use of org.apache.nifi.remote.protocol.DataPacket in project nifi by apache.
the class TestHttpClient method testSendSuccessCompressed.
@Test
public void testSendSuccessCompressed() throws Exception {
try (SiteToSiteClient client = getDefaultBuilder().portName("input-running").useCompression(true).build()) {
final Transaction transaction = client.createTransaction(TransferDirection.SEND);
assertNotNull(transaction);
serverChecksum = "1071206772";
for (int i = 0; i < 20; i++) {
DataPacket packet = new DataPacketBuilder().contents("Example contents from client.").attr("Client attr 1", "Client attr 1 value").attr("Client attr 2", "Client attr 2 value").build();
transaction.send(packet);
long written = ((Peer) transaction.getCommunicant()).getCommunicationsSession().getBytesWritten();
logger.info("{}: {} bytes have been written.", i, written);
}
transaction.confirm();
transaction.complete();
}
}
use of org.apache.nifi.remote.protocol.DataPacket in project nifi by apache.
the class TestHttpClient method testSendTimeout.
@Test
public void testSendTimeout() throws Exception {
// skip on windows
assumeFalse(isWindowsEnvironment());
try (SiteToSiteClient client = getDefaultBuilder().timeout(1, TimeUnit.SECONDS).portName("input-timeout").build()) {
final Transaction transaction = client.createTransaction(TransferDirection.SEND);
assertNotNull(transaction);
DataPacket packet = new DataPacketBuilder().contents("Example contents from client.").attr("Client attr 1", "Client attr 1 value").attr("Client attr 2", "Client attr 2 value").build();
serverChecksum = "1345413116";
transaction.send(packet);
try {
transaction.confirm();
fail();
} catch (IOException e) {
logger.info("An exception was thrown as expected.", e);
assertTrue(e.getMessage().contains("TimeoutException"));
}
completeShouldFail(transaction);
}
}
use of org.apache.nifi.remote.protocol.DataPacket in project nifi by apache.
the class TestHttpClient method testReceive.
private void testReceive(SiteToSiteClient client) throws IOException {
final Transaction transaction = client.createTransaction(TransferDirection.RECEIVE);
assertNotNull(transaction);
DataPacket packet;
while ((packet = transaction.receive()) != null) {
consumeDataPacket(packet);
}
transaction.confirm();
transaction.complete();
}
use of org.apache.nifi.remote.protocol.DataPacket in project nifi by apache.
the class TestHttpClient method testSend.
private void testSend(SiteToSiteClient client) throws Exception {
testSendIgnoreProxyError(client, transaction -> {
serverChecksum = "1071206772";
for (int i = 0; i < 20; i++) {
DataPacket packet = new DataPacketBuilder().contents("Example contents from client.").attr("Client attr 1", "Client attr 1 value").attr("Client attr 2", "Client attr 2 value").build();
transaction.send(packet);
long written = ((Peer) transaction.getCommunicant()).getCommunicationsSession().getBytesWritten();
logger.info("{}: {} bytes have been written.", i, written);
}
});
}
use of org.apache.nifi.remote.protocol.DataPacket in project nifi by apache.
the class TestHttpClient method testSendLargeFile.
private static void testSendLargeFile(SiteToSiteClient client) throws IOException {
testSendIgnoreProxyError(client, transaction -> {
serverChecksum = "1527414060";
final int contentSize = 10_000;
final StringBuilder sb = new StringBuilder(contentSize);
for (int i = 0; i < contentSize; i++) {
sb.append("a");
}
DataPacket packet = new DataPacketBuilder().contents(sb.toString()).attr("Client attr 1", "Client attr 1 value").attr("Client attr 2", "Client attr 2 value").build();
transaction.send(packet);
long written = ((Peer) transaction.getCommunicant()).getCommunicationsSession().getBytesWritten();
logger.info("{} bytes have been written.", written);
});
}
Aggregations