Search in sources :

Example 1 with StorageEngine

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());
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) File(java.io.File) Test(org.junit.Test)

Example 2 with StorageEngine

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"));
}
Also used : TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) Series(com.srotya.sidewinder.core.storage.Series) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) File(java.io.File) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) Point(com.srotya.sidewinder.core.rpc.Point) Test(org.junit.Test)

Example 3 with StorageEngine

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);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) File(java.io.File) Test(org.junit.Test)

Example 4 with StorageEngine

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());
}
Also used : Measurement(com.srotya.sidewinder.core.storage.Measurement) TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) Series(com.srotya.sidewinder.core.storage.Series) StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) ItemNotFoundException(com.srotya.sidewinder.core.storage.ItemNotFoundException) RejectException(com.srotya.sidewinder.core.storage.RejectException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with StorageEngine

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());
}
Also used : StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) Test(org.junit.Test)

Aggregations

StorageEngine (com.srotya.sidewinder.core.storage.StorageEngine)14 Test (org.junit.Test)14 HashMap (java.util.HashMap)11 LinkedHashMap (java.util.LinkedHashMap)11 File (java.io.File)10 ItemNotFoundException (com.srotya.sidewinder.core.storage.ItemNotFoundException)9 RejectException (com.srotya.sidewinder.core.storage.RejectException)8 IOException (java.io.IOException)8 Series (com.srotya.sidewinder.core.storage.Series)6 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)6 Point (com.srotya.sidewinder.core.rpc.Point)5 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)5 Measurement (com.srotya.sidewinder.core.storage.Measurement)2 Gson (com.google.gson.Gson)1 SimpleTagFilter (com.srotya.sidewinder.core.filters.SimpleTagFilter)1 DBMetadata (com.srotya.sidewinder.core.storage.DBMetadata)1 ByzantineWriter (com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter)1 BackgrounThreadFactory (com.srotya.sidewinder.core.utils.BackgrounThreadFactory)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1