@Test(expected = IllegalArgumentException.class) public void testMissingValue() { String metric = "put a.b 1465530393 c=d"; chunkManager.addMetric(metric); }
public void addMetric(final String metricString) { try { String[] metricParts = metricString.split(" "); if (metricParts.length > 1 && metricParts[0].equals("put")) { String metricName = metricParts[1].trim(); List<String> rawTags = Arrays.asList(metricParts).subList(4, metricParts.length); Metric metric = new Metric(metricName, rawTags); long ts = Long.parseLong(metricParts[2].trim()); double value = Double.parseDouble(metricParts[3].trim()); Chunk chunk = getChunk(ts); if (!chunk.isReadOnly()) { chunk.addPoint(metric, ts, value); } else { throw new ReadOnlyChunkInsertionException("Inserting metric into a read only store:" + metricString); } } else { throw new IllegalArgumentException("Metric doesn't start with a put: " + metricString); } } catch (ReadOnlyChunkInsertionException re) { throw re; } catch (Exception e) { LOG.error("metric failed with exception: ", e); throw new IllegalArgumentException("Invalid metric string " + metricString, e); } }
ChunkManager { public void addMetric(final String metricString) { try { String[] metricParts = metricString.split(" "); if (metricParts.length > 1 && metricParts[0].equals("put")) { String metricName = metricParts[1].trim(); List<String> rawTags = Arrays.asList(metricParts).subList(4, metricParts.length); Metric metric = new Metric(metricName, rawTags); long ts = Long.parseLong(metricParts[2].trim()); double value = Double.parseDouble(metricParts[3].trim()); Chunk chunk = getChunk(ts); if (!chunk.isReadOnly()) { chunk.addPoint(metric, ts, value); } else { throw new ReadOnlyChunkInsertionException("Inserting metric into a read only store:" + metricString); } } else { throw new IllegalArgumentException("Metric doesn't start with a put: " + metricString); } } catch (ReadOnlyChunkInsertionException re) { throw re; } catch (Exception e) { LOG.error("metric failed with exception: ", e); throw new IllegalArgumentException("Invalid metric string " + metricString, e); } } }
ChunkManager { public void addMetric(final String metricString) { try { String[] metricParts = metricString.split(" "); if (metricParts.length > 1 && metricParts[0].equals("put")) { String metricName = metricParts[1].trim(); List<String> rawTags = Arrays.asList(metricParts).subList(4, metricParts.length); Metric metric = new Metric(metricName, rawTags); long ts = Long.parseLong(metricParts[2].trim()); double value = Double.parseDouble(metricParts[3].trim()); Chunk chunk = getChunk(ts); if (!chunk.isReadOnly()) { chunk.addPoint(metric, ts, value); } else { throw new ReadOnlyChunkInsertionException("Inserting metric into a read only store:" + metricString); } } else { throw new IllegalArgumentException("Metric doesn't start with a put: " + metricString); } } catch (ReadOnlyChunkInsertionException re) { throw re; } catch (Exception e) { LOG.error("metric failed with exception: ", e); throw new IllegalArgumentException("Invalid metric string " + metricString, e); } } ChunkManager(String chunkDataPrefix, int expectedTagStoreSize);  ChunkManager(String chunkDataPrefix, int expectedTagStoreSize, String dataDirectory); }
ChunkManager { public void addMetric(final String metricString) { try { String[] metricParts = metricString.split(" "); if (metricParts.length > 1 && metricParts[0].equals("put")) { String metricName = metricParts[1].trim(); List<String> rawTags = Arrays.asList(metricParts).subList(4, metricParts.length); Metric metric = new Metric(metricName, rawTags); long ts = Long.parseLong(metricParts[2].trim()); double value = Double.parseDouble(metricParts[3].trim()); Chunk chunk = getChunk(ts); if (!chunk.isReadOnly()) { chunk.addPoint(metric, ts, value); } else { throw new ReadOnlyChunkInsertionException("Inserting metric into a read only store:" + metricString); } } else { throw new IllegalArgumentException("Metric doesn't start with a put: " + metricString); } } catch (ReadOnlyChunkInsertionException re) { throw re; } catch (Exception e) { LOG.error("metric failed with exception: ", e); throw new IllegalArgumentException("Invalid metric string " + metricString, e); } } ChunkManager(String chunkDataPrefix, int expectedTagStoreSize);  ChunkManager(String chunkDataPrefix, int expectedTagStoreSize, String dataDirectory); Chunk getChunk(long timestamp); void addMetric(final String metricString); List<TimeSeries> queryAroundChunkBoundaries(Query query, long startTsSecs,
                                                     long endTsSecs,
                                                     QueryAggregation queryAggregation); List<TimeSeries> query(Query query, long startTsSecs, long endTsSecs,
                                QueryAggregation queryAggregation); void toReadOnlyChunks(List<Map.Entry<Long, Chunk>> expiredChunks); void removeStaleChunks(List<Map.Entry<Long, Chunk>> staleChunks); }
ChunkManager { public void addMetric(final String metricString) { try { String[] metricParts = metricString.split(" "); if (metricParts.length > 1 && metricParts[0].equals("put")) { String metricName = metricParts[1].trim(); List<String> rawTags = Arrays.asList(metricParts).subList(4, metricParts.length); Metric metric = new Metric(metricName, rawTags); long ts = Long.parseLong(metricParts[2].trim()); double value = Double.parseDouble(metricParts[3].trim()); Chunk chunk = getChunk(ts); if (!chunk.isReadOnly()) { chunk.addPoint(metric, ts, value); } else { throw new ReadOnlyChunkInsertionException("Inserting metric into a read only store:" + metricString); } } else { throw new IllegalArgumentException("Metric doesn't start with a put: " + metricString); } } catch (ReadOnlyChunkInsertionException re) { throw re; } catch (Exception e) { LOG.error("metric failed with exception: ", e); throw new IllegalArgumentException("Invalid metric string " + metricString, e); } } ChunkManager(String chunkDataPrefix, int expectedTagStoreSize);  ChunkManager(String chunkDataPrefix, int expectedTagStoreSize, String dataDirectory); Chunk getChunk(long timestamp); void addMetric(final String metricString); List<TimeSeries> queryAroundChunkBoundaries(Query query, long startTsSecs,
                                                     long endTsSecs,
                                                     QueryAggregation queryAggregation); List<TimeSeries> query(Query query, long startTsSecs, long endTsSecs,
                                QueryAggregation queryAggregation); void toReadOnlyChunks(List<Map.Entry<Long, Chunk>> expiredChunks); void removeStaleChunks(List<Map.Entry<Long, Chunk>> staleChunks); static Duration DEFAULT_CHUNK_DURATION; }