Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

(a) Change the name of the metrics

(b) Write count is bumped up after sucessful writes
(c) Make metrics non static.
commit 381dd9db0841fb7ed8b9d4f92984025ac80d2903 1 parent d3a4e6a
Siddharth Taneja authored
Showing with 12 additions and 15 deletions.
  1. +12 −15 src/jvm/trident/memcached/MemcachedState.java
View
27 src/jvm/trident/memcached/MemcachedState.java
@@ -118,23 +118,13 @@ public Factory(List<InetSocketAddress> servers, StateType type, Options options)
@Override
public State makeState(Map conf, IMetricsContext context, int partitionIndex, int numPartitions) {
- int bucketSize = (int)(conf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS));
- _mreads =
- context.registerMetric("memcached/reads", new CountMetric(),
- bucketSize);
- _mwrites =
- context.registerMetric("memcached/writes", new CountMetric(),
- bucketSize);
- _mexceptions =
- context.registerMetric("memcached/exceptions",
- new CountMetric(), bucketSize);
-
MemcachedState s;
try {
s = new MemcachedState(makeMemcachedClient(_opts, _servers), _opts, _ser);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
+ s.registerMetrics(conf, context);
CachedMap c = new CachedMap(s, _opts.localCacheSize);
MapState ms;
if(_type == StateType.NON_TRANSACTIONAL) {
@@ -195,9 +185,9 @@ static String getHostPortWeightTuples(List<InetSocketAddress> endpoints) throws
private final Client _client;
private Options _opts;
private Serializer _ser;
- static CountMetric _mreads;
- static CountMetric _mwrites;
- static CountMetric _mexceptions;
+ CountMetric _mreads;
+ CountMetric _mwrites;
+ CountMetric _mexceptions;
public MemcachedState(Client client, Options opts, Serializer<T> ser) {
_client = client;
@@ -252,10 +242,10 @@ public void multiPut(List<List<Object>> keys, List<T> vals) {
futures.add(_client.set(key, 0 /* no flags */, expiry, entry));
}
- _mwrites.incrBy(futures.size());
for(Future future: futures) {
future.get();
}
+ _mwrites.incrBy(futures.size());
} catch(Exception e) {
checkMemcachedException(e);
}
@@ -277,6 +267,13 @@ private void checkMemcachedException(Exception e) {
}
}
+ private void registerMetrics(Map conf, IMetricsContext context) {
+ int bucketSize = (int)(conf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS));
+ _mreads = context.registerMetric("memcached/readCount", new CountMetric(), bucketSize);
+ _mwrites = context.registerMetric("memcached/writeCount", new CountMetric(), bucketSize);
+ _mexceptions = context.registerMetric("memcached/exceptionCount", new CountMetric(), bucketSize);
+ }
+
private String toSingleKey(List<Object> key) {
if(key.size()!=1) {
throw new RuntimeException("Memcached state does not support compound keys");
Please sign in to comment.
Something went wrong with that request. Please try again.