Search in sources :

Example 6 with MemStorageEngine

use of com.srotya.sidewinder.core.storage.mem.MemStorageEngine in project sidewinder by srotya.

the class TestDatabaseOpsApi method testQuerySeries.

@Test
public void testQuerySeries() throws IOException {
    MemStorageEngine engine = new MemStorageEngine();
    engine.configure(new HashMap<>(), null);
    engine.startup();
    Builder dp = Point.newBuilder();
    dp.setDbName("test1");
    dp.addFp(false);
    dp.addValue(1L);
    dp.setMeasurementName("cpu");
    dp.setTimestamp(System.currentTimeMillis());
    dp.addAllTags(Arrays.asList(Tag.newBuilder().setTagKey("host").setTagValue("1").build(), Tag.newBuilder().setTagKey("vm").setTagValue("1").build()));
    dp.addValueFieldName("value");
    engine.writeDataPointWithLock(dp.build(), false);
    DatabaseOpsApi api = new DatabaseOpsApi(engine);
    String querySeries = api.querySeries("test1", "2000-12-10T10:10:10<cpu.value.host=1|te=2&vm=1<2020-12-10T10:10:10");
    JsonArray results = new Gson().fromJson(querySeries, JsonArray.class);
    assertEquals(1, results.size());
    querySeries = api.querySeries("test1", "2000-12-10T10:10:10<cpu.value.host=2<2020-12-10T10:10:10");
    results = new Gson().fromJson(querySeries, JsonArray.class);
    assertEquals(0, results.size());
    querySeries = api.querySeries("test1", "2000-12-10T10:10:10<cpu.value.vm=1<2020-12-10T10:10:10");
    results = new Gson().fromJson(querySeries, JsonArray.class);
    assertEquals(1, results.size());
    System.out.println(results);
}
Also used : JsonArray(com.google.gson.JsonArray) Builder(com.srotya.sidewinder.core.rpc.Point.Builder) MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 7 with MemStorageEngine

use of com.srotya.sidewinder.core.storage.mem.MemStorageEngine in project sidewinder by srotya.

the class TestGRPWriterServiceImpl method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    ScheduledExecutorService bgTaskPool = Executors.newScheduledThreadPool(1);
    engine = new MemStorageEngine();
    engine.configure(new HashMap<>(), bgTaskPool);
    int port = 50051;
    server = ServerBuilder.forPort(port).decompressorRegistry(DecompressorRegistry.getDefaultInstance()).addService(new WriterServiceImpl(engine, new HashMap<>())).build().start();
    System.out.println("Server started, listening on " + port);
    channel = ManagedChannelBuilder.forAddress("localhost", port).compressorRegistry(CompressorRegistry.getDefaultInstance()).usePlaintext(true).build();
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) BeforeClass(org.junit.BeforeClass)

Example 8 with MemStorageEngine

use of com.srotya.sidewinder.core.storage.mem.MemStorageEngine in project sidewinder by srotya.

the class TestMappedBitmapTagIndex method before.

@BeforeClass
public static void before() throws IOException {
    engine = new MemStorageEngine();
    engine.configure(new HashMap<>(), Executors.newScheduledThreadPool(1));
}
Also used : MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) BeforeClass(org.junit.BeforeClass)

Example 9 with MemStorageEngine

use of com.srotya.sidewinder.core.storage.mem.MemStorageEngine in project sidewinder by srotya.

the class TestTagIndices method beforeClass.

@BeforeClass
public static void beforeClass() throws IOException {
    engine = new MemStorageEngine();
    engine.configure(new HashMap<>(), Executors.newScheduledThreadPool(1));
}
Also used : MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) BeforeClass(org.junit.BeforeClass)

Example 10 with MemStorageEngine

use of com.srotya.sidewinder.core.storage.mem.MemStorageEngine in project sidewinder by srotya.

the class TestSchemaAndBasicQueries method testDatabaseSchemaFail.

@Test
public void testDatabaseSchemaFail() throws Exception {
    StorageEngine engine = new MemStorageEngine();
    engine.configure(new HashMap<>(), null);
    engine.getOrCreateMeasurement("db1", "m1");
    try {
        new SidewinderDatabaseSchema(engine, null, 100);
        fail("Must throw exception");
    } catch (Exception e) {
    }
}
Also used : SidewinderDatabaseSchema(com.srotya.sidewinder.core.sql.calcite.SidewinderDatabaseSchema) MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) MemStorageEngine(com.srotya.sidewinder.core.storage.mem.MemStorageEngine) StorageEngine(com.srotya.sidewinder.core.storage.StorageEngine) SQLException(java.sql.SQLException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

MemStorageEngine (com.srotya.sidewinder.core.storage.mem.MemStorageEngine)13 Test (org.junit.Test)7 StorageEngine (com.srotya.sidewinder.core.storage.StorageEngine)6 Connection (java.sql.Connection)4 ResultSet (java.sql.ResultSet)4 Statement (java.sql.Statement)4 BeforeClass (org.junit.BeforeClass)4 SidewinderDatabaseSchema (com.srotya.sidewinder.core.sql.calcite.SidewinderDatabaseSchema)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 SqlApi (com.srotya.sidewinder.core.api.SqlApi)1 Builder (com.srotya.sidewinder.core.rpc.Point.Builder)1 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)1 BackgrounThreadFactory (com.srotya.sidewinder.core.utils.BackgrounThreadFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1