use of com.srotya.sidewinder.core.utils.BackgrounThreadFactory in project sidewinder by srotya.
the class TestPersistentMeasurement method testLinearizability.
@Test
public void testLinearizability() throws IOException, InterruptedException {
for (int p = 0; p < 100; p++) {
MiscUtils.delete(new File("target/db134/"));
final long t1 = 1497720452566L;
Measurement m = new PersistentMeasurement();
m.configure(conf, engine, DBNAME, "m1", "target/db134/index", "target/db134/data", metadata, bgTaskPool);
ExecutorService es = Executors.newFixedThreadPool(2, new BackgrounThreadFactory("tlinear"));
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 {
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(100, TimeUnit.SECONDS);
TimeSeries ts = m.getOrCreateTimeSeries("vf1", Arrays.asList("t=1", "t=2"), 4096, false, conf);
List<DataPoint> dps = ts.queryDataPoints("vf1", t1 - 120, t1 + 1000_000, null);
assertEquals(200, dps.size());
assertEquals(1, ts.getBucketCount());
m.close();
}
}
use of com.srotya.sidewinder.core.utils.BackgrounThreadFactory in project sidewinder by srotya.
the class TestSetTagIndex method testTagIndexPerformance.
// @Test
public void testTagIndexPerformance() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/perf/index-dir"));
MiscUtils.delete(new File("target/perf/data-dir"));
DiskStorageEngine engine = new DiskStorageEngine();
HashMap<String, String> conf = new HashMap<>();
conf.put("index.dir", "target/perf/index-dir");
conf.put("data.dir", "target/perf/data-dir");
engine.configure(conf, Executors.newScheduledThreadPool(1, new BackgrounThreadFactory("bgt")));
final long ms = System.currentTimeMillis();
ExecutorService es = Executors.newCachedThreadPool();
for (int k = 0; k < 6; k++) {
es.submit(() -> {
for (int i = 0; i < 200_000_000; i++) {
try {
engine.getOrCreateTimeSeries("db1", "m1", "v10", Arrays.asList(String.valueOf(i % 10_000), "test=" + "asdasdasd" + String.valueOf(i % 5), "test2=" + String.valueOf(i % 5), "goliath=" + String.valueOf(i % 100_000), "goliath2=" + String.valueOf(i % 1_500)), 4096, true);
} catch (IOException e) {
e.printStackTrace();
}
if (i % 1_000_000 == 0) {
System.out.println(i + " " + (System.currentTimeMillis() - ms) / 1000);
}
}
});
}
es.shutdown();
es.awaitTermination(1000, TimeUnit.SECONDS);
System.err.println("Index time:" + (System.currentTimeMillis() - ms));
Map<String, Map<String, Measurement>> index = engine.getMeasurementMap();
assertEquals(1, index.size());
Entry<String, Map<String, Measurement>> next = index.entrySet().iterator().next();
assertEquals("db1", next.getKey());
Entry<String, Measurement> itr = next.getValue().entrySet().iterator().next();
assertEquals("m1", itr.getKey());
}
Aggregations