mirror of https://github.com/apache/druid.git
add cache errorCount
This commit is contained in:
parent
2837309075
commit
1b51848a89
|
@ -67,5 +67,6 @@ public class CacheMonitor extends AbstractMonitor
|
||||||
emitter.emit(builder.build(String.format("%s/hitRate", metricPrefix), cacheStats.hitRate()));
|
emitter.emit(builder.build(String.format("%s/hitRate", metricPrefix), cacheStats.hitRate()));
|
||||||
emitter.emit(builder.build(String.format("%s/averageBytes", metricPrefix), cacheStats.averageBytes()));
|
emitter.emit(builder.build(String.format("%s/averageBytes", metricPrefix), cacheStats.averageBytes()));
|
||||||
emitter.emit(builder.build(String.format("%s/timeouts", metricPrefix), cacheStats.getNumTimeouts()));
|
emitter.emit(builder.build(String.format("%s/timeouts", metricPrefix), cacheStats.getNumTimeouts()));
|
||||||
|
emitter.emit(builder.build(String.format("%s/errors", metricPrefix), cacheStats.getNumErrors()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class CacheStats
|
||||||
private final long sizeInBytes;
|
private final long sizeInBytes;
|
||||||
private final long numEvictions;
|
private final long numEvictions;
|
||||||
private final long numTimeouts;
|
private final long numTimeouts;
|
||||||
|
private final long numErrors;
|
||||||
|
|
||||||
public CacheStats(
|
public CacheStats(
|
||||||
long numHits,
|
long numHits,
|
||||||
|
@ -36,7 +37,8 @@ public class CacheStats
|
||||||
long size,
|
long size,
|
||||||
long sizeInBytes,
|
long sizeInBytes,
|
||||||
long numEvictions,
|
long numEvictions,
|
||||||
long numTimeouts
|
long numTimeouts,
|
||||||
|
long numErrors
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.numHits = numHits;
|
this.numHits = numHits;
|
||||||
|
@ -45,6 +47,7 @@ public class CacheStats
|
||||||
this.sizeInBytes = sizeInBytes;
|
this.sizeInBytes = sizeInBytes;
|
||||||
this.numEvictions = numEvictions;
|
this.numEvictions = numEvictions;
|
||||||
this.numTimeouts = numTimeouts;
|
this.numTimeouts = numTimeouts;
|
||||||
|
this.numErrors = numErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getNumHits()
|
public long getNumHits()
|
||||||
|
@ -77,6 +80,11 @@ public class CacheStats
|
||||||
return numTimeouts;
|
return numTimeouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getNumErrors()
|
||||||
|
{
|
||||||
|
return numErrors;
|
||||||
|
}
|
||||||
|
|
||||||
public long numLookups()
|
public long numLookups()
|
||||||
{
|
{
|
||||||
return numHits + numMisses;
|
return numHits + numMisses;
|
||||||
|
@ -104,7 +112,8 @@ public class CacheStats
|
||||||
size - oldStats.size,
|
size - oldStats.size,
|
||||||
sizeInBytes - oldStats.sizeInBytes,
|
sizeInBytes - oldStats.sizeInBytes,
|
||||||
numEvictions - oldStats.numEvictions,
|
numEvictions - oldStats.numEvictions,
|
||||||
numTimeouts - oldStats.numTimeouts
|
numTimeouts - oldStats.numTimeouts,
|
||||||
|
numErrors - oldStats.numErrors
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class MapCache implements Cache
|
||||||
byteCountingLRUMap.size(),
|
byteCountingLRUMap.size(),
|
||||||
byteCountingLRUMap.getNumBytes(),
|
byteCountingLRUMap.getNumBytes(),
|
||||||
byteCountingLRUMap.getEvictionCount(),
|
byteCountingLRUMap.getEvictionCount(),
|
||||||
|
0,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class MemcachedCache implements Cache
|
||||||
private final AtomicLong hitCount = new AtomicLong(0);
|
private final AtomicLong hitCount = new AtomicLong(0);
|
||||||
private final AtomicLong missCount = new AtomicLong(0);
|
private final AtomicLong missCount = new AtomicLong(0);
|
||||||
private final AtomicLong timeoutCount = new AtomicLong(0);
|
private final AtomicLong timeoutCount = new AtomicLong(0);
|
||||||
|
private final AtomicLong errorCount = new AtomicLong(0);
|
||||||
|
|
||||||
MemcachedCache(MemcachedClientIF client, String memcachedPrefix, int timeout, int expiration) {
|
MemcachedCache(MemcachedClientIF client, String memcachedPrefix, int timeout, int expiration) {
|
||||||
Preconditions.checkArgument(memcachedPrefix.length() <= MAX_PREFIX_LENGTH,
|
Preconditions.checkArgument(memcachedPrefix.length() <= MAX_PREFIX_LENGTH,
|
||||||
|
@ -112,7 +113,8 @@ public class MemcachedCache implements Cache
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
timeoutCount.get()
|
timeoutCount.get(),
|
||||||
|
errorCount.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +126,7 @@ public class MemcachedCache implements Cache
|
||||||
future = client.asyncGet(computeKeyHash(memcachedPrefix, key));
|
future = client.asyncGet(computeKeyHash(memcachedPrefix, key));
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
// operation did not get queued in time (queue is full)
|
// operation did not get queued in time (queue is full)
|
||||||
|
errorCount.incrementAndGet();
|
||||||
log.warn(e, "Unable to queue cache operation");
|
log.warn(e, "Unable to queue cache operation");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +150,7 @@ public class MemcachedCache implements Cache
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
catch(ExecutionException e) {
|
catch(ExecutionException e) {
|
||||||
|
errorCount.incrementAndGet();
|
||||||
log.warn(e, "Exception pulling item from cache");
|
log.warn(e, "Exception pulling item from cache");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +163,7 @@ public class MemcachedCache implements Cache
|
||||||
client.set(computeKeyHash(memcachedPrefix, key), expiration, serializeValue(key, value));
|
client.set(computeKeyHash(memcachedPrefix, key), expiration, serializeValue(key, value));
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
// operation did not get queued in time (queue is full)
|
// operation did not get queued in time (queue is full)
|
||||||
|
errorCount.incrementAndGet();
|
||||||
log.warn(e, "Unable to queue cache operation");
|
log.warn(e, "Unable to queue cache operation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,8 +214,8 @@ public class MemcachedCache implements Cache
|
||||||
try {
|
try {
|
||||||
future = client.asyncGetBulk(keyLookup.keySet());
|
future = client.asyncGetBulk(keyLookup.keySet());
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
timeoutCount.incrementAndGet();
|
|
||||||
// operation did not get queued in time (queue is full)
|
// operation did not get queued in time (queue is full)
|
||||||
|
errorCount.incrementAndGet();
|
||||||
log.warn(e, "Unable to queue cache operation");
|
log.warn(e, "Unable to queue cache operation");
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -241,6 +246,7 @@ public class MemcachedCache implements Cache
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
catch(ExecutionException e) {
|
catch(ExecutionException e) {
|
||||||
|
errorCount.incrementAndGet();
|
||||||
log.warn(e, "Exception pulling item from cache");
|
log.warn(e, "Exception pulling item from cache");
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue