Search in sources :

Example 6 with WriteFuture

use of org.apache.mina.core.future.WriteFuture in project streamsx.topology by IBMStreams.

the class TesterSink method processBatch.

@Override
protected boolean processBatch(Queue<BatchedTuple> batch) throws Exception {
    List<WriteFuture> futures = new ArrayList<>(batch.size());
    for (BatchedTuple bt : batch) {
        int portIndex = bt.getStream().getPortNumber();
        TCPTestClient client = clients[portIndex];
        BinaryEncoding be = encoders[portIndex];
        byte[] tupleData = new byte[(int) be.getEncodedSize(bt.getTuple())];
        be.encodeTuple(bt.getTuple(), ByteBuffer.wrap(tupleData));
        TestTuple tt = new TestTuple(portIndex, tupleData);
        futures.add(client.writeTuple(tt));
    }
    for (WriteFuture future : futures) {
        future.await();
    }
    return false;
}
Also used : TCPTestClient(com.ibm.streamsx.topology.internal.tester.tcp.TCPTestClient) WriteFuture(org.apache.mina.core.future.WriteFuture) TestTuple(com.ibm.streamsx.topology.internal.tester.tcp.TestTuple) ArrayList(java.util.ArrayList) BinaryEncoding(com.ibm.streams.operator.encoding.BinaryEncoding)

Aggregations

WriteFuture (org.apache.mina.core.future.WriteFuture)6 IOException (java.io.IOException)3 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 BinaryEncoding (com.ibm.streams.operator.encoding.BinaryEncoding)1 TCPTestClient (com.ibm.streamsx.topology.internal.tester.tcp.TCPTestClient)1 TestTuple (com.ibm.streamsx.topology.internal.tester.tcp.TestTuple)1 ConnectException (java.net.ConnectException)1 UnresolvedAddressException (java.nio.channels.UnresolvedAddressException)1 ArrayList (java.util.ArrayList)1 CamelExchangeException (org.apache.camel.CamelExchangeException)1 DecoderException (org.apache.directory.api.asn1.DecoderException)1 MessageEncoderException (org.apache.directory.api.ldap.codec.api.MessageEncoderException)1 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)1 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)1 LdapNoPermissionException (org.apache.directory.api.ldap.model.exception.LdapNoPermissionException)1 LdapOperationException (org.apache.directory.api.ldap.model.exception.LdapOperationException)1 LdapOtherException (org.apache.directory.api.ldap.model.exception.LdapOtherException)1 UnbindRequest (org.apache.directory.api.ldap.model.message.UnbindRequest)1 UnbindRequestImpl (org.apache.directory.api.ldap.model.message.UnbindRequestImpl)1