use of io.questdb.cutlass.line.LineUdpSender in project questdb by bluestreak01.
the class LinuxLineUdpProtoReceiverTest method assertReceive.
private void assertReceive(LineUdpReceiverConfiguration receiverCfg, ReceiverFactory factory) throws Exception {
TestUtils.assertMemoryLeak(() -> {
final String expected = "colour\tshape\tsize\ttimestamp\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" + "blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n";
try (CairoEngine engine = new CairoEngine(configuration)) {
try (AbstractLineProtoUdpReceiver receiver = factory.create(receiverCfg, engine, null, false, null, metrics)) {
try (TableModel model = new TableModel(configuration, "tab", PartitionBy.NONE).col("colour", ColumnType.SYMBOL).col("shape", ColumnType.SYMBOL).col("size", ColumnType.DOUBLE).timestamp()) {
CairoTestUtils.create(model);
}
// warm writer up
try (TableWriter w = engine.getWriter(AllowAllCairoSecurityContext.INSTANCE, "tab", "testing")) {
w.warmUp();
}
receiver.start();
try (LineUdpSender sender = new LineUdpSender(NetworkFacadeImpl.INSTANCE, 0, Net.parseIPv4("127.0.0.1"), receiverCfg.getPort(), 1400, 1)) {
for (int i = 0; i < 10; i++) {
sender.metric("tab").tag("colour", "blue").tag("shape", "x square").field("size", 3.4).$(100000000000L);
}
sender.flush();
}
try (TableReader reader = new TableReader(new DefaultCairoConfiguration(root), "tab")) {
int count = 1000000;
while (true) {
if (count-- > 0 && reader.size() < 10) {
reader.reload();
LockSupport.parkNanos(1);
} else {
break;
}
}
Assert.assertTrue(count > 0);
receiver.close();
TestUtils.assertReader(expected, reader, sink);
}
}
}
});
}
use of io.questdb.cutlass.line.LineUdpSender in project questdb by bluestreak01.
the class LineUDPSenderMain method main.
public static void main(String[] args) {
final long count = 50_000_000;
String hostIPv4 = "127.0.0.1";
// 8089 influx
int port = 9009;
int ttl = 1;
// 1024 max
int bufferCapacity = 1024;
final Rnd rnd = new Rnd();
long start = System.nanoTime();
try (LineUdpSender sender = new LineUdpSender(0, Net.parseIPv4(hostIPv4), port, bufferCapacity, ttl)) {
for (int i = 0; i < count; i++) {
sender.metric("weather").tag("location", "london").tag("by", "quest").field("temp", rnd.nextPositiveLong()).field("ok", rnd.nextPositiveInt()).$(Os.currentTimeMicros() * 1000);
}
sender.flush();
}
System.out.println("Actual rate: " + (count * 1_000_000_000L / (System.nanoTime() - start)));
}
Aggregations