use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.
the class LineTcpReceiverTest method testTcpSenderWithSpaceInTableName.
@Test
public void testTcpSenderWithSpaceInTableName() throws Exception {
runInContext((receiver) -> {
String tableName = "ta ble";
send(receiver, tableName, WAIT_ENGINE_TABLE_RELEASE, () -> {
try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
lineTcpSender.metric(tableName).tag("tag1", "value 1").field("tag2", "value 2").$(0);
lineTcpSender.flush();
}
});
String expected = "tag1\ttag2\ttimestamp\n" + "value 1\tvalue 2\t1970-01-01T00:00:00.000000Z\n";
assertTable(expected, tableName);
});
}
use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.
the class LineTcpReceiverTest method testTcpSenderWithNewLineInTableName.
@Test
public void testTcpSenderWithNewLineInTableName() throws Exception {
if (engine.getConfiguration().getFilesFacade().isRestrictedFileSystem()) {
// Windows (NTFS) cannot crate files with new line in file name.
return;
}
runInContext((receiver) -> {
String tableName = "ta\nble";
send(receiver, tableName, WAIT_ENGINE_TABLE_RELEASE, () -> {
try (LineTcpSender lineTcpSender = new LineTcpSender(Net.parseIPv4("127.0.0.1"), bindPort, msgBufferSize)) {
lineTcpSender.metric(tableName).tag("tag1", "value 1").field("tag2", "value 2").$(0);
lineTcpSender.flush();
}
});
String expected = "tag1\ttag2\ttimestamp\n" + "value 1\tvalue 2\t1970-01-01T00:00:00.000000Z\n";
assertTable(expected, tableName);
});
}
use of io.questdb.cutlass.line.LineTcpSender in project questdb by bluestreak01.
the class LineTCPSenderMainVarLenStrings method main.
public static void main(String[] args) {
final long count = 2_000_000_000L;
String hostIPv4 = "127.0.0.1";
int port = 9009;
int bufferCapacity = 64;
final Rnd rnd = new Rnd();
long start = System.nanoTime();
FilesFacade ff = new FilesFacadeImpl();
try (Path path = new Path()) {
long logFd = -1;
if (args.length == 1) {
path.put(args[0]).$();
logFd = ff.openRW(path);
}
try (LineTcpSender sender = new LoggingLineTcpSender(Net.parseIPv4(hostIPv4), port, bufferCapacity, logFd, ff)) {
for (int i = 0; i < count; i++) {
sender.metric("md_msgs");
sender.field("ts_nsec", rnd.nextPositiveLong()).field("pkt_size", rnd.nextPositiveInt()).field("pcap_file", nextString(rnd.nextPositiveInt() % 64, rnd)).field("raw_msg", nextString(rnd.nextPositiveInt() % 512, rnd)).field("Length", rnd.nextInt()).field("MsgSeqNum", i).field("MsgType", rnd.nextInt() % 1000).field("src_ip", rnd.nextString(rnd.nextPositiveInt() % 16)).field("dst_ip", rnd.nextString(rnd.nextPositiveInt() % 16)).field("src_port", rnd.nextInt() % 10000).field("dst_port", rnd.nextInt() % 10000).field("first_dir", rnd.nextBoolean()).$(i * 10_000_000L);
}
sender.flush();
} finally {
if (logFd > 0) {
ff.close(logFd);
}
}
}
System.out.println("Actual rate: " + (count * 1_000_000_000L / (System.nanoTime() - start)));
}
Aggregations