use of org.apache.storm.messaging.IContext in project storm by apache.
the class NettyTest method connectToFixedPort.
private void connectToFixedPort(Map<String, Object> stormConf, int port) throws Exception {
LOG.info("7. Should be able to rebind to a port quickly");
String reqMessage = "0123456789abcdefghijklmnopqrstuvwxyz";
IContext context = TransportFactory.makeContext(stormConf, null);
try {
AtomicReference<TaskMessage> response = new AtomicReference<>();
try (IConnection server = context.bind(null, port, mkConnectionCallback(response::set), null);
IConnection client = context.connect(null, "localhost", server.getPort(), remoteBpStatus)) {
waitUntilReady(client, server);
byte[] messageBytes = reqMessage.getBytes(StandardCharsets.UTF_8);
send(client, taskId, messageBytes);
waitForNotNull(response);
TaskMessage responseMessage = response.get();
assertThat(responseMessage.task(), is(taskId));
assertThat(responseMessage.message(), is(messageBytes));
}
} finally {
context.term();
}
}
use of org.apache.storm.messaging.IContext in project storm by apache.
the class NettyTest method doTestLargeMessage.
private void doTestLargeMessage(Map<String, Object> stormConf) throws Exception {
LOG.info("3 Should send and receive a large message");
String reqMessage = StringUtils.repeat("c", 2_048_000);
IContext context = TransportFactory.makeContext(stormConf, null);
try {
AtomicReference<TaskMessage> response = new AtomicReference<>();
try (IConnection server = context.bind(null, 0, mkConnectionCallback(response::set), null);
IConnection client = context.connect(null, "localhost", server.getPort(), remoteBpStatus)) {
waitUntilReady(client, server);
byte[] messageBytes = reqMessage.getBytes(StandardCharsets.UTF_8);
send(client, taskId, messageBytes);
waitForNotNull(response);
TaskMessage responseMessage = response.get();
assertThat(responseMessage.task(), is(taskId));
assertThat(responseMessage.message(), is(messageBytes));
}
} finally {
context.term();
}
}
Aggregations