Search in sources :

Example 1 with SetIndex

use of com.srotya.sidewinder.core.storage.mem.SetIndex 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)

Aggregations

Tag (com.srotya.sidewinder.core.filters.Tag)1 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)1 Measurement (com.srotya.sidewinder.core.storage.Measurement)1 SetIndex (com.srotya.sidewinder.core.storage.mem.SetIndex)1 File (java.io.File)1 Test (org.junit.Test)1