use of com.srotya.sidewinder.core.storage.Measurement in project sidewinder by srotya.
the class TestPersistentMeasurement method testConstructRowKey.
@Test
public void testConstructRowKey() throws Exception {
MiscUtils.delete(new File("target/db131/"));
List<String> tags = Arrays.asList("test=1", "test=2");
Measurement m = new PersistentMeasurement();
m.configure(conf, engine, DBNAME, "m1", "target/db131/index", "target/db131/data", metadata, bgTaskPool);
TagIndex index = m.getTagIndex();
String encodeTagsToString = m.encodeTagsToString(index, tags);
String key = m.constructSeriesId(tags, index);
assertEquals(encodeTagsToString, key);
m.close();
}
use of com.srotya.sidewinder.core.storage.Measurement in project sidewinder by srotya.
the class TestPersistentMeasurement method testLinearizabilityWithRollOverBucket.
@Test
public void testLinearizabilityWithRollOverBucket() throws IOException, InterruptedException {
for (int p = 0; p < 2; p++) {
final int LIMIT = 10000;
MiscUtils.delete(new File("target/db135/"));
final long t1 = 1497720452566L;
Measurement m = new PersistentMeasurement();
m.configure(conf, engine, DBNAME, "m1", "target/db135/index", "target/db135/data", metadata, bgTaskPool);
ExecutorService es = Executors.newFixedThreadPool(2, new BackgrounThreadFactory("tlinear2"));
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 < LIMIT; j++) {
try {
TimeSeries ts = m.getOrCreateTimeSeries("vf1", Arrays.asList("t=1", "t=2"), 4096, false, conf);
long timestamp = t + j * 1000;
ts.addDataPoint(TimeUnit.MILLISECONDS, timestamp, j);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
es.shutdown();
wait.set(true);
es.awaitTermination(10, TimeUnit.SECONDS);
TimeSeries ts = m.getOrCreateTimeSeries("vf1", Arrays.asList("t=1", "t=2"), 4096, false, conf);
List<DataPoint> dps = ts.queryDataPoints("vf1", t1 - 100, t1 + 1000_0000, null);
assertEquals(LIMIT * 2, dps.size(), 10);
m.close();
}
}
use of com.srotya.sidewinder.core.storage.Measurement in project sidewinder by srotya.
the class TestPersistentMeasurement method testTagEncodeDecode.
@Test
public void testTagEncodeDecode() throws IOException {
String indexDir = "target/test";
MetricsRegistryService.getInstance(engine, bgTaskPool).getInstance("requests");
MiscUtils.delete(new File(indexDir));
new File(indexDir).mkdirs();
SetIndex table = new SetIndex(indexDir, "test2");
Measurement measurement = new PersistentMeasurement();
String encodedStr = measurement.encodeTagsToString(table, Arrays.asList("host=2", "value=1", "test=1"));
List<Tag> decodedStr = Measurement.decodeStringToTags(table, encodedStr);
List<Tag> list = Arrays.asList(new Tag("host", "2"), new Tag("value", "1"), new Tag("test", "1"));
for (int i = 0; i < list.size(); i++) {
assertEquals(list.get(i) + "", list.get(i), decodedStr.get(i));
}
}
use of com.srotya.sidewinder.core.storage.Measurement in project sidewinder by srotya.
the class TestPersistentMeasurement method testConfigure.
@Test
public void testConfigure() throws IOException {
MiscUtils.delete(new File("target/pmeasurement1"));
Measurement measurement = new PersistentMeasurement();
measurement.configure(conf, engine, DBNAME, "m1", "target/pmeasurement1/idx", "target/pmeasurement1/data", metadata, bgTaskPool);
assertTrue(measurement.getTagIndex() != null);
// TimeSeries series = measurement.getOrCreateTimeSeries("v1",
// Arrays.asList("test1"), 4096, false, conf);
measurement.close();
}
use of com.srotya.sidewinder.core.storage.Measurement 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());
}
Aggregations