ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-13245. RU cluster in hung state while trying to perform downgrade (part2) (jonathanhurley)
Date Sat, 26 Sep 2015 02:48:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 c936847b0 -> e3ef9124c


AMBARI-13245. RU cluster in hung state while trying to perform downgrade (part2) (jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e3ef9124
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e3ef9124
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e3ef9124

Branch: refs/heads/branch-2.1
Commit: e3ef9124c1e6c528207041c3114d819a10b06c57
Parents: c936847
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Sep 25 20:26:10 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Sep 25 22:48:37 2015 -0400

----------------------------------------------------------------------
 .../actionmanager/ActionDBAccessorImpl.java     | 45 +++++---------------
 .../ambari/server/actionmanager/Request.java    | 35 +++------------
 .../apache/ambari/server/utils/Parallel.java    | 12 +++++-
 3 files changed, 26 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3ef9124/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
index 146a1e9..9514925 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
@@ -137,24 +137,12 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
   @Override
   public List<Stage> getAllStages(long requestId) {
     List<StageEntity> stageEntities = stageDAO.findByRequestId(requestId);
-    ParallelLoopResult<Stage> loopResult = Parallel.forLoop(stageEntities, new LoopBody<StageEntity,
Stage>() {
-      @Override
-      public Stage run(StageEntity stageEntity) {
-        return stageFactory.createExisting(stageEntity);
-      }
-    });
-    if(loopResult.getIsCompleted()) {
-      return loopResult.getResult();
-    } else {
-      // Fetch any missing results sequentially
-      List<Stage> stages = loopResult.getResult();
-      for(int i = 0; i < stages.size(); i++) {
-        if(stages.get(i) == null) {
-          stages.set(i, stageFactory.createExisting(stageEntities.get(i)));
-        }
-      }
-      return stages;
+    List<Stage> stages = new ArrayList<>(stageEntities.size());
+    for( StageEntity stageEntity : stageEntities ){
+      stages.add(stageFactory.createExisting(stageEntity));
     }
+
+    return stages;
   }
 
   @Override
@@ -687,26 +675,13 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
   }
 
   @Override
-  public List<Request> getRequests(Collection<Long> requestIds){
+  public List<Request> getRequests(Collection<Long> requestIds) {
     List<RequestEntity> requestEntities = requestDAO.findByPks(requestIds);
-    ParallelLoopResult<Request> loopResult = Parallel.forLoop(requestEntities, new
LoopBody<RequestEntity, Request>() {
-      @Override
-      public Request run(RequestEntity requestEntity) {
-        return requestFactory.createExisting(requestEntity);
-      }
-    });
-    if(loopResult.getIsCompleted()) {
-      return loopResult.getResult();
-    } else {
-      // Fetch any missing results sequentially
-      List<Request> requests = loopResult.getResult();
-      for(int i = 0; i < requests.size(); i++) {
-        if(requests.get(i) == null) {
-          requests.set(i, requestFactory.createExisting(requestEntities.get(i)));
-        }
-      }
-      return requests;
+    List<Request> requests = new ArrayList<Request>(requestEntities.size());
+    for (RequestEntity requestEntity : requestEntities) {
+      requests.add(requestFactory.createExisting(requestEntity));
     }
+    return requests;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3ef9124/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
index 26447e6..31e11c1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
@@ -23,7 +23,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import com.google.inject.Inject;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.controller.ExecuteActionRequest;
@@ -37,14 +36,12 @@ import org.apache.ambari.server.orm.entities.RequestOperationLevelEntity;
 import org.apache.ambari.server.orm.entities.RequestResourceFilterEntity;
 import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.utils.LoopBody;
-import org.apache.ambari.server.utils.Parallel;
-import org.apache.ambari.server.utils.ParallelLoopResult;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.gson.Gson;
+import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
 
@@ -197,32 +194,12 @@ public class Request {
     if(stageEntities == null || stageEntities.isEmpty()) {
       stages = Collections.emptyList();
     } else {
-      List<StageEntity> stageEntityList;
-      if(stageEntities instanceof List) {
-        stageEntityList = (List<StageEntity>) stageEntities;
-      } else {
-        stageEntityList = new ArrayList<StageEntity>(stageEntities);
-      }
-      ParallelLoopResult<Stage> loopResult = Parallel.forLoop(stageEntityList, new
LoopBody<StageEntity, Stage>() {
-        @Override
-        public Stage run(StageEntity stageEntity) {
-          return stageFactory.createExisting(stageEntity);
-        }
-      });
-      List<Stage> stageList;
-      if(loopResult.getIsCompleted()) {
-        stageList = loopResult.getResult();
-      } else {
-        // Fetch any missing results sequentially
-        stageList = loopResult.getResult();
-        for(int i = 0; i < stages.size(); i++) {
-          if(stageList.get(i) == null) {
-            stageList.set(i, stageFactory.createExisting(stageEntityList.get(i)));
-          }
-        }
+      stages = new ArrayList<>(stageEntities.size());
+      for (StageEntity stageEntity : stageEntities) {
+        stages.add(stageFactory.createExisting(stageEntity));
       }
-      stages = stageList;
     }
+
     resourceFilters = filtersFromEntity(entity);
     operationLevel = operationLevelFromEntity(entity);
   }
@@ -424,7 +401,7 @@ public class Request {
   }
 
   public void setExclusive(boolean isExclusive) {
-    this.exclusive = isExclusive;
+    exclusive = isExclusive;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3ef9124/ambari-server/src/main/java/org/apache/ambari/server/utils/Parallel.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/Parallel.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/Parallel.java
index 903be0f..3b7af98 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/Parallel.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/Parallel.java
@@ -35,13 +35,21 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.eclipse.persistence.internal.helper.ConcurrencyManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- *  This class provides support for parallel loops.
- *  Iterations in the loop run in parallel in parallel loops.
+ * <b>TEMPORARILY DO NOT USE WITH JPA ENTITIES</b>
+ * <p/>
+ * Deprecated since the use of this class to access JPA from multiple Ambari
+ * threads seems to cause thread liveliness problems in
+ * {@link ConcurrencyManager}.
+ * <p/>
+ * This class provides support for parallel loops. Iterations in the loop run in
+ * parallel in parallel loops.
  */
+@Deprecated
 public class Parallel {
 
   /**


Mime
View raw message