ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-6306 API: filtering operations are slow (more than 40 seconds) on 2k-node cluster (dsen)
Date Fri, 27 Jun 2014 15:41:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 ef54ef1ba -> f94893d72


AMBARI-6306 API: filtering operations are slow (more than 40 seconds) on 2k-node cluster (dsen)


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

Branch: refs/heads/branch-1.6.1
Commit: f94893d72b5b81bf0a8357910caee823b40e3efa
Parents: ef54ef1
Author: Dmytro Sen <dsen@hortonworks.com>
Authored: Fri Jun 27 18:14:41 2014 +0300
Committer: Dmytro Sen <dsen@hortonworks.com>
Committed: Fri Jun 27 18:14:41 2014 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/api/query/QueryImpl.java | 18 +++++++++++++++---
 .../internal/ClusterControllerImpl.java           | 14 +++-----------
 .../server/controller/spi/ClusterController.java  |  8 ++++++++
 3 files changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f94893d7/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
index ec8a3d4..a607761 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
@@ -324,6 +324,17 @@ public class QueryImpl implements Query, ResourceInstance {
   }
 
   /**
+   * @param type the resource type
+   * @return whether sub-resources is in processed predicate
+   */
+  private boolean populateResourceRequired(Resource.Type type) {
+    ResourceProvider resourceProvider = clusterController.ensureResourceProvider(type);
+    Set<String> subResourcePropertiesInpredicate =
+      resourceProvider.checkPropertyIds(PredicateHelper.getPropertyIds(processedPredicate));
+    return !subResourcePropertiesInpredicate.isEmpty();
+  }
+
+  /**
    * Query the cluster controller for the top level resources.
    */
   private void queryForResources()
@@ -343,9 +354,10 @@ public class QueryImpl implements Query, ResourceInstance {
     Set<Resource> resourceSet = new LinkedHashSet<Resource>();
 
     Set<Resource> queryResources = doQuery(resourceType, request, queryPredicate);
-    // If there is a page request and there is no user predicate
-    if ((pageRequest != null || sortRequest != null )&&
-      userPredicate == null) {
+    // If there is a page request and the predicate does not contain properties
+    // that need to be set
+    if ((pageRequest != null || sortRequest != null ) &&
+      !populateResourceRequired(resourceType)) {
       PageResponse pageResponse = clusterController.getPage(resourceType,
         queryResources, request, queryPredicate, pageRequest, sortRequest);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f94893d7/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
index 3f8f317..48767d5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
@@ -317,23 +317,15 @@ public class ClusterControllerImpl implements ClusterController {
     return null;
   }
 
-
-  // ----- ClusterControllerImpl ---------------------------------------------
-
-  /**
-   * Get the resource provider for the given type, creating it if required.
-   *
-   * @param type  the resource type
-   *
-   * @return the resource provider
-   */
+  @Override
   public ResourceProvider ensureResourceProvider(Type type) {
     synchronized (resourceProviders) {
       if (!resourceProviders.containsKey(type)) {
         resourceProviders.put(type, providerModule.getResourceProvider(type));
       }
     }
-    return resourceProviders.get(type);   }
+    return resourceProviders.get(type);
+  }
 
 
   // ----- helper methods ----------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/f94893d7/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
index d7d916e..35ea680 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
@@ -134,6 +134,14 @@ public interface ClusterController extends SchemaFactory {
    */
   public Schema getSchema(Resource.Type type);
 
+  /**
+   * Get the resource provider for the given type, creating it if required.
+   *
+   * @param type  the resource type
+   *
+   * @return the resource provider
+   */
+  public ResourceProvider ensureResourceProvider(Resource.Type type);
 
   // ----- Management -------------------------------------------------------
 


Mime
View raw message