Search in sources :

Example 1 with Measurement

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

Example 2 with Measurement

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();
    }
}
Also used : Measurement(com.srotya.sidewinder.core.storage.Measurement) BackgrounThreadFactory(com.srotya.sidewinder.core.utils.BackgrounThreadFactory) TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File) Test(org.junit.Test)

Example 3 with Measurement

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));
    }
}
Also used : Measurement(com.srotya.sidewinder.core.storage.Measurement) SetIndex(com.srotya.sidewinder.core.storage.mem.SetIndex) Tag(com.srotya.sidewinder.core.filters.Tag) File(java.io.File) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) Test(org.junit.Test)

Example 4 with Measurement

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

Example 5 with Measurement

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());
}
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)

Aggregations

Measurement (com.srotya.sidewinder.core.storage.Measurement)25 File (java.io.File)13 IOException (java.io.IOException)11 Test (org.junit.Test)8 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)7 DBMetadata (com.srotya.sidewinder.core.storage.DBMetadata)5 SeriesFieldMap (com.srotya.sidewinder.core.storage.SeriesFieldMap)5 BackgrounThreadFactory (com.srotya.sidewinder.core.utils.BackgrounThreadFactory)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ExecutorService (java.util.concurrent.ExecutorService)4 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)3 ItemNotFoundException (com.srotya.sidewinder.core.storage.ItemNotFoundException)3 RejectException (com.srotya.sidewinder.core.storage.RejectException)3 Series (com.srotya.sidewinder.core.storage.Series)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 StorageEngine (com.srotya.sidewinder.core.storage.StorageEngine)2 NoneArchiver (com.srotya.sidewinder.core.storage.archival.NoneArchiver)2 ByzantineWriter (com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter)2