usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [07/31] incubator-usergrid git commit: Added Metrics factory to CpEntityManager and its corresponding factory.
Date Mon, 09 Mar 2015 15:25:20 GMT
Added Metrics factory to CpEntityManager and its corresponding factory.


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

Branch: refs/heads/USERGRID-405
Commit: b3d4eb2b50336307fdece0fc2edc390c4b658fcd
Parents: ff46465
Author: GERey <greyes@apigee.com>
Authored: Wed Mar 4 16:06:17 2015 -0800
Committer: GERey <greyes@apigee.com>
Committed: Wed Mar 4 16:06:17 2015 -0800

----------------------------------------------------------------------
 .../apache/usergrid/corepersistence/CpEntityManager.java | 10 +++++++++-
 .../usergrid/corepersistence/CpEntityManagerFactory.java | 11 ++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b3d4eb2b/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 5619382..10e7926 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
@@ -72,6 +72,7 @@ import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
+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.entities.Application;
@@ -103,6 +104,7 @@ import org.apache.usergrid.utils.CompositeUtils;
 import org.apache.usergrid.utils.StringUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 
+import com.codahale.metrics.Timer;
 import com.google.common.base.Preconditions;
 import com.netflix.hystrix.exception.HystrixRuntimeException;
 import com.yammer.metrics.annotation.Metered;
@@ -187,12 +189,16 @@ public class CpEntityManager implements EntityManager {
 
     private boolean skipAggregateCounters;
 
+    private final 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;
 
 
-    public CpEntityManager() {}
+    public CpEntityManager() {
+        corePersistanceTimer = emf.getMetricsFactory().getTimer( CpEntityManager.class, "cp.entity.manager.timer"
);
 
+    }
 
     @Override
     public void init( EntityManagerFactory emf, UUID applicationId ) {
@@ -303,7 +309,9 @@ public class CpEntityManager implements EntityManager {
 
         Entity entity = batchCreate( m, entityType, null, properties, importId, timestampUuid
);
 
+        Timer.Context timeCassCreation = corePersistanceTimer.time();
         m.execute();
+        timeCassCreation.stop();
 
         return entity;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b3d4eb2b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 9aa36a0..b247eae 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -44,6 +44,7 @@ import org.apache.usergrid.persistence.cassandra.Setup;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
@@ -105,17 +106,18 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
     private CassandraService cassandraService;
     private CounterUtils counterUtils;
     private Injector injector;
-
+    private final MetricsFactory metricsFactory;
 
     public CpEntityManagerFactory(
-            final CassandraService cassandraService, final CounterUtils counterUtils, final
Injector injector) {
+            final CassandraService cassandraService, final CounterUtils counterUtils, final
Injector injector,
+                                 final MetricsFactory metricsFactory) {
 
         this.cassandraService = cassandraService;
         this.counterUtils = counterUtils;
         this.injector = injector;
         this.managerCache = injector.getInstance( ManagerCache.class );
         this.dataMigrationManager = injector.getInstance( DataMigrationManager.class );
-
+        this.metricsFactory = metricsFactory;
 
     }
 
@@ -194,6 +196,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         return em;
     }
 
+    public MetricsFactory getMetricsFactory(){
+        return metricsFactory;
+    }
 
     @Override
     public UUID createApplication(String organizationName, String name) throws Exception
{


Mime
View raw message