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/07/22 16:37:51 UTC
[1/3] incubator-usergrid git commit: add get by name timers
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-dev d32cee48b -> ca4575d6d
add get by name timers
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/75d59e7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/75d59e7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/75d59e7c
Branch: refs/heads/two-dot-o-dev
Commit: 75d59e7c06636ea8ee5d66c92484e0b87ddebf2b
Parents: 23ce4c5
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jul 21 14:03:31 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Jul 21 14:03:31 2015 -0600
----------------------------------------------------------------------
.../usergrid/services/AbstractService.java | 292 +++++++++++--------
1 file changed, 173 insertions(+), 119 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d59e7c/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index edf8ab2..660545e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -26,6 +26,9 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import com.codahale.metrics.Timer;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
@@ -98,8 +101,15 @@ public abstract class AbstractService implements Service {
private Scheduler rxScheduler;
private RxSchedulerFig rxSchedulerFig;
-
-
+ private MetricsFactory metricsFactory;
+ private Timer entityGetTimer;
+ private Timer entitiesGetTimer;
+ private Timer entitiesParallelGetTimer;
+ private Timer deleteByNameTimer;
+ private Timer postByNameTimer;
+ private Timer putByNameTimer;
+ private Timer getByNameTimer;
+ private Timer headByNameTimer;
public AbstractService() {
@@ -112,7 +122,16 @@ public abstract class AbstractService implements Service {
em = sm.getEntityManager();
final Injector injector = sm.getApplicationContext().getBean( Injector.class );
rxScheduler = injector.getInstance( RxTaskScheduler.class ).getAsyncIOScheduler();
- rxSchedulerFig = injector.getInstance( RxSchedulerFig.class );
+ rxSchedulerFig = injector.getInstance(RxSchedulerFig.class);
+ metricsFactory = injector.getInstance(MetricsFactory.class);
+ this.entityGetTimer = metricsFactory.getTimer(this.getClass(), "importEntity.get");
+ this.entitiesGetTimer = metricsFactory.getTimer(this.getClass(), "importEntities.get");
+ this.entitiesParallelGetTimer = metricsFactory.getTimer( this.getClass(),"importEntitiesP.get" );
+ this.getByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.get" );
+ this.putByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.put" );
+ this.postByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.post" );
+ this.deleteByNameTimer = metricsFactory.getTimer(this.getClass(), "byname.delete");
+ this.headByNameTimer = metricsFactory.getTimer(this.getClass(), "byname.head");
}
@@ -170,9 +189,9 @@ public abstract class AbstractService implements Service {
return false;
}
if ( "application".equals( context.getOwner().getType() ) ) {
- return Schema.getDefaultSchema().isCollectionReversed( "application", pluralize( info.getItemType() ) );
+ return Schema.getDefaultSchema().isCollectionReversed("application", pluralize(info.getItemType()));
}
- return Schema.getDefaultSchema().isCollectionReversed( info.getContainerType(), info.getCollectionName() );
+ return Schema.getDefaultSchema().isCollectionReversed(info.getContainerType(), info.getCollectionName());
}
@@ -181,9 +200,9 @@ public abstract class AbstractService implements Service {
return null;
}
if ( "application".equals( context.getOwner().getType() ) ) {
- return Schema.getDefaultSchema().getCollectionSort( "application", pluralize( info.getItemType() ) );
+ return Schema.getDefaultSchema().getCollectionSort("application", pluralize(info.getItemType()));
}
- return Schema.getDefaultSchema().getCollectionSort( info.getContainerType(), info.getCollectionName() );
+ return Schema.getDefaultSchema().getCollectionSort(info.getContainerType(), info.getCollectionName());
}
@@ -191,7 +210,7 @@ public abstract class AbstractService implements Service {
if ( privateConnections == null ) {
privateConnections = new LinkedHashSet<String>();
}
- privateConnections.add( connection );
+ privateConnections.add(connection);
}
@@ -199,7 +218,7 @@ public abstract class AbstractService implements Service {
if ( privateConnections == null ) {
privateConnections = new LinkedHashSet<String>();
}
- privateConnections.addAll( connections );
+ privateConnections.addAll(connections);
}
@@ -207,7 +226,7 @@ public abstract class AbstractService implements Service {
if ( declaredConnections == null ) {
declaredConnections = new LinkedHashSet<String>();
}
- declaredConnections.add( connection );
+ declaredConnections.add(connection);
}
@@ -215,7 +234,7 @@ public abstract class AbstractService implements Service {
if ( declaredConnections == null ) {
declaredConnections = new LinkedHashSet<String>();
}
- declaredConnections.addAll( connections );
+ declaredConnections.addAll(connections);
}
@@ -223,7 +242,7 @@ public abstract class AbstractService implements Service {
if ( privateCollections == null ) {
privateCollections = new LinkedHashSet<String>();
}
- privateCollections.add( collection );
+ privateCollections.add(collection);
}
@@ -231,7 +250,7 @@ public abstract class AbstractService implements Service {
if ( privateCollections == null ) {
privateCollections = new LinkedHashSet<String>();
}
- privateCollections.addAll( collections );
+ privateCollections.addAll(collections);
}
@@ -239,7 +258,7 @@ public abstract class AbstractService implements Service {
if ( declaredCollections == null ) {
declaredCollections = new LinkedHashSet<String>();
}
- declaredCollections.add( collection );
+ declaredCollections.add(collection);
}
@@ -247,7 +266,7 @@ public abstract class AbstractService implements Service {
if ( declaredCollections == null ) {
declaredCollections = new LinkedHashSet<String>();
}
- declaredCollections.addAll( collections );
+ declaredCollections.addAll(collections);
}
@@ -255,7 +274,7 @@ public abstract class AbstractService implements Service {
if ( replaceParameters == null ) {
replaceParameters = new LinkedHashMap<List<String>, List<String>>();
}
- replaceParameters.put( find, replace );
+ replaceParameters.put(find, replace);
}
@@ -263,7 +282,7 @@ public abstract class AbstractService implements Service {
if ( serviceCommands == null ) {
serviceCommands = new LinkedHashSet<String>();
}
- serviceCommands.add( command );
+ serviceCommands.add(command);
}
@@ -271,7 +290,7 @@ public abstract class AbstractService implements Service {
if ( serviceCommands == null ) {
serviceCommands = new LinkedHashSet<String>();
}
- serviceCommands.addAll( commands );
+ serviceCommands.addAll(commands);
}
@@ -279,7 +298,7 @@ public abstract class AbstractService implements Service {
if ( entityDictionaries == null ) {
entityDictionaries = new LinkedHashSet<EntityDictionaryEntry>();
}
- entityDictionaries.add( dictionary );
+ entityDictionaries.add(dictionary);
}
@@ -305,7 +324,7 @@ public abstract class AbstractService implements Service {
if ( metadataTypes == null ) {
metadataTypes = new LinkedHashSet<String>();
}
- metadataTypes.add( type );
+ metadataTypes.add(type);
}
@@ -313,7 +332,7 @@ public abstract class AbstractService implements Service {
if ( metadataTypes == null ) {
metadataTypes = new LinkedHashSet<String>();
}
- metadataTypes.addAll( typeList );
+ metadataTypes.addAll(typeList);
}
@@ -321,7 +340,7 @@ public abstract class AbstractService implements Service {
if ( entityCommands == null ) {
entityCommands = new LinkedHashSet<String>();
}
- entityCommands.add( command );
+ entityCommands.add(command);
}
@@ -329,7 +348,7 @@ public abstract class AbstractService implements Service {
if ( entityCommands == null ) {
entityCommands = new LinkedHashSet<String>();
}
- entityCommands.addAll( commands );
+ entityCommands.addAll(commands);
}
@@ -354,69 +373,79 @@ public abstract class AbstractService implements Service {
@Override
public Entity importEntity( ServiceRequest request, Entity entity ) throws Exception {
- if ( entity == null ) {
- return null;
- }
+ Timer.Context getEntityTimer = entityGetTimer.time();
+ try {
+ if (entity == null) {
+ return null;
+ }
- if ( !isRootService() ) {
- return sm.importEntity( request, entity );
- }
+ if (!isRootService()) {
+ return sm.importEntity(request, entity);
+ }
- String path = request.getPath() + "/" + entity.getUuid();
- Map<String, Object> metadata = new LinkedHashMap<String, Object>();
- metadata.put( "path", path );
- if ( defaultEntityMetadata != null ) {
- metadata.putAll( defaultEntityMetadata );
- }
+ String path = request.getPath() + "/" + entity.getUuid();
+ Map<String, Object> metadata = new LinkedHashMap<String, Object>();
+ metadata.put("path", path);
- Set<Object> connections = getConnectedTypesSet( entity );
- if ( connections != null ) {
- Map<String, Object> m = new LinkedHashMap<String, Object>();
- for ( Object n : connections ) {
- m.put( n.toString(), path + "/" + n );
+ if (defaultEntityMetadata != null) {
+ metadata.putAll(defaultEntityMetadata);
}
- metadata.put( "connections", m );
- }
- Set<Object> connecting = getConnectingTypesSet( entity );
- if ( connecting != null ) {
- Map<String, Object> m = new LinkedHashMap<String, Object>();
- for ( Object n : connecting ) {
- m.put( n.toString(), path + "/connecting/" + n );
+ Set<Object> connections = getConnectedTypesSet(entity);
+ if (connections != null) {
+ Map<String, Object> m = new LinkedHashMap<String, Object>();
+ for (Object n : connections) {
+ m.put(n.toString(), path + "/" + n);
+ }
+ metadata.put("connections", m);
}
- metadata.put( "connecting", m );
- }
- Set<String> collections = getCollectionSet( entity );
- if ( collections != null ) {
- Map<String, Object> m = new LinkedHashMap<String, Object>();
- for ( Object n : collections ) {
- m.put( n.toString(), path + "/" + n );
+ Set<Object> connecting = getConnectingTypesSet(entity);
+ if (connecting != null) {
+ Map<String, Object> m = new LinkedHashMap<String, Object>();
+ for (Object n : connecting) {
+ m.put(n.toString(), path + "/connecting/" + n);
+ }
+ metadata.put("connecting", m);
}
- metadata.put( "collections", m );
- }
- if ( entityDictionaries != null ) {
- Map<String, Object> m = new LinkedHashMap<String, Object>();
- for ( EntityDictionaryEntry dict : entityDictionaries ) {
- m.put( dict.getName(), path + "/" + dict.getPath() );
+ Set<String> collections = getCollectionSet(entity);
+ if (collections != null) {
+ Map<String, Object> m = new LinkedHashMap<String, Object>();
+ for (Object n : collections) {
+ m.put(n.toString(), path + "/" + n);
+ }
+ metadata.put("collections", m);
+ }
+
+ if (entityDictionaries != null) {
+ Map<String, Object> m = new LinkedHashMap<String, Object>();
+ for (EntityDictionaryEntry dict : entityDictionaries) {
+ m.put(dict.getName(), path + "/" + dict.getPath());
+ }
+ metadata.put("sets", m);
}
- metadata.put( "sets", m );
- }
- if ( metadata.size() > 0 ) {
- entity.mergeMetadata( metadata );
+ if (metadata.size() > 0) {
+ entity.mergeMetadata(metadata);
+ }
+ return entity;
+ }finally {
+ getEntityTimer.stop();
}
- return entity;
}
public void importEntities( ServiceRequest request, Results results ) throws Exception {
-
- List<Entity> entities = results.getEntities();
- if ( entities != null ) {
- importEntitiesParallel(request, results);
+ Timer.Context timer = entitiesGetTimer.time();
+ try {
+ List<Entity> entities = results.getEntities();
+ if (entities != null) {
+ importEntitiesParallel(request, results);
+ }
+ }finally {
+ timer.stop();
}
}
@@ -427,42 +456,45 @@ public abstract class AbstractService implements Service {
* @param results
*/
private void importEntitiesParallel(final ServiceRequest request, final Results results ) {
+ Timer.Context timer = entitiesParallelGetTimer.time();
+ try {
+ //create our tuples
+ final Observable<EntityTuple> tuples = Observable.create(new Observable.OnSubscribe<EntityTuple>() {
+ @Override
+ public void call(final Subscriber<? super EntityTuple> subscriber) {
+ subscriber.onStart();
+
+ final List<Entity> entities = results.getEntities();
+ final int size = entities.size();
+ for (int i = 0; i < size && !subscriber.isUnsubscribed(); i++) {
+ subscriber.onNext(new EntityTuple(i, entities.get(i)));
+ }
- //create our tuples
- final Observable<EntityTuple> tuples = Observable.create( new Observable.OnSubscribe<EntityTuple>() {
- @Override
- public void call( final Subscriber<? super EntityTuple> subscriber ) {
- subscriber.onStart();
-
- final List<Entity> entities = results.getEntities();
- final int size = entities.size();
- for ( int i = 0; i < size && !subscriber.isUnsubscribed(); i++ ) {
- subscriber.onNext( new EntityTuple( i, entities.get( i ) ) );
+ subscriber.onCompleted();
}
+ });
- subscriber.onCompleted();
- }
- } );
-
- //now process them in parallel up to 10 threads
+ //now process them in parallel up to 10 threads
- tuples.flatMap( tuple -> {
- //map the entity into the tuple
- return Observable.just( tuple ).doOnNext( parallelTuple -> {
- //import the entity and set it at index
- try {
+ tuples.flatMap(tuple -> {
+ //map the entity into the tuple
+ return Observable.just(tuple).doOnNext(parallelTuple -> {
+ //import the entity and set it at index
+ try {
- final Entity imported = importEntity( request, parallelTuple.entity );
+ final Entity imported = importEntity(request, parallelTuple.entity);
- if(imported != null) {
- results.setEntity( parallelTuple.index, imported );
+ if (imported != null) {
+ results.setEntity(parallelTuple.index, imported);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
- }
- catch ( Exception e ) {
- throw new RuntimeException(e);
- }
- } ).subscribeOn( rxScheduler );
- }, rxSchedulerFig.getImportThreads() ).toBlocking().lastOrDefault( null );
+ }).subscribeOn(rxScheduler);
+ }, rxSchedulerFig.getImportThreads()).toBlocking().lastOrDefault(null);
+ } finally {
+ timer.stop();
+ }
}
@@ -528,7 +560,7 @@ public abstract class AbstractService implements Service {
entity.addProperties( payload.getProperties() );
return entity;
}
- logger.error( "Attempted update of entity reference rather than full entity, currently unsupport - MUSTFIX" );
+ logger.error("Attempted update of entity reference rather than full entity, currently unsupport - MUSTFIX");
throw new NotImplementedException();
}
@@ -555,7 +587,7 @@ public abstract class AbstractService implements Service {
public Set<Object> getConnectedTypesSet( EntityRef ref ) throws Exception {
- final Set<String> connections = em.getConnectionsAsSource( ref );
+ final Set<String> connections = em.getConnectionsAsSource(ref);
if ( connections == null ) {
return null;
@@ -574,7 +606,7 @@ public abstract class AbstractService implements Service {
public Set<Object> getConnectingTypesSet( EntityRef ref ) throws Exception {
- final Set<String> connections = em.getConnectionsAsTarget( ref );
+ final Set<String> connections = em.getConnectionsAsTarget(ref);
if ( connections == null ) {
return null;
@@ -593,7 +625,7 @@ public abstract class AbstractService implements Service {
public Set<String> getCollectionSet( EntityRef ref ) {
- Set<String> set = Schema.getDefaultSchema().getCollectionNames( ref.getType() );
+ Set<String> set = Schema.getDefaultSchema().getCollectionNames(ref.getType());
set = new LinkedHashSet<String>( set );
if ( declaredCollections != null ) {
set.addAll( declaredCollections );
@@ -612,7 +644,7 @@ public abstract class AbstractService implements Service {
public ServiceResults invoke( ServiceAction action, ServiceRequest request, ServiceResults previousResults,
ServicePayload payload ) throws Exception {
- ServiceContext context = getContext( action, request, previousResults, payload );
+ ServiceContext context = getContext(action, request, previousResults, payload);
return invoke( context );
}
@@ -629,7 +661,7 @@ public abstract class AbstractService implements Service {
EntityRef owner = request.getOwner();
String collectionName =
"application".equals( owner.getType() ) ? pluralize( info.getItemType() ) : info.getCollectionName();
- List<ServiceParameter> parameters = filter( request.getParameters(), replaceParameters );
+ List<ServiceParameter> parameters = filter(request.getParameters(), replaceParameters);
ServiceParameter first_parameter = null;
if ( !isEmpty( parameters ) ) {
@@ -652,7 +684,7 @@ public abstract class AbstractService implements Service {
if ( first_parameter instanceof QueryParameter ) {
query = first_parameter.getQuery();
}
- parameters = mergeQueries( query, parameters );
+ parameters = mergeQueries(query, parameters);
if ( first_parameter instanceof IdParameter ) {
UUID id = first_parameter.getId();
@@ -718,19 +750,19 @@ public abstract class AbstractService implements Service {
switch ( context.getAction() ) {
case GET:
- return getItemById( context, id );
+ return getItemById(context, id);
case POST:
- return postItemById( context, id );
+ return postItemById(context, id);
case PUT:
- return putItemById( context, id );
+ return putItemById(context, id);
case DELETE:
- return deleteItemById( context, id );
+ return deleteItemById(context, id);
case HEAD:
- return headItemById( context, id );
+ return headItemById(context, id);
}
throw new ServiceInvocationException( context, "Request action unhandled " + context.getAction() );
@@ -739,21 +771,43 @@ public abstract class AbstractService implements Service {
public ServiceResults invokeItemWithName( ServiceContext context, String name ) throws Exception {
+ Timer.Context time;
switch ( context.getAction() ) {
case GET:
- return getItemByName( context, name );
-
+ time = getByNameTimer.time();
+ try {
+ return getItemByName(context, name);
+ } finally {
+ time.stop();
+ }
case POST:
- return postItemByName( context, name );
-
+ time = postByNameTimer.time();
+ try {
+ return postItemByName(context, name);
+ } finally {
+ time.stop();
+ }
case PUT:
- return putItemByName( context, name );
-
+ time = putByNameTimer.time();
+ try {
+ return putItemByName(context, name);
+ } finally {
+ time.stop();
+ }
case DELETE:
- return deleteItemByName( context, name );
-
+ time = deleteByNameTimer.time();
+ try {
+ return deleteItemByName(context, name);
+ } finally {
+ time.stop();
+ }
case HEAD:
- return headItemByName( context, name );
+ time = headByNameTimer.time();
+ try {
+ return headItemByName(context, name);
+ } finally {
+ time.stop();
+ }
}
throw new ServiceInvocationException( context, "Request action unhandled " + context.getAction() );
[3/3] incubator-usergrid git commit: Merge branch 'two-dot-o-dev' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-dev
Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ca4575d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ca4575d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ca4575d6
Branch: refs/heads/two-dot-o-dev
Commit: ca4575d6d2b6605a838e7899eea503ea889c57b8
Parents: 11f8049 d32cee4
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jul 22 08:37:39 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jul 22 08:37:39 2015 -0600
----------------------------------------------------------------------
CHANGELOG | 3 -
LICENSE | 10 +
stack/LICENSE-2.0.txt | 202 -------------------
.../applications/assets/AssetResourceIT.java | 2 +-
.../src/test/resources/cat-larger-than-6mb.jpg | Bin 9799257 -> 0 bytes
.../src/test/resources/ship-larger-than-6mb.gif | Bin 0 -> 7407487 bytes
.../org/apache/usergrid/tools/AppAudit.java | 30 +--
.../java/org/apache/usergrid/tools/Cli.java | 6 +-
.../apache/usergrid/tools/DupAdminRepair.java | 34 +---
.../org/apache/usergrid/tools/DupOrgRepair.java | 36 ++--
.../apache/usergrid/tools/EntityCleanup.java | 178 ----------------
.../org/apache/usergrid/tools/EntityUpdate.java | 25 +--
.../org/apache/usergrid/tools/ExportAdmins.java | 73 +++----
.../org/apache/usergrid/tools/ImportAdmins.java | 60 ++++--
.../org/apache/usergrid/tools/ToolBase.java | 6 +-
.../org/apache/usergrid/tools/UserManager.java | 22 ++
stack/tools/src/main/resources/log4j.properties | 1 +
17 files changed, 152 insertions(+), 536 deletions(-)
----------------------------------------------------------------------
[2/3] incubator-usergrid git commit: add invoke timer
Posted by sf...@apache.org.
add invoke timer
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/11f8049b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/11f8049b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/11f8049b
Branch: refs/heads/two-dot-o-dev
Commit: 11f8049b660dc452a9ca9cec29a4d1bdc72d30b0
Parents: 75d59e7
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jul 22 08:37:27 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jul 22 08:37:27 2015 -0600
----------------------------------------------------------------------
.../usergrid/services/AbstractService.java | 62 ++++----------------
1 file changed, 13 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/11f8049b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index 660545e..1c04da9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -28,7 +28,6 @@ import java.util.UUID;
import com.codahale.metrics.Timer;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
-import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
@@ -105,11 +104,7 @@ public abstract class AbstractService implements Service {
private Timer entityGetTimer;
private Timer entitiesGetTimer;
private Timer entitiesParallelGetTimer;
- private Timer deleteByNameTimer;
- private Timer postByNameTimer;
- private Timer putByNameTimer;
- private Timer getByNameTimer;
- private Timer headByNameTimer;
+ private Timer invokeTimer;
public AbstractService() {
@@ -127,11 +122,7 @@ public abstract class AbstractService implements Service {
this.entityGetTimer = metricsFactory.getTimer(this.getClass(), "importEntity.get");
this.entitiesGetTimer = metricsFactory.getTimer(this.getClass(), "importEntities.get");
this.entitiesParallelGetTimer = metricsFactory.getTimer( this.getClass(),"importEntitiesP.get" );
- this.getByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.get" );
- this.putByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.put" );
- this.postByNameTimer = metricsFactory.getTimer( this.getClass(),"byname.post" );
- this.deleteByNameTimer = metricsFactory.getTimer(this.getClass(), "byname.delete");
- this.headByNameTimer = metricsFactory.getTimer(this.getClass(), "byname.head");
+ this.invokeTimer = metricsFactory.getTimer( this.getClass(),"service.invoke" );
}
@@ -710,9 +701,8 @@ public abstract class AbstractService implements Service {
public ServiceResults invoke( ServiceContext context ) throws Exception {
-
ServiceResults results = null;
-
+ Timer.Context time = invokeTimer.time();
String metadataType = checkForServiceMetadata( context );
if ( metadataType != null ) {
return handleServiceMetadata( context, metadataType );
@@ -740,8 +730,9 @@ public abstract class AbstractService implements Service {
}
results = handleEntityDictionary( context, results, entityDictionary );
- results = handleEntityCommand( context, results, entityCommand );
+ results = handleEntityCommand(context, results, entityCommand);
+ time.stop();
return results;
}
@@ -770,47 +761,20 @@ public abstract class AbstractService implements Service {
public ServiceResults invokeItemWithName( ServiceContext context, String name ) throws Exception {
-
- Timer.Context time;
- switch ( context.getAction() ) {
+ switch (context.getAction()) {
case GET:
- time = getByNameTimer.time();
- try {
- return getItemByName(context, name);
- } finally {
- time.stop();
- }
+ return getItemByName(context, name);
case POST:
- time = postByNameTimer.time();
- try {
- return postItemByName(context, name);
- } finally {
- time.stop();
- }
+ return postItemByName(context, name);
case PUT:
- time = putByNameTimer.time();
- try {
- return putItemByName(context, name);
- } finally {
- time.stop();
- }
+ return putItemByName(context, name);
case DELETE:
- time = deleteByNameTimer.time();
- try {
- return deleteItemByName(context, name);
- } finally {
- time.stop();
- }
+ return deleteItemByName(context, name);
case HEAD:
- time = headByNameTimer.time();
- try {
- return headItemByName(context, name);
- } finally {
- time.stop();
- }
+ return headItemByName(context, name);
+ default:
+ throw new ServiceInvocationException(context, "Request action unhandled " + context.getAction());
}
-
- throw new ServiceInvocationException( context, "Request action unhandled " + context.getAction() );
}