ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [21/50] [abbrv] ambari git commit: AMBARI-13245. RU cluster in hung state while trying to perform downgrade (part2) (jonathanhurley)
Date Wed, 30 Sep 2015 14:45:41 GMT
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/156afda5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/156afda5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/156afda5

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 156afda504ce75fdfaf0efd2509ca757baefc463
Parents: 7e2a1c0
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:29:56 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/156afda5/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 8768590..0f439de 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
@@ -138,24 +138,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
@@ -701,26 +689,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/156afda5/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/156afda5/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 9ca039b..c6e2156 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