usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [10/30] incubator-usergrid git commit: Added unique timers for each method. Also added TODO for places where I was unsure if a graphite timer was needed.
Date Mon, 09 Mar 2015 15:14:27 GMT
Added unique timers for each method. Also added TODO for places where I was unsure if a graphite
timer was needed.


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

Branch: refs/heads/two-dot-o
Commit: d54290986f8eacf3e7415223ebd7ab239f7e9715
Parents: cb35127
Author: GERey <greyes@apigee.com>
Authored: Thu Mar 5 15:57:24 2015 -0800
Committer: GERey <greyes@apigee.com>
Committed: Thu Mar 5 15:57:24 2015 -0800

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 83 ++++++++++++++------
 .../corepersistence/CpRelationManager.java      | 15 ++--
 .../index/impl/EsEntityIndexImpl.java           | 38 +++++----
 3 files changed, 90 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5429098/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e7efa6f..fa16f07 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -189,8 +189,6 @@ public class CpEntityManager implements EntityManager {
 
     private boolean skipAggregateCounters;
 
-    private Timer corePersistanceTimer;
-
 //    /** Short-term cache to keep us from reloading same Entity during single request. */
 //    private LoadingCache<EntityScope, org.apache.usergrid.persistence.model.entity.Entity>
entityCache;
 
@@ -206,7 +204,6 @@ public class CpEntityManager implements EntityManager {
         Preconditions.checkNotNull( applicationId, "applicationId must not be null" );
 
         this.emf = ( CpEntityManagerFactory ) emf;
-        corePersistanceTimer = this.emf.getMetricsFactory().getTimer( CpEntityManager.class,
"cp.entity.manager.timer" );
         this.managerCache = this.emf.getManagerCache();
         this.applicationId = applicationId;
 
@@ -310,7 +307,7 @@ public class CpEntityManager implements EntityManager {
         Entity entity = batchCreate( m, entityType, null, properties, importId, timestampUuid
);
 
         //Adding graphite metrics
-        Timer.Context timeCassCreation = corePersistanceTimer.time();
+        Timer.Context timeCassCreation = this.emf.getMetricsFactory().getTimer( CpEntityManager.class,
"cp.entity.create.timer" ).time();
         m.execute();
         timeCassCreation.stop();
 
@@ -344,7 +341,9 @@ public class CpEntityManager implements EntityManager {
         A entity = batchCreate( m, entityType, entityClass, properties, importId, timestampUuid
);
 
         //Adding graphite metrics
-        Timer.Context timeEntityCassCreation = corePersistanceTimer.time();
+        Timer.Context timeEntityCassCreation = this.emf.getMetricsFactory()
+                                                       .getTimer( CpEntityManager.class,
+                                                           "cp.entity.create.batch.timer"
).time();
         m.execute();
         timeEntityCassCreation.stop();
 
@@ -987,6 +986,7 @@ public class CpEntityManager implements EntityManager {
                 cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
         } );
 
+        //TODO: does this call and others like it need a graphite reporter?
         cpEntity = ecm.write( cpEntity ).toBlockingObservable().last();
 
         logger.debug( "Wrote {}:{} version {}", new Object[] {
@@ -994,7 +994,9 @@ public class CpEntityManager implements EntityManager {
         } );
 
         //Adding graphite metrics
-        Timer.Context timeESBatch = corePersistanceTimer.time();
+        Timer.Context timeESBatch = this.emf.getMetricsFactory()
+                                            .getTimer( CpEntityManager.class,
+                                                "cp.entity.es.delete.property.timer" ).time();
         BetterFuture future = ei.createBatch().index( defaultIndexScope, cpEntity ).execute();
         timeESBatch.stop();
         // update in all containing collections and connection indexes
@@ -1034,7 +1036,9 @@ public class CpEntityManager implements EntityManager {
         batch = batchUpdateDictionary( batch, entity, dictionaryName, elementName, elementValue,
false, timestampUuid );
 
         //Adding graphite metrics
-        Timer.Context timeDictionaryCreation = corePersistanceTimer.time();
+        Timer.Context timeDictionaryCreation = this.emf.getMetricsFactory()
+                                                       .getTimer( CpEntityManager.class,
+                                                           "cp.entity.add.dictionary.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeDictionaryCreation.stop();
     }
@@ -1058,7 +1062,9 @@ public class CpEntityManager implements EntityManager {
         }
 
         //Adding graphite metrics
-        Timer.Context timeAddingSetDictionary = corePersistanceTimer.time();
+        Timer.Context timeAddingSetDictionary = this.emf.getMetricsFactory()
+                                                        .getTimer( CpEntityManager.class,
+                                                            "cp.entity.add.dictionary.set.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeAddingSetDictionary.stop();
     }
@@ -1083,7 +1089,9 @@ public class CpEntityManager implements EntityManager {
         }
 
         //Adding graphite metrics
-        Timer.Context timeMapDictionary = corePersistanceTimer.time();
+        Timer.Context timeMapDictionary = this.emf.getMetricsFactory()
+                                                  .getTimer( CpEntityManager.class,
+                                                      "cp.entity.add.dictionary.map.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeMapDictionary.stop();
     }
@@ -1263,7 +1271,9 @@ public class CpEntityManager implements EntityManager {
 
         batch = batchUpdateDictionary( batch, entity, dictionaryName, elementName, true,
timestampUuid );
         //Adding graphite metrics
-        Timer.Context timeRemoveDictionary = corePersistanceTimer.time();
+        Timer.Context timeRemoveDictionary = this.emf.getMetricsFactory()
+                                                     .getTimer( CpEntityManager.class,
+                                                         "cp.entity.remove.dictionary.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeRemoveDictionary.stop();
 
@@ -1602,7 +1612,9 @@ public class CpEntityManager implements EntityManager {
                 CassandraPersistenceUtils.key( ownerId, DICTIONARY_SETS ), Schema.DICTIONARY_ROLENAMES,
null,
                 timestamp );
         //Adding graphite metrics
-        Timer.Context timeCreateBatchRole= corePersistanceTimer.time();
+        Timer.Context timeCreateBatchRole= this.emf.getMetricsFactory()
+                                                   .getTimer( CpEntityManager.class,
+                                                       "cp.entity.create.role.timer" ).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeCreateBatchRole.stop();
 
@@ -1619,7 +1631,9 @@ public class CpEntityManager implements EntityManager {
         CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
             getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ), timestamp
);
         //Adding graphite metrics
-        Timer.Context timeGrantRolePermission = corePersistanceTimer.time();
+        Timer.Context timeGrantRolePermission = this.emf.getMetricsFactory()
+                                                        .getTimer( CpEntityManager.class,
+                                                            "cp.entity.create.role.permission.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeGrantRolePermission.stop();
     }
@@ -1637,7 +1651,9 @@ public class CpEntityManager implements EntityManager {
                 getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ),
timestamp);
         }
         //Adding graphite metrics
-        Timer.Context timeGrantRolePermissions = corePersistanceTimer.time();
+        Timer.Context timeGrantRolePermissions = this.emf.getMetricsFactory()
+                                                         .getTimer( CpEntityManager.class,
+                                                             "cp.entity.create.role.permissions.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeGrantRolePermissions.stop();
 
@@ -1671,12 +1687,14 @@ public class CpEntityManager implements EntityManager {
         CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
                 getRolePermissionsKey( roleName ), permission, timestamp );
         //Adding graphite metrics
-        Timer.Context timeRevokeRolePermission = corePersistanceTimer.time();
+        Timer.Context timeRevokeRolePermission = this.emf.getMetricsFactory()
+                                                         .getTimer( CpEntityManager.class,
+                                                             "cp.entity.revoke.role.permissions.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeRevokeRolePermission.stop();
     }
 
-
+//TODO: does this need graphite monitoring
     @Override
     public Set<String> getRolePermissions( String roleName ) throws Exception {
         roleName = roleName.toLowerCase();
@@ -1684,7 +1702,7 @@ public class CpEntityManager implements EntityManager {
                 ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ) );
     }
 
-
+//TODO: does this need graphite monitoring
     @Override
     public void deleteRole( String roleName ) throws Exception {
         roleName = roleName.toLowerCase();
@@ -1739,7 +1757,9 @@ public class CpEntityManager implements EntityManager {
             getRolePermissionsKey( groupId, roleName ), permission, ByteBuffer.allocate(
0 ), timestamp );
 
         //Adding graphite metrics
-        Timer.Context timeGroupRolePermission = corePersistanceTimer.time();
+        Timer.Context timeGroupRolePermission = this.emf.getMetricsFactory()
+                                                        .getTimer( CpEntityManager.class,
+                                                            "cp.entity.grant.group.permission.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeGroupRolePermission.stop();
     }
@@ -1754,7 +1774,9 @@ public class CpEntityManager implements EntityManager {
         CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
                 getRolePermissionsKey( groupId, roleName ), permission, timestamp );
         //Adding graphite metrics
-        Timer.Context timeRevokeGroupRolePermission = corePersistanceTimer.time();
+        Timer.Context timeRevokeGroupRolePermission = this.emf.getMetricsFactory()
+                                                              .getTimer( CpEntityManager.class,
+                                                                  "cp.entity.revoke.group.permission.timer"
).time();
         CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
         timeRevokeGroupRolePermission.stop();
     }
@@ -1906,7 +1928,10 @@ public class CpEntityManager implements EntityManager {
                     category, counterName, value, cassandraTimestamp / 1000, cassandraTimestamp
);
 
             //Adding graphite metrics
-            Timer.Context timeIncrementAggregateCounters = corePersistanceTimer.time();
+            Timer.Context timeIncrementAggregateCounters = this.emf.getMetricsFactory()
+                                                                   .getTimer( CpEntityManager.class,
+                                                                       "cp.entity.increment.aggregate.counters.timer"
)
+                                                                   .time();
             CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
             timeIncrementAggregateCounters.stop();
         }
@@ -1934,7 +1959,9 @@ public class CpEntityManager implements EntityManager {
         q.setRange( start, finish, false, ALL_COUNT );
 
         //Adding graphite metrics
-        Timer.Context timeGetAggregateCounters = corePersistanceTimer.time();
+        Timer.Context timeGetAggregateCounters = this.emf.getMetricsFactory()
+                                                         .getTimer( CpEntityManager.class,
+                                                             "cp.entity.get.aggregate.counters.timer"
).time();
         QueryResult<CounterSlice<Long>> r = q.setKey(
                 counterUtils.getAggregateCounterRow( counterName, userId, groupId, queueId,
category, resolution ) )
                                              .execute();
@@ -2009,7 +2036,9 @@ public class CpEntityManager implements EntityManager {
         q.setColumnFamily( APPLICATION_AGGREGATE_COUNTERS.toString() );
         q.setRange( start, finish, false, ALL_COUNT );
         //Adding graphite metrics
-        Timer.Context timeGetAggregateCounters = corePersistanceTimer.time();
+        Timer.Context timeGetAggregateCounters = this.emf.getMetricsFactory()
+                                                         .getTimer( CpEntityManager.class,
+                                                             "cp.entity.get.aggregate.counters.query.timer"
).time();
         QueryResult<CounterRows<String, Long>> rows = q.setKeys( selections.keySet()
).execute();
         timeGetAggregateCounters.stop();
 
@@ -2136,7 +2165,9 @@ public class CpEntityManager implements EntityManager {
         q.setColumnFamily( ENTITY_COUNTERS.toString() );
         q.setRange( null, null, false, ALL_COUNT );
         //Adding graphite metrics
-        Timer.Context timeEntityCounters = corePersistanceTimer.time();
+        Timer.Context timeEntityCounters = this.emf.getMetricsFactory()
+                                                   .getTimer( CpEntityManager.class,
+                                                       "cp.entity.get.entity.counters.timer"
).time();
         QueryResult<CounterSlice<String>> r = q.setKey( entityId ).execute();
         timeEntityCounters.stop();
         for ( HCounterColumn<String> column : r.get().getColumns() ) {
@@ -2163,7 +2194,9 @@ public class CpEntityManager implements EntityManager {
                     m, applicationId, userId, groupId, null, category, counters, timestamp
);
 
             //Adding graphite metrics
-            Timer.Context timeIncrementCounters = corePersistanceTimer.time();
+            Timer.Context timeIncrementCounters = this.emf.getMetricsFactory()
+                                                          .getTimer( CpEntityManager.class,
+                                                              "cp.entity.increment.aggregate.counters.timer"
).time();
             CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
             timeIncrementCounters.stop();
         }
@@ -2897,7 +2930,9 @@ public class CpEntityManager implements EntityManager {
         //        batch.index(appAllTypesScope, memberEntity);
 
         //Adding graphite metrics
-        Timer.Context timeIndexEntityCollection = corePersistanceTimer.time();
+        Timer.Context timeIndexEntityCollection = this.emf.getMetricsFactory()
+                                                          .getTimer( CpEntityManager.class,
+                                                              "cp.entity.es.index.entity.to.collection.timer"
).time();
         batch.execute();
         timeIndexEntityCollection.stop();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5429098/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 499f841..f5d59d9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -121,7 +121,6 @@ import rx.functions.Func1;
 import static java.util.Arrays.asList;
 
 import static me.prettyprint.hector.api.factory.HFactory.createMutator;
-import static org.apache.usergrid.corepersistence.util.CpEntityMapUtils.entityToCpEntity;
 import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType;
 import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
 import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
@@ -190,8 +189,6 @@ public class CpRelationManager implements RelationManager {
 
     private ResultsLoaderFactory resultsLoaderFactory;
 
-    private Timer cpRelationTimer;
-
     private MetricsFactory metricsFactory;
 
     public CpRelationManager() {}
@@ -224,7 +221,6 @@ public class CpRelationManager implements RelationManager {
         this.cass = em.getCass(); // TODO: eliminate need for this via Core Persistence
         this.indexBucketLocator = indexBucketLocator; // TODO: this also
         this.metricsFactory = metricsFactory;
-        this.cpRelationTimer = metricsFactory.getTimer( CpRelationManager.class, "relation.manager.timer"
);
 
         // load the Core Persistence version of the head entity as well
         this.headEntityScope = getCollectionScopeNameFromEntityType(
@@ -449,7 +445,8 @@ public class CpRelationManager implements RelationManager {
                 } ).count().toBlocking().lastOrDefault( 0 );
 
         //Adding graphite metrics
-        Timer.Context timeElasticIndexBatch = cpRelationTimer.time();
+        Timer.Context timeElasticIndexBatch = metricsFactory
+            .getTimer( CpRelationManager.class, "relation.manager.es.update.collection" ).time();
         entityIndexBatch.execute();
         timeElasticIndexBatch.stop();
 
@@ -1075,7 +1072,8 @@ public class CpRelationManager implements RelationManager {
         Mutator<ByteBuffer> m = createMutator( ko, be );
         batchUpdateEntityConnection( m, false, connection, UUIDGenerator.newTimeUUID() );
         //Added Graphite Metrics
-        Timer.Context timeElasticIndexBatch = cpRelationTimer.time();
+        Timer.Context timeElasticIndexBatch = metricsFactory
+            .getTimer( CpRelationManager.class, "relation.manager.es.create.connection.timer"
).time();
         batchExecute( m, CassandraService.RETRY_COUNT );
         timeElasticIndexBatch.stop();
 
@@ -1251,7 +1249,8 @@ public class CpRelationManager implements RelationManager {
                 m, true, ( ConnectionRefImpl ) connectionRef, UUIDGenerator.newTimeUUID()
);
 
         //Added Graphite Metrics
-        Timer.Context timeDeleteConnections = cpRelationTimer.time();
+        Timer.Context timeDeleteConnections = metricsFactory
+            .getTimer( CpRelationManager.class, "relation.manager.cassandra.delete.connection.batch.timer"
).time();
         batchExecute( m, CassandraService.RETRY_COUNT );
         timeDeleteConnections.stop();
 
@@ -1309,7 +1308,7 @@ public class CpRelationManager implements RelationManager {
 //        batch.deindex( allTypesIndexScope, targetEntity );
 
         //Added Graphite Metrics
-        Timer.Context timeDeleteConnection = cpRelationTimer.time();
+        Timer.Context timeDeleteConnection = metricsFactory.getTimer( CpRelationManager.class,
"relation.manager.es.delete.connection.batch.timer" ).time();
         batch.execute();
         timeDeleteConnection.stop();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5429098/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 f85692f..2cbe51f 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
@@ -126,7 +126,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
     private EsIndexCache aliasCache;
 
-    private final Timer indexTimer;
+//    private final Timer indexTimer;
 
 
     @Inject
@@ -139,12 +139,11 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
         this.esProvider = provider;
         this.config = config;
         this.cursorTimeout = config.getQueryCursorTimeout();
-        this.indexIdentifier = IndexingUtils.createIndexIdentifier(config, appScope);
+        this.indexIdentifier = IndexingUtils.createIndexIdentifier( config, appScope );
         this.alias = indexIdentifier.getAlias();
         this.failureMonitor = new FailureMonitorImpl( config, provider );
         this.aliasCache = indexCache;
         this.metricsFactory = metricsFactory;
-        this.indexTimer = metricsFactory.getTimer( EsEntityIndexImpl.class, "entity.index.timer"
);
     }
 
     @Override
@@ -176,7 +175,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                     .build();
 
                 //Added For Graphite Metrics
-                Timer.Context timeNewIndexCreation = indexTimer.time();
+                Timer.Context timeNewIndexCreation = metricsFactory
+                    .getTimer( EsEntityIndexImpl.class, "es.entity.index.add.index.timer"
).time();
                 final CreateIndexResponse cir = admin.indices().prepareCreate(indexName)
                         .setSettings(settings)
                         .execute()
@@ -209,7 +209,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
             for (String currentIndex : indexNames){
                 //Added For Graphite Metrics
-                Timer.Context timeRemoveAlias = indexTimer.time();
+                Timer.Context timeRemoveAlias = metricsFactory
+                    .getTimer( EsEntityIndexImpl.class, "es.entity.index.remove.index.alias.timer"
).time();
                 isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,
                         alias.getWriteAlias()).execute().actionGet().isAcknowledged();
                 timeRemoveAlias.stop();
@@ -217,7 +218,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
             }
 
             //Added For Graphite Metrics
-            Timer.Context timeAddReadAlias = indexTimer.time();
+            Timer.Context timeAddReadAlias = metricsFactory
+                .getTimer( EsEntityIndexImpl.class, "es.entity.index.add.read.alias.timer"
).time();
             // add read alias
             isAck = adminClient.indices().prepareAliases().addAlias(
                     indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
@@ -225,7 +227,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
             logger.info("Created new read Alias Name [{}] ACK=[{}]", alias.getReadAlias(),
isAck);
 
             //Added For Graphite Metrics
-            Timer.Context timeAddWriteAlias = indexTimer.time();
+            Timer.Context timeAddWriteAlias = metricsFactory
+                .getTimer( EsEntityIndexImpl.class, "es.entity.index.add.write.alias.timer"
).time();
             //add write alias
             isAck = adminClient.indices().prepareAliases().addAlias(
                     indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
@@ -296,7 +299,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                 XContentFactory.jsonBuilder(), "_default_");
 
         //Added For Graphite Metrics
-        Timer.Context timePutIndex = indexTimer.time();
+        Timer.Context timePutIndex = metricsFactory
+            .getTimer( EsEntityIndexImpl.class, "es.entity.index.create.mapping.timer" ).time();
         PutIndexTemplateResponse pitr = esProvider.getClient().admin().indices()
                 .preparePutTemplate("usergrid_template")
                 // set mapping as the default for all types
@@ -389,7 +393,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
             try {
                 //Added For Graphite Metrics
-                Timer.Context timeSearch = indexTimer.time();
+                Timer.Context timeSearch = metricsFactory
+                    .getTimer( EsEntityIndexImpl.class, "es.entity.index.search.timer" ).time();
                 searchResponse = srb.execute().actionGet();
                 timeSearch.stop();
             }
@@ -417,7 +422,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
             try {
                 //Added For Graphite Metrics
-                Timer.Context timeSearchCursor = indexTimer.time();
+                Timer.Context timeSearchCursor = metricsFactory
+                    .getTimer( EsEntityIndexImpl.class, "es.entity.index.search.cursor.timer"
).time();
                 searchResponse = ssrb.execute().actionGet();
                 timeSearchCursor.stop();
             }
@@ -489,7 +495,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                         return true;
                     }
                     //Added For Graphite Metrics
-                    Timer.Context timeRefreshIndex = indexTimer.time();
+                    Timer.Context timeRefreshIndex = metricsFactory
+                        .getTimer( EsEntityIndexImpl.class, "es.entity.index.refresh.timer"
).time();
                     esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
                     timeRefreshIndex.stop();
                     logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", "));
@@ -535,7 +542,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
         final SearchResponse searchResponse;
         try {
             //Added For Graphite Metrics
-            Timer.Context timeEntityIndex = indexTimer.time();
+            Timer.Context timeEntityIndex = metricsFactory
+                .getTimer( EsEntityIndexImpl.class, "es.entity.index.get.versions.timer"
).time();
             searchResponse = srb.execute().actionGet();
             timeEntityIndex.stop();
         }
@@ -560,7 +568,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
         final TermQueryBuilder tqb = QueryBuilders.termQuery( ENTITYID_ID_FIELDNAME, idString
);
 
         //Added For Graphite Metrics
-        final Timer.Context timeDeleteAllVersions = indexTimer.time();
+        final Timer.Context timeDeleteAllVersions = metricsFactory
+            .getTimer( EsEntityIndexImpl.class, "es.entity.index.delete.all.versions.timer"
).time();
         final ListenableActionFuture<DeleteByQueryResponse> response = esProvider.getClient()
             .prepareDeleteByQuery( alias.getWriteAlias() ).setQuery( tqb ).execute();
 
@@ -601,7 +610,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
         //Added For Graphite Metrics
         //Checks the time from the execute to the response below
-        final Timer.Context timeDeletePreviousVersions = indexTimer.time();
+        final Timer.Context timeDeletePreviousVersions = metricsFactory
+            .getTimer( EsEntityIndexImpl.class, "es.entity.index.delete.previous.versions.timer"
).time();
         final ListenableActionFuture<DeleteByQueryResponse> response = esProvider.getClient()
             .prepareDeleteByQuery(alias.getWriteAlias()).setQuery(fqb).execute();
 


Mime
View raw message