You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/03/09 16:14:23 UTC
[06/30] incubator-usergrid git commit: Added metrics for the deindex
operation.
Added metrics for the deindex operation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ff46465d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ff46465d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ff46465d
Branch: refs/heads/two-dot-o
Commit: ff46465d2fee3907ee41f47ad83e5244f85e514d
Parents: 0f203b6
Author: GERey <gr...@apigee.com>
Authored: Wed Mar 4 15:54:49 2015 -0800
Committer: GERey <gr...@apigee.com>
Committed: Wed Mar 4 15:54:49 2015 -0800
----------------------------------------------------------------------
.../index/impl/EsEntityIndexBatchImpl.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff46465d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index c2a3fdc..d987b29 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.persistence.index.impl;
import java.util.*;
import org.apache.usergrid.persistence.core.future.BetterFuture;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.index.*;
import org.elasticsearch.action.delete.DeleteRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -49,6 +50,9 @@ import org.apache.usergrid.persistence.model.field.StringField;
import org.apache.usergrid.persistence.model.field.UUIDField;
import org.apache.usergrid.persistence.model.field.value.EntityObject;
+import com.codahale.metrics.*;
+import com.codahale.metrics.Timer;
+
import rx.Observable;
import rx.functions.Func1;
@@ -81,9 +85,12 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
private final AliasedEntityIndex entityIndex;
private IndexOperationMessage container;
+ private final Timer batchTimer;
+
- public EsEntityIndexBatchImpl(final ApplicationScope applicationScope, final Client client,final IndexBufferProducer indexBatchBufferProducer,
- final IndexFig config, final AliasedEntityIndex entityIndex ) {
+ public EsEntityIndexBatchImpl(final ApplicationScope applicationScope, final Client client,
+ final IndexBufferProducer indexBatchBufferProducer,final IndexFig config,
+ final AliasedEntityIndex entityIndex,final MetricsFactory metricsFactory ) {
this.applicationScope = applicationScope;
this.client = client;
@@ -92,6 +99,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
this.indexIdentifier = IndexingUtils.createIndexIdentifier(config, applicationScope);
this.alias = indexIdentifier.getAlias();
this.refresh = config.isForcedRefresh();
+ this.batchTimer = metricsFactory.getTimer( EsEntityIndexBatchImpl.class, "entity.index.batch.timer" );
//constrained
this.container = new IndexOperationMessage();
}
@@ -167,6 +175,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
indexes = new String[]{indexIdentifier.getIndex(null)};
}
//get all indexes then flush everyone
+ Timer.Context timeDeindex = batchTimer.time();
Observable.from(indexes)
.map(new Func1<String, Object>() {
@Override
@@ -181,7 +190,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
return index;
}
}).toBlocking().last();
-
+ timeDeindex.stop();
log.debug("Deindexed Entity with index id " + indexId);
return this;