Align behaviour of in-memory and redis mult repos

The in-memory version has to force the incoming metric keys to
start with the group name. Redis doesn't have that restriction
but normally we expect both to be used in such a way that
the metric keys already match the prefix. In that case the two
repositories behave the same now in terms of set and get.
pull/931/merge
Dave Syer 11 years ago
parent 0dca2dd978
commit 1fabfaa259

@ -144,12 +144,8 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
} }
private Metric<?> deserialize(String group, String redisKey, String v, Double value) { private Metric<?> deserialize(String group, String redisKey, String v, Double value) {
String prefix = group;
if (!group.endsWith(".")) {
prefix = group + ".";
}
Date timestamp = new Date(Long.valueOf(v)); Date timestamp = new Date(Long.valueOf(v));
return new Metric<Double>(prefix + nameFor(redisKey), value, timestamp); return new Metric<Double>(nameFor(redisKey), value, timestamp);
} }
private String serialize(Metric<?> entity) { private String serialize(Metric<?> entity) {

@ -82,9 +82,9 @@ public class InMemoryPrefixMetricRepositoryTests {
@Test @Test
public void incrementGroup() { public void incrementGroup() {
this.repository.increment("foo", new Delta<Number>("bar", 1)); this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
this.repository.increment("foo", new Delta<Number>("bar", 2)); this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
this.repository.increment("foo", new Delta<Number>("spam", 1)); this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
Set<String> names = new HashSet<String>(); Set<String> names = new HashSet<String>();
for (Metric<?> metric : this.repository.findAll("foo")) { for (Metric<?> metric : this.repository.findAll("foo")) {
names.add(metric.getName()); names.add(metric.getName());

@ -116,9 +116,9 @@ public class RedisMultiMetricRepositoryTests {
@Test @Test
public void increment() { public void increment() {
this.repository.increment("foo", new Delta<Number>("bar", 1)); this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
this.repository.increment("foo", new Delta<Number>("bar", 2)); this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
this.repository.increment("foo", new Delta<Number>("spam", 1)); this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
Metric<?> bar = null; Metric<?> bar = null;
Set<String> names = new HashSet<String>(); Set<String> names = new HashSet<String>();
for (Metric<?> metric : this.repository.findAll("foo")) { for (Metric<?> metric : this.repository.findAll("foo")) {

Loading…
Cancel
Save