Search in sources :

Example 1 with WriterServiceBlockingStub

use of com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub in project sidewinder by srotya.

the class TestGRPWriterServiceImpl method testPointWritesRejects.

@Test
public void testPointWritesRejects() throws Exception {
    WriterServiceBlockingStub client = WriterServiceGrpc.newBlockingStub(channel);
    long sts = 1497720452566L;
    String dbName = "test3";
    String measurementName = "cpu4";
    List<Point> points = Arrays.asList(Point.newBuilder().setDbName(dbName).setFp(false).setMeasurementName(measurementName).addTags("host=1").setTimestamp(sts).setValue(1L).setValueFieldName("usage").build(), Point.newBuilder().setDbName(dbName).setFp(true).setMeasurementName(measurementName).addTags("host=1").setTimestamp(sts + 1).setValue(2L).setValueFieldName("usage").build());
    try {
        Ack response = client.writeBatchDataPoint(BatchData.newBuilder().setMessageId(sts).addAllPoints(points).build());
        if (response.getResponseCode() == 200) {
            fail("Exception must be thrown");
        }
    } catch (Exception e) {
    }
    // second data point should have been rejected
    assertTrue(engine.checkIfExists(dbName));
    assertTrue(engine.checkIfExists(dbName, measurementName));
    assertEquals("host", engine.getTagKeysForMeasurement(dbName, measurementName).iterator().next());
    List<Series> result = engine.queryDataPoints(dbName, measurementName, "usage", sts, sts + 1, null);
    assertEquals(1, result.size());
    assertEquals(1, result.iterator().next().getDataPoints().size());
    assertEquals(1L, result.iterator().next().getDataPoints().iterator().next().getLongValue());
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) WriterServiceBlockingStub(com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub) Test(org.junit.Test)

Example 2 with WriterServiceBlockingStub

use of com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub in project sidewinder by srotya.

the class TestGRPWriterServiceImpl method testMultiDataPointWrites.

// @Test
public void testMultiDataPointWrites() throws Exception {
    WriterServiceBlockingStub client = WriterServiceGrpc.newBlockingStub(channel);
    long sts = 1497720452566L;
    String dbName = "test2";
    String measurementName = "cpu";
    List<Point> points = Arrays.asList(Point.newBuilder().setDbName(dbName).setFp(false).setMeasurementName(measurementName).addTags("host=1").setTimestamp(sts).setValue(1L).setValueFieldName("usage").build(), Point.newBuilder().setDbName(dbName).setFp(false).setMeasurementName(measurementName).addTags("host=1").setTimestamp(sts + 1).setValue(2L).setValueFieldName("usage").build());
    client.writeBatchDataPoint(BatchData.newBuilder().setMessageId(sts).addAllPoints(points).build());
    assertTrue(engine.checkIfExists(dbName));
    assertTrue(engine.checkIfExists(dbName, measurementName));
    assertEquals("host=1", engine.getTagKeysForMeasurement(dbName, measurementName).iterator().next());
    List<Series> result = engine.queryDataPoints(dbName, measurementName, "usage", sts, sts + 1, null);
    assertEquals(1, result.size());
    assertEquals(2, result.iterator().next().getDataPoints().size());
    assertEquals(1L, result.iterator().next().getDataPoints().iterator().next().getLongValue());
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) WriterServiceBlockingStub(com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub)

Example 3 with WriterServiceBlockingStub

use of com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub in project sidewinder by srotya.

the class TestGRPWriterServiceImpl method testSingleDataPointWrites.

// @Test
public void testSingleDataPointWrites() throws Exception {
    WriterServiceBlockingStub client = WriterServiceGrpc.newBlockingStub(channel);
    long sts = 1497720452566L;
    Point point = Point.newBuilder().setDbName("test").setFp(false).setMeasurementName("cpu").addTags("host=1").setTimestamp(sts).setValue(1L).setValueFieldName("usage").build();
    client.writeSingleDataPoint(SingleData.newBuilder().setMessageId(point.getTimestamp()).setPoint(point).build());
    assertTrue(engine.checkIfExists("test"));
    assertTrue(engine.checkIfExists("test", "cpu"));
    assertEquals("host=1", engine.getTagKeysForMeasurement("test", "cpu").iterator().next());
    List<Series> result = engine.queryDataPoints("test", "cpu", "usage", sts, sts + 1, null);
    assertEquals(1, result.size());
    assertEquals(1, result.iterator().next().getDataPoints().size());
    assertEquals(1L, result.iterator().next().getDataPoints().iterator().next().getLongValue());
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) WriterServiceBlockingStub(com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub)

Aggregations

WriterServiceBlockingStub (com.srotya.sidewinder.core.rpc.WriterServiceGrpc.WriterServiceBlockingStub)3 Series (com.srotya.sidewinder.core.storage.Series)3 Test (org.junit.Test)1