Skip to content

Commit

Permalink
util: minor change for Profiling use
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrossie committed Nov 10, 2015
1 parent 97bfd3d commit e57a1e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Expand Up @@ -175,7 +175,7 @@ private class WithCaching<TypeIn, TypeOut> {

private TypeOut withCaching(final OperationRetrieval<TypeIn, TypeOut> op, @Nullable final TypeIn objectOrRecordId, final ObjectType objectType, final TableName tableName, @Nullable final CacheController<Object, Object> cache) {

final Profiling<TypeOut> prof = new Profiling<TypeOut>();
final Profiling<TypeOut, RuntimeException> prof = new Profiling<TypeOut, RuntimeException>();
if (objectOrRecordId == null) {
return null;
}
Expand All @@ -186,18 +186,13 @@ private TypeOut withCaching(final OperationRetrieval<TypeIn, TypeOut> op, @Nulla
return (TypeOut) cache.get(key, new CacheLoaderArgument(objectType));
}
final TypeOut result;
try {
result = prof.executeWithProfiling(ProfilingFeatureType.DAO_DETAILS, "NonEntityDao (type = " + objectType + ") cache miss", new WithProfilingCallback<TypeOut>() {
@Override
public <ExceptionType extends Throwable> TypeOut execute() throws ExceptionType {
return op.doRetrieve(objectOrRecordId, objectType);
}
});
return result;
} catch (final Throwable throwable) {
// This is only because WithProfilingCallback throws a Throwable...
throw new RuntimeException(throwable);
}
result = prof.executeWithProfiling(ProfilingFeatureType.DAO_DETAILS, "NonEntityDao (type = " + objectType + ") cache miss", new WithProfilingCallback<TypeOut, RuntimeException>() {
@Override
public TypeOut execute() throws RuntimeException {
return op.doRetrieve(objectOrRecordId, objectType);
}
});
return result;
}
}
}
Expand Up @@ -104,7 +104,7 @@ public EntitySqlDaoWrapperInvocationHandler(final Class<S> sqlDaoClass,
this.clock = clock;
this.cacheControllerDispatcher = cacheControllerDispatcher;
this.nonEntityDao = nonEntityDao;
this.prof = new Profiling<Object>();
this.prof = new Profiling<Object, Throwable>();
}

@Override
Expand Down
Expand Up @@ -42,7 +42,7 @@ protected void configure() {

public static class ProfilingMethodInterceptor implements MethodInterceptor {

private final Profiling prof = new Profiling<Object>();
private final Profiling prof = new Profiling<Object, Throwable>();

@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
Expand Down

1 comment on commit e57a1e4

@pierre
Copy link
Member

@pierre pierre commented on e57a1e4 Nov 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.