use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestDiskStorageEngine method testConfigure.
@Test
public void testConfigure() throws IOException {
StorageEngine engine = new DiskStorageEngine();
try {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "ss", "value", Arrays.asList("t=e"), System.currentTimeMillis(), 2.2));
fail("Engine not initialized, shouldn't be able to write a datapoint");
} catch (Exception e) {
}
try {
// FileUtils.forceDelete(new File("target/db2/"));
MiscUtils.delete(new File("targer/db2/"));
HashMap<String, String> map = new HashMap<>();
// map.put("metadata.dir", "target/db2/mdq");
map.put("index.dir", "target/db2/index");
map.put("data.dir", "target/db2/data");
map.put(StorageEngine.PERSISTENCE_DISK, "true");
map.put("default.series.retention.hours", "32");
engine.configure(map, bgTasks);
} catch (IOException e) {
fail("No IOException should be thrown");
}
try {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "ss", "value", Arrays.asList("t=e"), System.currentTimeMillis(), 2.2));
String md = new String(Files.readAllBytes(new File("target/db2/data/test/.md").toPath()), Charset.forName("utf8"));
DBMetadata metadata = new Gson().fromJson(md, DBMetadata.class);
assertEquals(32, metadata.getRetentionHours());
} catch (Exception e) {
e.printStackTrace();
fail("Engine is initialized, no IO Exception should be thrown:" + e.getMessage());
}
engine.disconnect();
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestDiskStorageEngine method testGetMeasurementsLike.
@Test
public void testGetMeasurementsLike() throws Exception {
StorageEngine engine = new DiskStorageEngine();
MiscUtils.delete(new File("target/db1/"));
HashMap<String, String> map = new HashMap<>();
map.put("metadata.dir", "target/db1/mdq");
map.put("index.dir", "target/db1/index");
map.put("data.dir", "target/db1/data");
map.put(StorageEngine.PERSISTENCE_DISK, "true");
engine.configure(map, bgTasks);
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "cpu", "value", Arrays.asList("test=1"), System.currentTimeMillis(), 2L));
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "mem", "value", Arrays.asList("test=1"), System.currentTimeMillis() + 10, 3L));
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "netm", "value", Arrays.asList("test=1"), 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());
engine.disconnect();
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestMemStorageEngine method testConfigureTimeBuckets.
@Test
public void testConfigureTimeBuckets() throws ItemNotFoundException, IOException {
StorageEngine engine = new MemStorageEngine();
HashMap<String, String> conf = new HashMap<>();
long ts = System.currentTimeMillis();
conf.put(StorageEngine.DEFAULT_BUCKET_SIZE, String.valueOf(4096 * 10));
try {
engine.configure(conf, bgTasks);
} catch (IOException e) {
fail("No IOException should be thrown");
}
try {
for (int i = 0; i < 10; i++) {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "ss", "value", Arrays.asList("te=2"), ts + (i * 4096 * 1000), 2.2));
}
} catch (Exception e) {
e.printStackTrace();
fail("Engine is initialized, no IO Exception should be thrown:" + e.getMessage());
}
List<Series> queryDataPoints = engine.queryDataPoints("test", "ss", "value", ts, ts + (4096 * 100 * 1000) + 1, null);
assertTrue(queryDataPoints.size() >= 1);
}
use of com.srotya.sidewinder.core.storage.StorageEngine in project sidewinder by srotya.
the class TestMemStorageEngine method testConfigure.
// @Test
// public void testWritePerformanceStress() throws Exception {
// final MemStorageEngine engine = new MemStorageEngine();
// engine.configure(new HashMap<>());
// long timeMillis = System.currentTimeMillis();
// int tcount = 64;
// ExecutorService es = Executors.newCachedThreadPool();
// int count = 10000000;
// final int modulator = 100;
// final AtomicInteger rejects = new AtomicInteger(0);
// for (int k = 0; k < tcount; k++) {
// final int j = k;
// es.submit(new Thread() {
// @Override
// public void run() {
// long ts = System.currentTimeMillis();
// for (int i = 0; i < count; i++) {
// if (isInterrupted()) {
// break;
// }
// try {
// DataPoint dp = MiscUtils.buildDataPoint(ts + i, i * 1.1);
// dp.setDbName("test"+j);
// dp.setMeasurementName("cpu");
// dp.setTags(Arrays.asList("test2", String.valueOf( + (i % modulator))));
// dp.setValueFieldName("value");
// engine.writeDataPoint(dp);
// } catch (IOException e) {
// rejects.incrementAndGet();
// }
// }
// }
// });
// }
// es.shutdown();
// es.awaitTermination(120, TimeUnit.SECONDS);
// int backOff = 30;
// while (!es.isTerminated()) {
// backOff = backOff * 2;
// Thread.sleep(backOff);
// }
// System.out.println("Write throughput direct " + tcount + "x" + count +
// ":"
// + (System.currentTimeMillis() - timeMillis) + "ms with " + rejects.get()
// + " rejects"
// + "\nWriting " + tcount + " each with " + (count/modulator) + " series");
// }
@Test
public void testConfigure() {
StorageEngine engine = new MemStorageEngine();
try {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "ss", "value", Arrays.asList("te"), System.currentTimeMillis(), 2.2));
fail("Engine not initialized, shouldn't be able to write a datapoint");
} catch (Exception e) {
}
try {
engine.configure(new HashMap<>(), bgTasks);
} catch (IOException e) {
fail("No IOException should be thrown");
}
try {
engine.writeDataPoint(MiscUtils.buildDataPoint("test", "ss", "value", Arrays.asList("te=2"), System.currentTimeMillis(), 2.2));
} catch (Exception e) {
e.printStackTrace();
fail("Engine is initialized, no IO Exception should be thrown:" + e.getMessage());
}
}
Aggregations