Search in sources :

Example 6 with LineTcpSender

use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.

the class LineTcpReceiverTest method testCrossingSymbolBoundary.

@Test
public void testCrossingSymbolBoundary() throws Exception {
    String tableName = "punk";
    int count = 2100;
    int startSymbolCount = 2040;
    int writeIterations = 4;
    runInContext((receiver) -> {
        int symbolCount = startSymbolCount;
        for (int it = 0; it < writeIterations; it++) {
            final int iteration = it;
            final int maxIds = symbolCount++;
            send(receiver, tableName, WAIT_ENGINE_TABLE_RELEASE, () -> {
                try (LineTcpSender sender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
                    for (int i = 0; i < count; i++) {
                        String id = String.valueOf(i % maxIds);
                        sender.metric(tableName).tag("id", id).$((iteration * count + i) * 10_000_000L);
                    }
                    sender.flush();
                }
            });
        }
    });
    try (TableReader reader = engine.getReader(AllowAllCairoSecurityContext.INSTANCE, tableName)) {
        Assert.assertEquals(count * writeIterations, reader.size());
    }
}
Also used : LineTcpSender(io.questdb.cutlass.line.LineTcpSender) AuthenticatedLineTcpSender(io.questdb.cutlass.line.AuthenticatedLineTcpSender) Test(org.junit.Test)

Example 7 with LineTcpSender

use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.

the class LineTcpReceiverTest method testTcpSenderQuotedTagValue.

@Test
public void testTcpSenderQuotedTagValue() throws Exception {
    runInContext((receiver) -> {
        send(receiver, "table", WAIT_ENGINE_TABLE_RELEASE, () -> {
            try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
                lineTcpSender.metric("table").tag("tag1", "\"value 1\"").$(0);
                lineTcpSender.flush();
            }
        });
        String expected = "tag1\ttimestamp\n" + "\"value 1\"\t1970-01-01T00:00:00.000000Z\n";
        assertTable(expected, "table");
    });
}
Also used : LineTcpSender(io.questdb.cutlass.line.LineTcpSender) AuthenticatedLineTcpSender(io.questdb.cutlass.line.AuthenticatedLineTcpSender) Test(org.junit.Test)

Example 8 with LineTcpSender

use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.

the class LineTcpReceiverTest method testWithTcpSender.

@Test
public void testWithTcpSender() throws Exception {
    runInContext((receiver) -> {
        send(receiver, "table", WAIT_ENGINE_TABLE_RELEASE, () -> {
            try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
                lineTcpSender.metric("table").tag("tag1", "value 1").tag("tag=2", "значение 2").field("поле=3", "{\"ключ\": \"число\"}").$(0);
                lineTcpSender.metric("table").tag("tag1", "value 2").$(0);
                lineTcpSender.metric("table").tag("tag 2", // Invalid column name, last line is not saved
                "value=\2").$(Timestamps.DAY_MICROS * 1000L);
                lineTcpSender.flush();
            }
        });
        String expected = "tag1\ttag=2\tполе=3\ttimestamp\n" + "value 1\tзначение 2\t{\"ключ\": \"число\"}\t1970-01-01T00:00:00.000000Z\n" + "value 2\t\t\t1970-01-01T00:00:00.000000Z\n";
        assertTable(expected, "table");
    });
}
Also used : LineTcpSender(io.questdb.cutlass.line.LineTcpSender) AuthenticatedLineTcpSender(io.questdb.cutlass.line.AuthenticatedLineTcpSender) Test(org.junit.Test)

Example 9 with LineTcpSender

use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.

the class LineTcpReceiverTest method testFirstRowIsCancelled.

@Test
public void testFirstRowIsCancelled() throws Exception {
    runInContext((receiver) -> {
        send(receiver, "table", WAIT_ENGINE_TABLE_RELEASE, () -> {
            try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
                lineTcpSender.metric("table").tag("tag 2", // Invalid column name, line is not saved
                "value=\2").$(0);
                lineTcpSender.metric("table").tag("tag1", "value 1").tag("tag=2", "значение 2").field("поле=3", "{\"ключ\": \"число\"}").$(0);
                lineTcpSender.metric("table").tag("tag1", "value 2").$(0);
                lineTcpSender.metric("table").tag("tag=2", "value=\\2").$(Timestamps.DAY_MICROS * 1000L);
                lineTcpSender.flush();
            }
        });
        String expected = "tag1\ttag=2\tполе=3\ttimestamp\n" + "value 1\tзначение 2\t{\"ключ\": \"число\"}\t1970-01-01T00:00:00.000000Z\n" + "value 2\t\t\t1970-01-01T00:00:00.000000Z\n" + "\tvalue=\\2\t\t1970-01-02T00:00:00.000000Z\n";
        assertTable(expected, "table");
    });
}
Also used : LineTcpSender(io.questdb.cutlass.line.LineTcpSender) AuthenticatedLineTcpSender(io.questdb.cutlass.line.AuthenticatedLineTcpSender) Test(org.junit.Test)

Example 10 with LineTcpSender

use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.

the class LineTcpReceiverTest method testTcpSenderManyLinesToForceBufferFlush.

@Test
public void testTcpSenderManyLinesToForceBufferFlush() throws Exception {
    int rowCount = 100;
    maxMeasurementSize = 100;
    runInContext((receiver) -> {
        String tableName = "table";
        send(receiver, tableName, WAIT_ENGINE_TABLE_RELEASE, () -> {
            try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, 64)) {
                for (int i = 0; i < rowCount; i++) {
                    lineTcpSender.metric(tableName).tag("tag1", "value 1").field("tag2", Chars.repeat("value 2", 10)).$(0);
                }
                lineTcpSender.flush();
            }
        });
        try (TableReader reader = engine.getReader(AllowAllCairoSecurityContext.INSTANCE, tableName)) {
            Assert.assertEquals(rowCount, reader.size());
        }
    });
}
Also used : LineTcpSender(io.questdb.cutlass.line.LineTcpSender) AuthenticatedLineTcpSender(io.questdb.cutlass.line.AuthenticatedLineTcpSender) Test(org.junit.Test)

Aggregations

LineTcpSender (io.questdb.cutlass.line.LineTcpSender)13 AuthenticatedLineTcpSender (io.questdb.cutlass.line.AuthenticatedLineTcpSender)11 Test (org.junit.Test)10 Rnd (io.questdb.std.Rnd)2 EntryLockedException (io.questdb.cairo.pool.ex.EntryLockedException)1 AbstractLineSender (io.questdb.cutlass.line.AbstractLineSender)1 SOCountDownLatch (io.questdb.mp.SOCountDownLatch)1 FilesFacade (io.questdb.std.FilesFacade)1 FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)1 Path (io.questdb.std.str.Path)1 StringSink (io.questdb.std.str.StringSink)1