usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [03/31] incubator-usergrid git commit: Added timer to elasticsearch index addition.
Date Mon, 09 Mar 2015 15:25:16 GMT
Added timer to elasticsearch index addition.


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

Branch: refs/heads/USERGRID-405
Commit: 00e7ca4b599e14953e01dc608f90de7a4cdcbd9f
Parents: c1f5b78
Author: GERey <greyes@apigee.com>
Authored: Wed Mar 4 15:03:15 2015 -0800
Committer: GERey <greyes@apigee.com>
Committed: Wed Mar 4 15:03:15 2015 -0800

----------------------------------------------------------------------
 .../persistence/index/impl/EsEntityIndexImpl.java   | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00e7ca4b/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 49026e2..4200d13 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
@@ -18,6 +18,8 @@
 package org.apache.usergrid.persistence.index.impl;
 
 
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Timer;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -26,6 +28,7 @@ import com.google.inject.assistedinject.Assisted;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.usergrid.persistence.core.future.BetterFuture;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.core.util.ValidationUtils;
@@ -121,9 +124,16 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
     private EsIndexCache aliasCache;
 
+    private final Timer flushTimer;
+
+    //private final Meter flushMeter;
+
+
 
     @Inject
-    public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
final IndexBufferProducer indexBatchBufferProducer, final EsProvider provider, final EsIndexCache
indexCache) {
+    public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
+                              final IndexBufferProducer indexBatchBufferProducer, final EsProvider
provider,
+                              final EsIndexCache indexCache, final MetricsFactory metricsFactory)
{
         this.indexBatchBufferProducer = indexBatchBufferProducer;
         ValidationUtils.validateApplicationScope( appScope );
         this.applicationScope = appScope;
@@ -134,6 +144,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
         this.alias = indexIdentifier.getAlias();
         this.failureMonitor = new FailureMonitorImpl( config, provider );
         this.aliasCache = indexCache;
+        this.flushTimer = metricsFactory.getTimer( EsEntityIndexImpl.class, "entity.index.flush"
);
     }
 
     @Override
@@ -163,10 +174,13 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                         .put("index.number_of_replicas", numberOfReplicas)
                         .put("action.write_consistency", writeConsistency )
                     .build();
+
+                Timer.Context timeNewIndexCreation = flushTimer.time();
                 final CreateIndexResponse cir = admin.indices().prepareCreate(indexName)
                         .setSettings(settings)
                         .execute()
                         .actionGet();
+                timeNewIndexCreation.stop();
                 logger.info("Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged());
             } catch (IndexAlreadyExistsException e) {
                 logger.info("Index Name [{}] already exists", indexName);


Mime
View raw message