use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestTransformFunctions method testCube.
@Test
public void testCube() {
Function f = new CubeFunction();
List<SeriesOutput> series = new ArrayList<>();
SeriesOutput s = new SeriesOutput(Arrays.asList(new DataPoint(1L, 3), new DataPoint(1L, 4)));
series.add(s);
List<SeriesOutput> apply = f.apply(series);
assertEquals(2, apply.get(0).getDataPoints().size());
assertEquals(27, apply.get(0).getDataPoints().get(0).getLongValue());
assertEquals(64, apply.get(0).getDataPoints().get(1).getLongValue());
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestGRPWriterServiceImpl method testSingleDataPointWrites.
// @Test
public void testSingleDataPointWrites() throws Exception {
WriterServiceBlockingStub client = WriterServiceGrpc.newBlockingStub(channel);
long sts = 1497720452566L;
Point point = Point.newBuilder().setDbName("test").addFp(false).setMeasurementName("cpu").addTags(Tag.newBuilder().setTagKey("host").setTagValue("1").build()).setTimestamp(sts).addValue(1L).addValueFieldName("usage").build();
client.writeSingleDataPoint(SingleData.newBuilder().setMessageId(point.getTimestamp()).setPoint(point).build());
assertTrue(engine.checkIfExists("test"));
assertTrue(engine.checkIfExists("test", "cpu"));
assertEquals("host=1", engine.getTagKeysForMeasurement("test", "cpu").iterator().next());
List<SeriesOutput> result = engine.queryDataPoints("test", "cpu", "usage", sts, sts + 1, null);
assertEquals(1, result.size());
assertEquals(1, result.iterator().next().getDataPoints().size());
assertEquals(1L, result.iterator().next().getDataPoints().iterator().next().getLongValue());
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestPersistentMeasurement method testDataPointsRecoveryPTR.
@Test
public void testDataPointsRecoveryPTR() throws Exception {
long ts = System.currentTimeMillis();
List<Tag> tags = Arrays.asList(Tag.newBuilder().setTagKey("test").setTagValue("1").build(), Tag.newBuilder().setTagKey("test").setTagValue("2").build());
Map<String, String> conf = new HashMap<>();
conf.put(DiskMalloc.CONF_MEASUREMENT_FILE_MAX, String.valueOf(2 * 1024 * 1024));
conf.put("malloc.ptrfile.increment", String.valueOf(2 * 1024));
measurement.configure(conf, null, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
int LIMIT = 100;
for (int i = 0; i < LIMIT; i++) {
measurement.addPointWithLocking(MiscUtils.buildDataPoint(DBNAME, "m1", "value" + i, tags, ts, 1L), true);
}
measurement.close();
measurement.configure(conf, null, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
List<SeriesOutput> resultMap = new ArrayList<>();
measurement.queryDataPoints("value.*", ts, ts + 1000, null, null, resultMap, null);
assertEquals(LIMIT, resultMap.size());
measurement.close();
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestPersistentMeasurement method testDataPointsRecovery.
@Test
public void testDataPointsRecovery() throws Exception {
long ts = System.currentTimeMillis();
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(1024 * 1024));
try {
measurement.configure(conf, null, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
fail("Must throw invalid file max size exception");
} catch (Exception e) {
}
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 = 100000;
for (int i = 0; i < LIMIT; i++) {
measurement.addPointWithLocking(TestMeasurement.build("value", tags, ts + i * 1000, 1L), false);
}
measurement.close();
measurement.configure(conf, null, 4096, DBNAME, "m1", indexDir, dataDir, metadata, bgTaskPool);
List<SeriesOutput> resultMap = new ArrayList<>();
measurement.queryDataPoints("value", ts, ts + 1000 * LIMIT, null, null, resultMap, null);
Iterator<SeriesOutput> iterator = resultMap.iterator();
assertEquals(LIMIT, iterator.next().getDataPoints().size());
resultMap.clear();
TagFilter filter = MiscUtils.buildTagFilter("test=1&test=2");
measurement.queryDataPoints("value", ts, ts + 1000 * LIMIT, filter, null, resultMap, null);
iterator = resultMap.iterator();
assertEquals(LIMIT, iterator.next().getDataPoints().size());
measurement.close();
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestDiskStorageEngine method testQueryDataPointsRecovery.
@Test
public void testQueryDataPointsRecovery() throws Exception {
try {
List<Tag> tagd = Arrays.asList(Tag.newBuilder().setTagKey("test").setTagValue("e").build());
DiskStorageEngine engine = new DiskStorageEngine();
File file = new File("target/db201/");
MiscUtils.delete(file);
MiscUtils.ls(file);
Map<String, String> map = new HashMap<>();
map.put("index.dir", "target/db201/index");
map.put("data.dir", "target/db201/data");
engine.configure(map, bgTasks);
long ts = System.currentTimeMillis();
Map<String, Measurement> db = engine.getOrCreateDatabase("test3");
assertEquals(0, db.size());
engine.writeDataPointWithLock(MiscUtils.buildDataPoint("test3", "cpu", "value", tagd, ts, 1), false);
engine.writeDataPointWithLock(MiscUtils.buildDataPoint("test3", "cpu", "value", tagd, ts + (400 * 60000), 4), false);
Measurement measurement = engine.getOrCreateMeasurement("test3", "cpu");
assertEquals(1, measurement.getSeriesKeys().size());
MiscUtils.ls(file);
engine = new DiskStorageEngine();
engine.configure(map, bgTasks);
assertTrue(!engine.isMeasurementFieldFP("test3", "cpu", "value"));
List<SeriesOutput> queryDataPoints = engine.queryDataPoints("test3", "cpu", "value", ts, ts + (400 * 60000), null, null);
try {
engine.isMeasurementFieldFP("test3", "test", "test");
fail("Measurement should not exist");
} catch (Exception e) {
}
assertEquals(1, queryDataPoints.size());
assertEquals(2, queryDataPoints.iterator().next().getDataPoints().size());
assertEquals(ts, queryDataPoints.iterator().next().getDataPoints().get(0).getTimestamp());
assertEquals(ts + (400 * 60000), queryDataPoints.iterator().next().getDataPoints().get(1).getTimestamp());
TagFilter filter = MiscUtils.buildTagFilter("test=e");
queryDataPoints = engine.queryDataPoints("test3", "cpu", "value", ts, ts + (400 * 60000), filter, null);
assertEquals(1, queryDataPoints.size());
assertEquals(2, queryDataPoints.iterator().next().getDataPoints().size());
assertEquals(ts, queryDataPoints.iterator().next().getDataPoints().get(0).getTimestamp());
assertEquals(ts + (400 * 60000), queryDataPoints.iterator().next().getDataPoints().get(1).getTimestamp());
filter = MiscUtils.buildTagFilter("test=2");
queryDataPoints = engine.queryDataPoints("test3", "cpu", "value", ts, ts + (400 * 60000), filter, null);
assertEquals(0, queryDataPoints.size());
try {
engine.dropDatabase("test3");
} catch (Exception e) {
e.printStackTrace();
fail("Database delete must succeed");
}
assertTrue(!new File("target/db201/data/test3").exists());
assertEquals(0, engine.getOrCreateMeasurement("test3", "cpu").getSeriesKeys().size());
engine.shutdown();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
Aggregations