diff --git a/util/src/main/java/org/killbill/billing/util/dao/DefaultNonEntityDao.java b/util/src/main/java/org/killbill/billing/util/dao/DefaultNonEntityDao.java
index 785ef8b..d5783c9 100644
--- a/util/src/main/java/org/killbill/billing/util/dao/DefaultNonEntityDao.java
+++ b/util/src/main/java/org/killbill/billing/util/dao/DefaultNonEntityDao.java
@@ -21,6 +21,9 @@ import java.util.UUID;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import org.killbill.commons.profiling.Profiling;
+import org.killbill.commons.profiling.Profiling.WithProfilingCallback;
+import org.killbill.commons.profiling.ProfilingFeature.ProfilingFeatureType;
import org.skife.jdbi.v2.IDBI;
import org.killbill.billing.ObjectType;
@@ -31,12 +34,13 @@ public class DefaultNonEntityDao implements NonEntityDao {
private final NonEntitySqlDao nonEntitySqlDao;
private final WithCaching containedCall;
-
+ private final Profiling<Long> prof;
@Inject
public DefaultNonEntityDao(final IDBI dbi) {
this.nonEntitySqlDao = dbi.onDemand(NonEntitySqlDao.class);
this.containedCall = new WithCaching();
+ this.prof = new Profiling<Long>();
}
@@ -124,7 +128,19 @@ public class DefaultNonEntityDao implements NonEntityDao {
if (cache != null) {
return (Long) cache.get(objectId.toString(), new CacheLoaderArgument(objectType));
}
- return op.doRetrieve(objectId, objectType);
+ final Long result;
+ try {
+ result = prof.executeWithProfiling(ProfilingFeatureType.DAO_DETAILS, "NonEntityDao (type = " + objectType + ") cache miss", new WithProfilingCallback() {
+ @Override
+ public Long execute() throws Throwable {
+ return op.doRetrieve(objectId, objectType);
+ }
+ });
+ return result;
+ } catch (Throwable throwable) {
+ // This is only because WithProfilingCallback throws a Throwable...
+ throw new RuntimeException(throwable);
+ }
}
}
}
diff --git a/util/src/main/java/org/killbill/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java b/util/src/main/java/org/killbill/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
index 7033462..4f5e778 100644
--- a/util/src/main/java/org/killbill/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
+++ b/util/src/main/java/org/killbill/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
@@ -196,38 +196,31 @@ public class EntitySqlDaoWrapperInvocationHandler<S extends EntitySqlDao<M, E>,
final CacheController<Object, Object> cache = cacheControllerDispatcher.getCacheController(cacheType);
Object result = null;
if (cache != null) {
-
- result = prof.executeWithProfiling(ProfilingFeatureType.DAO_DETAILS, sqlDaoClass.getSimpleName() + "(caching) :" + method.getName(), new WithProfilingCallback() {
- @Override
- public Object execute() throws Throwable {
-
- // Find all arguments marked with @CachableKey
- final Map<Integer, Object> keyPieces = new LinkedHashMap<Integer, Object>();
- final Annotation[][] annotations = method.getParameterAnnotations();
- for (int i = 0; i < annotations.length; i++) {
- for (int j = 0; j < annotations[i].length; j++) {
- final Annotation annotation = annotations[i][j];
- if (CachableKey.class.equals(annotation.annotationType())) {
- // CachableKey position starts at 1
- keyPieces.put(((CachableKey) annotation).value() - 1, args[i]);
- break;
- }
- }
+ // Find all arguments marked with @CachableKey
+ final Map<Integer, Object> keyPieces = new LinkedHashMap<Integer, Object>();
+ final Annotation[][] annotations = method.getParameterAnnotations();
+ for (int i = 0; i < annotations.length; i++) {
+ for (int j = 0; j < annotations[i].length; j++) {
+ final Annotation annotation = annotations[i][j];
+ if (CachableKey.class.equals(annotation.annotationType())) {
+ // CachableKey position starts at 1
+ keyPieces.put(((CachableKey) annotation).value() - 1, args[i]);
+ break;
}
+ }
+ }
- // Build the Cache key
- final String cacheKey = buildCacheKey(keyPieces);
+ // Build the Cache key
+ final String cacheKey = buildCacheKey(keyPieces);
- final InternalTenantContext internalTenantContext = (InternalTenantContext) Iterables.find(ImmutableList.copyOf(args), new Predicate<Object>() {
- @Override
- public boolean apply(final Object input) {
- return input instanceof InternalTenantContext;
- }
- }, null);
- final CacheLoaderArgument cacheLoaderArgument = new CacheLoaderArgument(objectType, args, internalTenantContext);
- return cache.get(cacheKey, cacheLoaderArgument);
+ final InternalTenantContext internalTenantContext = (InternalTenantContext) Iterables.find(ImmutableList.copyOf(args), new Predicate<Object>() {
+ @Override
+ public boolean apply(final Object input) {
+ return input instanceof InternalTenantContext;
}
- });
+ }, null);
+ final CacheLoaderArgument cacheLoaderArgument = new CacheLoaderArgument(objectType, args, internalTenantContext);
+ return cache.get(cacheKey, cacheLoaderArgument);
}
if (result == null) {
result = prof.executeWithProfiling(ProfilingFeatureType.DAO_DETAILS, sqlDaoClass.getSimpleName() + "(raw) :" + method.getName(), new WithProfilingCallback() {