usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [06/10] usergrid git commit: add timer
Date Thu, 27 Aug 2015 22:16:01 GMT
add timer


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

Branch: refs/heads/two-dot-o-dev
Commit: c726129bd08fa9b6be6a102b4e6d0536e1d017af
Parents: c08ad51
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Aug 26 09:45:01 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Aug 26 09:45:01 2015 -0600

----------------------------------------------------------------------
 .../persistence/index/impl/EsEntityIndexImpl.java         | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c726129b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 800dac3..3ada5b9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -27,6 +27,7 @@ import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
 import org.apache.usergrid.persistence.core.migration.data.VersionedData;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.util.Health;
@@ -119,6 +120,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
     private final long queryTimeout;
     private final IndexBufferConsumer indexBatchBufferProducer;
     private final FailureMonitorImpl failureMonitor;
+    private final Timer aggregationTimer;
 
     private IndexCache aliasCache;
     private Timer mappingTimer;
@@ -153,8 +155,9 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
         this.addTimer = metricsFactory.getTimer(EsEntityIndexImpl.class, "index.add");
         this.updateAliasTimer = metricsFactory.getTimer(EsEntityIndexImpl.class, "index.update_alias");
         this.mappingTimer = metricsFactory.getTimer(EsEntityIndexImpl.class, "index.create_mapping");
-        this.refreshIndexMeter = metricsFactory.getMeter( EsEntityIndexImpl.class, "index.refresh_index"
);
-        this.searchTimer = metricsFactory.getTimer( EsEntityIndexImpl.class, "search" );
+        this.refreshIndexMeter = metricsFactory.getMeter(EsEntityIndexImpl.class, "index.refresh_index");
+        this.searchTimer = metricsFactory.getTimer(EsEntityIndexImpl.class, "search");
+        this.aggregationTimer = metricsFactory.getTimer( EsEntityIndexImpl.class, "aggregations"
);
 
     }
 
@@ -759,6 +762,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
         SumBuilder sumBuilder = new SumBuilder(key);
         sumBuilder.field("entitySize");
         builder.addAggregation(sumBuilder);
+
         Observable<Number> o = Observable.from(builder.execute())
             .map(response -> {
                 Sum aggregation = (Sum) response.getAggregations().get(key);
@@ -768,7 +772,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
                     return aggregation.getValue();
                 }
             });
-        Number val =  o.toBlocking().first();
+        Number val =   ObservableTimer.time(o,aggregationTimer).toBlocking().lastOrDefault(-1);
         return val.longValue();
     }
 


Mime
View raw message