use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestDiskStorageEngine method testMeasurementsLike.
@Test
public void testMeasurementsLike() throws Exception {
MiscUtils.delete(new File("target/dst-4/data"));
StorageEngine engine = new DiskStorageEngine();
Map<String, String> conf = new HashMap<>();
conf.put("data.dir", "target/dst-4/data");
conf.put("index.dir", "target/dst-4/index");
engine.configure(conf, bgTasks);
engine.getOrCreateTimeSeries("db1", "m1", "vf1", Arrays.asList("t=1"), 4096, false);
engine.getOrCreateTimeSeries("db1", "t1", "vf1", Arrays.asList("t=1"), 4096, false);
Set<String> measurementsLike = engine.getMeasurementsLike("db1", "m.*");
assertEquals(1, measurementsLike.size());
assertEquals(2, engine.getAllMeasurementsForDb("db1").size());
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestDiskStorageEngine method testGarbageCollector.
@Test
public void testGarbageCollector() throws Exception {
StorageEngine engine = new DiskStorageEngine();
MiscUtils.delete(new File("target/dbgc/"));
HashMap<String, String> map = new HashMap<>();
map.put("index.dir", "target/dbgc/index");
map.put("data.dir", "target/dbgc/data");
map.put(StorageEngine.GC_DELAY, "1");
map.put(StorageEngine.GC_FREQUENCY, "10");
map.put(StorageEngine.PERSISTENCE_DISK, "true");
map.put(StorageEngine.DEFAULT_BUCKET_SIZE, "4096");
map.put(DiskMalloc.CONF_MEASUREMENT_INCREMENT_SIZE, "4096");
map.put(DiskMalloc.CONF_MEASUREMENT_FILE_INCREMENT, "10240");
map.put(DiskMalloc.CONF_MEASUREMENT_FILE_MAX, String.valueOf(1024 * 100));
map.put(StorageEngine.RETENTION_HOURS, "28");
engine.configure(map, bgTasks);
long base = 1497720452566L;
long ts = base;
for (int i = 320; i >= 0; i--) {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "cpu2", "value", Arrays.asList("test=1"), base - (3600_000 * i), 2L));
}
engine.getMeasurementMap().get("test").get("cpu2").collectGarbage(null);
List<Series> queryDataPoints = engine.queryDataPoints("test", "cpu2", "value", ts - (3600_000 * 320), ts, null, null);
assertEquals(27, queryDataPoints.iterator().next().getDataPoints().size());
assertTrue(!engine.isMeasurementFieldFP("test", "cpu2", "value"));
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestDiskStorageEngine method testInvalidArchiver.
@Test
public void testInvalidArchiver() throws IOException {
MiscUtils.delete(new File("target/dst-1/data"));
StorageEngine engine = new DiskStorageEngine();
Map<String, String> conf = new HashMap<>();
conf.put("data.dir", "target/dst-1/data");
conf.put("data.dir", "target/dst-1/index");
conf.put(StorageEngine.ARCHIVER_CLASS, "asdasd");
engine.configure(conf, bgTasks);
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestMemStorageEngine method testQueryDataPoints.
@Test
public void testQueryDataPoints() throws IOException, ItemNotFoundException {
StorageEngine engine = new MemStorageEngine();
engine.configure(conf, bgTasks);
long ts = System.currentTimeMillis();
Map<String, Measurement> db = engine.getOrCreateDatabase("test", 24);
assertEquals(0, db.size());
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "cpu", "value", Arrays.asList("test=1"), ts, 1));
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "cpu", "value", Arrays.asList("test=1"), ts + (400 * 60000), 4));
assertEquals(1, engine.getOrCreateMeasurement("test", "cpu").getSeriesKeys().size());
List<Series> queryDataPoints = engine.queryDataPoints("test", "cpu", "value", ts, ts + (400 * 60000), null, null);
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());
assertTrue(!engine.isMeasurementFieldFP("test", "cpu", "value"));
try {
engine.isMeasurementFieldFP("test", "test", "test");
fail("Measurement should not exist");
} catch (Exception e) {
}
try {
engine.dropDatabase("test");
} catch (Exception e) {
}
assertEquals(0, engine.getOrCreateMeasurement("test", "cpu").getTimeSeries().size());
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestMemStorageEngine method testGetMeasurementsLike.
@Test
public void testGetMeasurementsLike() throws Exception {
StorageEngine engine = new MemStorageEngine();
engine.configure(conf, bgTasks);
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "cpu", "value", Arrays.asList("test=2"), System.currentTimeMillis(), 2L));
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "mem", "value", Arrays.asList("test=2"), System.currentTimeMillis() + 10, 3L));
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "netm", "value", Arrays.asList("test=2"), System.currentTimeMillis() + 20, 5L));
Set<String> result = engine.getMeasurementsLike("test", " ");
assertEquals(3, result.size());
result = engine.getMeasurementsLike("test", "c.*");
assertEquals(1, result.size());
result = engine.getMeasurementsLike("test", ".*m.*");
assertEquals(2, result.size());
}
Aggregations