@Test public void testParseMalformatted() { MetricParser parser = new MetricParser(); try { parser.parse("put mymetric 12341234 5.0 tag1 tag2=value2"); Assert.fail(); } catch (IllegalArgumentException e) { } }
@Override public Metric parse(String line) { List<String> parts = spaceSplitter.splitToList(line); Preconditions.checkPositionIndex(3, parts.size()); Metric.Builder builder = Metric.newBuilder(); builder.name(parts.get(1)); builder.value(Long.parseLong(parts.get(2)), Double.parseDouble(parts.get(3))); parts.stream().skip(4).forEach(builder::tag); return builder.build(); }
MetricParser implements Parser<Metric> { @Override public Metric parse(String line) { List<String> parts = spaceSplitter.splitToList(line); Preconditions.checkPositionIndex(3, parts.size()); Metric.Builder builder = Metric.newBuilder(); builder.name(parts.get(1)); builder.value(Long.parseLong(parts.get(2)), Double.parseDouble(parts.get(3))); parts.stream().skip(4).forEach(builder::tag); return builder.build(); } }
MetricParser implements Parser<Metric> { @Override public Metric parse(String line) { List<String> parts = spaceSplitter.splitToList(line); Preconditions.checkPositionIndex(3, parts.size()); Metric.Builder builder = Metric.newBuilder(); builder.name(parts.get(1)); builder.value(Long.parseLong(parts.get(2)), Double.parseDouble(parts.get(3))); parts.stream().skip(4).forEach(builder::tag); return builder.build(); }  }
MetricParser implements Parser<Metric> { @Override public Metric parse(String line) { List<String> parts = spaceSplitter.splitToList(line); Preconditions.checkPositionIndex(3, parts.size()); Metric.Builder builder = Metric.newBuilder(); builder.name(parts.get(1)); builder.value(Long.parseLong(parts.get(2)), Double.parseDouble(parts.get(3))); parts.stream().skip(4).forEach(builder::tag); return builder.build(); }  @Override Metric parse(String line); }
MetricParser implements Parser<Metric> { @Override public Metric parse(String line) { List<String> parts = spaceSplitter.splitToList(line); Preconditions.checkPositionIndex(3, parts.size()); Metric.Builder builder = Metric.newBuilder(); builder.name(parts.get(1)); builder.value(Long.parseLong(parts.get(2)), Double.parseDouble(parts.get(3))); parts.stream().skip(4).forEach(builder::tag); return builder.build(); }  @Override Metric parse(String line);  }