use of com.srotya.sidewinder.core.rpc.Tag in project sidewinder by srotya.
the class TestGraphiteDecoder method testHandler.
@Test
public void testHandler() throws IOException {
EmbeddedChannel ch = new EmbeddedChannel(new StringDecoder(), new GraphiteDecoder("test", engine, null));
ch.writeInbound(Unpooled.copiedBuffer("app=1.server=1.s=jvm.heap.max 233123 1497720452", Charset.defaultCharset()));
ch.readInbound();
List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("app").setTagValue("1").build(), Tag.newBuilder().setTagKey("server").setTagValue("1").build(), Tag.newBuilder().setTagKey("s").setTagValue("jvm").build());
verify(engine, times(1)).writeDataPointWithLock(MiscUtils.buildDataPoint("test", "heap", "max", tags, ((long) 1497720452) * 1000, 233123), false);
ch.close();
}
use of com.srotya.sidewinder.core.rpc.Tag in project sidewinder by srotya.
the class TestMeasurement method testMeasurementRecovery.
@Test
public void testMeasurementRecovery() throws IOException {
List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("t").setTagValue("1").build(), Tag.newBuilder().setTagKey("t").setTagValue("2").build());
measurement.configure(conf, engine, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
measurement.addPointWithLocking(build("vf1", tags, t + i * 1000, i), false);
}
Series s = measurement.getOrCreateSeries(tags, false);
List<DataPoint> dps = s.queryDataPoints(measurement, Arrays.asList("vf1"), t, t + 1000 * 100, null).get("vf1");
assertEquals(100, dps.size());
for (int i = 0; i < 100; i++) {
DataPoint dp = dps.get(i);
assertEquals(t + i * 1000, dp.getTimestamp());
assertEquals(i, dp.getLongValue());
}
List<SeriesOutput> resultMap = new ArrayList<>();
measurement.queryDataPoints("vf1", t, t + 1000 * 100, null, null, resultMap, null);
assertEquals(1, resultMap.size());
SeriesOutput next = resultMap.iterator().next();
for (int i = 0; i < next.getDataPoints().size(); i++) {
DataPoint dp = next.getDataPoints().get(i);
assertEquals(t + i * 1000, dp.getTimestamp());
assertEquals(i, dp.getLongValue());
}
ConcurrentMap<ByteString, FieldReaderIterator[]> readers = new ConcurrentHashMap<>();
measurement.queryReaders(Arrays.asList("vf1"), null, false, t, t + 1000 * 100, null, readers);
assertEquals(1, readers.size());
for (Entry<ByteString, FieldReaderIterator[]> entry : readers.entrySet()) {
assertEquals(100, entry.getValue()[0].getReaders().get(0).getCount());
assertEquals(100, entry.getValue()[1].getReaders().get(0).getCount());
}
measurement.close();
}
use of com.srotya.sidewinder.core.rpc.Tag in project sidewinder by srotya.
the class TestMeasurement method testDataPointsQuery.
@Test
public void testDataPointsQuery() throws Exception {
final long ts = 1546334202515L;
List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("test").setTagValue("1").build(), Tag.newBuilder().setTagKey("test").setTagValue("2").build());
conf.put(DiskMalloc.CONF_MEASUREMENT_FILE_MAX, String.valueOf(2 * 1024 * 1024));
measurement.configure(conf, null, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
int LIMIT = 1000;
for (int i = 0; i < LIMIT; i++) {
measurement.addPointWithLocking(Point.newBuilder().setDbName(DBNAME).setMeasurementName("m1").addAllTags(tags).setTimestamp(ts + i * 1000).addFp(false).addValue(1L).addValueFieldName("value1").addFp(false).addValue(1L).addValueFieldName("value2").build(), true);
}
List<SeriesOutput> resultMap = new ArrayList<>();
measurement.queryDataPoints("value.*$", ts, ts + 1000 * LIMIT, null, null, resultMap, null);
assertEquals(2, resultMap.size());
for (SeriesOutput s : resultMap) {
for (int i = 0; i < s.getDataPoints().size(); i++) {
DataPoint dataPoint = s.getDataPoints().get(i);
assertEquals("Bad timestamp:" + ts + " + " + i * 1000 + " iteration:" + i, ts + i * 1000, dataPoint.getTimestamp());
assertEquals(1L, dataPoint.getLongValue());
}
}
List<List<Tag>> tagsResult = measurement.getTagsForMeasurement();
Collections.sort(tags, Measurement.TAG_COMPARATOR);
for (List<Tag> list : tagsResult) {
Set<Tag> hashSet = new HashSet<>(list);
for (int i = 0; i < tags.size(); i++) {
Tag tag = tags.get(i);
assertTrue(hashSet.contains(tag));
}
}
try {
tagsResult = measurement.getTagsForMeasurement();
} catch (IOException e) {
}
measurement.close();
}
use of com.srotya.sidewinder.core.rpc.Tag in project sidewinder by srotya.
the class TestMeasurement method testTagEncodingPerformance.
@Test
public void testTagEncodingPerformance() throws IOException {
measurement.configure(conf, engine, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
assertTrue(measurement.getTagIndex() != null);
for (int i = 0; i < 1_000_000; i++) {
List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("test").setTagValue(String.valueOf("asdasd" + i)).build(), Tag.newBuilder().setTagKey("test").setTagValue("2").build());
measurement.encodeTagsToString(tags);
}
}
use of com.srotya.sidewinder.core.rpc.Tag in project sidewinder by srotya.
the class TestMeasurement method testLinearizability.
@Test
public void testLinearizability() throws IOException, InterruptedException {
String valueFieldName = "vf2";
for (int p = 0; p < 100; p++) {
MiscUtils.delete(new File("target/measurement-common"));
final long t1 = 1497720452566L;
measurement.configure(conf, engine, 4096, DBNAME, "m2", indexDir, dataDir, metadata, bgTaskPool);
ExecutorService es = Executors.newFixedThreadPool(2, new BackgrounThreadFactory("tlinear"));
final List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("t").setTagValue("1").build(), Tag.newBuilder().setTagKey("t").setTagValue("2").build());
AtomicBoolean wait = new AtomicBoolean(false);
for (int i = 0; i < 2; i++) {
final int th = i;
es.submit(() -> {
while (!wait.get()) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
long t = t1 + th * 3;
for (int j = 0; j < 100; j++) {
try {
long timestamp = t + j * 1000;
measurement.addPointWithLocking(build(valueFieldName, tags, timestamp, j), false);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
es.shutdown();
wait.set(true);
es.awaitTermination(100, TimeUnit.SECONDS);
Series s = measurement.getOrCreateSeries(tags, false);
List<DataPoint> dps = s.queryDataPoints(measurement, Arrays.asList(valueFieldName), t1 - 120, t1 + 1000_000, null).get(valueFieldName);
assertEquals(200, dps.size());
measurement.close();
}
}
Aggregations