Java Code Examples for net.sf.ehcache.Element#getObjectKey()

The following examples show how to use net.sf.ehcache.Element#getObjectKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalMetricsCache.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyElementEvicted(Ehcache cache, Element element) {
  // Bad - Remote endpoint cannot keep up resulting in flooding
  InternalMetricCacheKey key = (InternalMetricCacheKey) element.getObjectKey();
  LOG.warn("Evicting element from internal metrics cache, metric => " + key
    .getMetricName() + ", startTime = " + new Date(key.getStartTime()));
}
 
Example 2
Source File: EhcacheOperateElementInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    EhcacheEnhanceInfo enhanceInfo = (EhcacheEnhanceInfo) objInst.getSkyWalkingDynamicField();

    AbstractSpan span = ContextManager.createLocalSpan("Ehcache/" + method.getName() + "/" + enhanceInfo.getCacheName());
    span.setComponent(ComponentsDefine.EHCACHE);
    SpanLayer.asCache(span);

    Element element = (Element) allArguments[0];
    if (element != null && element.getObjectKey() != null) {
        Tags.DB_STATEMENT.set(span, element.getObjectKey().toString());
    }
}