org.apache.catalina.tribes.io.ChannelData Java Examples

The following examples show how to use org.apache.catalina.tribes.io.ChannelData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThroughputInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( access.addAndGet(1) == 1 ) txStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    try {
        super.sendMessage(destination, msg, payload);
    }catch ( ChannelException x ) {
        msgTxErr.addAndGet(1);
        if ( access.get() == 1 ) access.addAndGet(-1);
        throw x;
    }
    mbTx += (bytes*destination.length)/(1024d*1024d);
    mbAppTx += bytes/(1024d*1024d);
    if ( access.addAndGet(-1) == 0 ) {
        long stop = System.currentTimeMillis();
        timeTx += (stop - txStart) / 1000d;
        if ((msgTxCnt.get() / (double) interval) >= lastCnt) {
            lastCnt++;
            report(timeTx);
        }
    }
    msgTxCnt.addAndGet(1);
}
 
Example #2
Source File: ThroughputInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( access.addAndGet(1) == 1 ) txStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    try {
        super.sendMessage(destination, msg, payload);
    }catch ( ChannelException x ) {
        msgTxErr.addAndGet(1);
        if ( access.get() == 1 ) access.addAndGet(-1);
        throw x;
    } 
    mbTx += (bytes*destination.length)/(1024d*1024d);
    mbAppTx += bytes/(1024d*1024d);
    if ( access.addAndGet(-1) == 0 ) {
        long stop = System.currentTimeMillis();
        timeTx += (stop - txStart) / 1000d;
        if ((msgTxCnt.get() / interval) >= lastCnt) {
            lastCnt++;
            report(timeTx);
        }
    }
    msgTxCnt.addAndGet(1);
}
 
Example #3
Source File: McastService.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void broadcast(ChannelMessage message) throws ChannelException {
    if (impl==null || (impl.startLevel & Channel.MBR_TX_SEQ)!=Channel.MBR_TX_SEQ )
        throw new ChannelException("Multicast send is not started or enabled.");
    
    byte[] data = XByteBuffer.createDataPackage((ChannelData)message);
    if (data.length>McastServiceImpl.MAX_PACKET_SIZE) {
        throw new ChannelException("Packet length["+data.length+"] exceeds max packet size of "+McastServiceImpl.MAX_PACKET_SIZE+" bytes.");
    }
    DatagramPacket packet = new DatagramPacket(data,0,data.length);
    try {
        impl.send(false, packet);
    } catch (Exception x) {
        throw new ChannelException(x);
    }
}
 
Example #4
Source File: ThroughputInterceptor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( access.addAndGet(1) == 1 ) txStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    try {
        super.sendMessage(destination, msg, payload);
    }catch ( ChannelException x ) {
        msgTxErr.addAndGet(1);
        if ( access.get() == 1 ) access.addAndGet(-1);
        throw x;
    } 
    mbTx += (bytes*destination.length)/(1024d*1024d);
    mbAppTx += bytes/(1024d*1024d);
    if ( access.addAndGet(-1) == 0 ) {
        long stop = System.currentTimeMillis();
        timeTx += (stop - txStart) / 1000d;
        if ((msgTxCnt.get() / interval) >= lastCnt) {
            lastCnt++;
            report(timeTx);
        }
    }
    msgTxCnt.addAndGet(1);
}
 
Example #5
Source File: TestEncryptInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testPickup() throws Exception {
    File file = new File(MESSAGE_FILE);
    if(!file.exists()) {
        System.err.println("File message.bin does not exist. Skipping test.");
        return;
    }

    dest.start(Channel.SND_TX_SEQ);

    byte[] bytes = new byte[8192];
    int read;

    try (FileInputStream in = new FileInputStream(file)) {
        read = in.read(bytes);
    }

    ChannelData msg = new ChannelData(false);
    XByteBuffer xbb = new XByteBuffer(read, false);
    xbb.append(bytes, 0, read);
    msg.setMessage(xbb);

    dest.messageReceived(msg);
}
 
Example #6
Source File: TestEncryptInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testMessageUniqueness() throws Exception {
    src.start(Channel.SND_TX_SEQ);
    src.setNext(new ValueCaptureInterceptor());

    String testInput = "The quick brown fox jumps over the lazy dog.";

    ChannelData msg = new ChannelData(false);
    msg.setMessage(new XByteBuffer(testInput.getBytes("UTF-8"), false));
    src.sendMessage(null, msg, null);

    byte[] cipherText1 = ((ValueCaptureInterceptor)src.getNext()).getValue();

    msg.setMessage(new XByteBuffer(testInput.getBytes("UTF-8"), false));
    src.sendMessage(null, msg, null);

    byte[] cipherText2 = ((ValueCaptureInterceptor)src.getNext()).getValue();

    Assert.assertThat("Two identical cleartexts encrypt to the same ciphertext",
            cipherText1, IsNot.not(IsEqual.equalTo(cipherText2)));
}
 
Example #7
Source File: McastService.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void broadcast(ChannelMessage message) throws ChannelException {
    if (impl==null || (impl.startLevel & Channel.MBR_TX_SEQ)!=Channel.MBR_TX_SEQ )
        throw new ChannelException(sm.getString("mcastService.noStart"));

    byte[] data = XByteBuffer.createDataPackage((ChannelData)message);
    if (data.length>McastServiceImpl.MAX_PACKET_SIZE) {
        throw new ChannelException(sm.getString("mcastService.exceed.maxPacketSize",
                Integer.toString(data.length) ,
                Integer.toString(McastServiceImpl.MAX_PACKET_SIZE)));
    }
    DatagramPacket packet = new DatagramPacket(data,0,data.length);
    try {
        impl.send(false, packet);
    } catch (Exception x) {
        throw new ChannelException(x);
    }
}
 
Example #8
Source File: McastService.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void broadcast(ChannelMessage message) throws ChannelException {
    if (impl==null || (impl.startLevel & Channel.MBR_TX_SEQ)!=Channel.MBR_TX_SEQ )
        throw new ChannelException("Multicast send is not started or enabled.");
    
    byte[] data = XByteBuffer.createDataPackage((ChannelData)message);
    if (data.length>McastServiceImpl.MAX_PACKET_SIZE) {
        throw new ChannelException("Packet length["+data.length+"] exceeds max packet size of "+McastServiceImpl.MAX_PACKET_SIZE+" bytes.");
    }
    DatagramPacket packet = new DatagramPacket(data,0,data.length);
    try {
        impl.send(false, packet);
    } catch (Exception x) {
        throw new ChannelException(x);
    }
}
 
Example #9
Source File: NonBlockingCoordinator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public ChannelData createData(CoordinationMessage msg, MemberImpl local) {
    msg.write();
    ChannelData data = new ChannelData(true);
    data.setAddress(local);
    data.setMessage(msg.getBuffer());
    data.setOptions(Channel.SEND_OPTIONS_USE_ACK);
    data.setTimestamp(System.currentTimeMillis());
    return data;
}
 
Example #10
Source File: TcpPingInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected void sendPingMessage(Member[] members) {
    if ( members == null || members.length == 0 ) return;
    ChannelData data = new ChannelData(true);//generates a unique Id
    data.setAddress(getLocalMember(false));
    data.setTimestamp(System.currentTimeMillis());
    data.setOptions(getOptionFlag());
    data.setMessage(new XByteBuffer(TCP_PING_DATA, false));
    try {
        super.sendMessage(members, data, null);
    }catch (ChannelException x) {
        log.warn("Unable to send TCP ping.",x);
    }
}
 
Example #11
Source File: ThroughputInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( rxStart == 0 ) rxStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    mbRx += bytes/(1024d*1024d);
    msgRxCnt.addAndGet(1);
    if ( msgRxCnt.get() % interval == 0 ) report(timeTx);
    super.messageReceived(msg);
    
}
 
Example #12
Source File: StaticMembershipInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected void sendMemberMessage(Member[] members, byte[] message) throws ChannelException {
    if ( members == null || members.length == 0 ) return;
    ChannelData data = new ChannelData(true);
    data.setAddress(getLocalMember(false));
    data.setTimestamp(System.currentTimeMillis());
    data.setOptions(getOptionFlag());
    data.setMessage(new XByteBuffer(message, false));
    super.sendMessage(members, data, null);
}
 
Example #13
Source File: BioReplicationTask.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected void execute(ObjectReader reader) throws Exception{
    int pkgcnt = reader.count();

    if ( pkgcnt > 0 ) {
        ChannelMessage[] msgs = reader.execute();
        for ( int i=0; i<msgs.length; i++ ) {
            /**
             * Use send ack here if you want to ack the request to the remote 
             * server before completing the request
             * This is considered an asynchronized request
             */
            if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            try {
                //process the message
                getCallback().messageDataReceived(msgs[i]);
                /**
                 * Use send ack here if you want the request to complete on this
                 * server before sending the ack to the remote server
                 * This is considered a synchronized request
                 */
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            }catch  ( Exception x ) {
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND);
                log.error("Error thrown from messageDataReceived.",x);
            }
            if ( getUseBufferPool() ) {
                BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
                msgs[i].setMessage(null);
            }
        }                       
    }

   
}
 
Example #14
Source File: NioSenderTest.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public synchronized ChannelData getMessage(Member mbr) {
    String msg = "Thread-"+Thread.currentThread().getName()+" Message:"+inc();
    ChannelData data = new ChannelData(true);
    data.setMessage(new XByteBuffer(msg.getBytes(),false));
    data.setAddress(mbr);

    return data;
}
 
Example #15
Source File: SocketNioReceive.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Member mbr = new MemberImpl("localhost", 9999, 0);
    ChannelData data = new ChannelData();
    data.setAddress(mbr);
    byte[] buf = new byte[8192 * 4];
    data.setMessage(new XByteBuffer(buf, false));
    buf = XByteBuffer.createDataPackage(data);
    len = buf.length;
    NioReceiver receiver = new NioReceiver();
    receiver.setPort(9999);
    receiver.setHost("localhost");
    MyList list = new MyList();
    receiver.setMessageListener(list);
    receiver.start();
    System.out.println("Listening on 9999");
    while (true) {
        try {
            synchronized (mutex) {
                mutex.wait(5000);
                if ( start != 0 ) {
                    System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, messages "+count+" accepts "+accept+", total "+mb+" MB.");
                }
            }
        }catch (Throwable x) {
            x.printStackTrace();
        }
    }
}
 
Example #16
Source File: SocketNioReceive.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Member mbr = new MemberImpl("localhost", 9999, 0);
    ChannelData data = new ChannelData();
    data.setAddress(mbr);
    byte[] buf = new byte[8192 * 4];
    data.setMessage(new XByteBuffer(buf, false));
    buf = XByteBuffer.createDataPackage(data);
    len = buf.length;
    NioReceiver receiver = new NioReceiver();
    receiver.setPort(9999);
    receiver.setHost("localhost");
    MyList list = new MyList();
    receiver.setMessageListener(list);
    receiver.start();
    System.out.println("Listening on 9999");
    while (true) {
        try {
            synchronized (mutex) {
                mutex.wait(5000);
                if ( start != 0 ) {
                    System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, messages "+count+" accepts "+accept+", total "+mb+" MB.");
                }
            }
        }catch (Throwable x) {
            x.printStackTrace();
        }
    }
}
 
Example #17
Source File: BioReplicationTask.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected void execute(ObjectReader reader) throws Exception{
    int pkgcnt = reader.count();

    if ( pkgcnt > 0 ) {
        ChannelMessage[] msgs = reader.execute();
        for ( int i=0; i<msgs.length; i++ ) {
            /**
             * Use send ack here if you want to ack the request to the remote 
             * server before completing the request
             * This is considered an asynchronized request
             */
            if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            try {
                //process the message
                getCallback().messageDataReceived(msgs[i]);
                /**
                 * Use send ack here if you want the request to complete on this
                 * server before sending the ack to the remote server
                 * This is considered a synchronized request
                 */
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            }catch  ( Exception x ) {
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND);
                log.error("Error thrown from messageDataReceived.",x);
            }
            if ( getUseBufferPool() ) {
                BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
                msgs[i].setMessage(null);
            }
        }                       
    }

   
}
 
Example #18
Source File: NioSenderTest.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public synchronized ChannelData getMessage(Member mbr) {
    String msg = "Thread-"+Thread.currentThread().getName()+" Message:"+inc();
    ChannelData data = new ChannelData(true);
    data.setMessage(new XByteBuffer(msg.getBytes(),false));
    data.setAddress(mbr);

    return data;
}
 
Example #19
Source File: TcpPingInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected void sendPingMessage(Member[] members) {
    if ( members == null || members.length == 0 ) return;
    ChannelData data = new ChannelData(true);//generates a unique Id
    data.setAddress(getLocalMember(false));
    data.setTimestamp(System.currentTimeMillis());
    data.setOptions(getOptionFlag());
    data.setMessage(new XByteBuffer(TCP_PING_DATA, false));
    try {
        super.sendMessage(members, data, null);
    }catch (ChannelException x) {
        log.warn("Unable to send TCP ping.",x);
    }
}
 
Example #20
Source File: NonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public ChannelData createData(CoordinationMessage msg, MemberImpl local) {
    msg.write();
    ChannelData data = new ChannelData(true);
    data.setAddress(local);
    data.setMessage(msg.getBuffer());
    data.setOptions(Channel.SEND_OPTIONS_USE_ACK);
    data.setTimestamp(System.currentTimeMillis());
    return data;
}
 
Example #21
Source File: ThroughputInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( rxStart == 0 ) rxStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    mbRx += bytes/(1024d*1024d);
    msgRxCnt.addAndGet(1);
    if ( msgRxCnt.get() % interval == 0 ) report(timeTx);
    super.messageReceived(msg);
    
}
 
Example #22
Source File: ThroughputInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( rxStart == 0 ) rxStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    mbRx += bytes/(1024d*1024d);
    msgRxCnt.addAndGet(1);
    if ( msgRxCnt.get() % interval == 0 ) report(timeTx);
    super.messageReceived(msg);

}
 
Example #23
Source File: TcpFailureDetector.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected boolean memberAlive(Member mbr, byte[] msgData,
                                     boolean sendTest, boolean readTest,
                                     long readTimeout, long conTimeout,
                                     int optionFlag) {
    //could be a shutdown notification
    if ( Arrays.equals(mbr.getCommand(),Member.SHUTDOWN_PAYLOAD) ) return false;

    try (Socket socket = new Socket()) {
        InetAddress ia = InetAddress.getByAddress(mbr.getHost());
        InetSocketAddress addr = new InetSocketAddress(ia, mbr.getPort());
        socket.setSoTimeout((int)readTimeout);
        socket.connect(addr, (int) conTimeout);
        if ( sendTest ) {
            ChannelData data = new ChannelData(true);
            data.setAddress(getLocalMember(false));
            data.setMessage(new XByteBuffer(msgData,false));
            data.setTimestamp(System.currentTimeMillis());
            int options = optionFlag | Channel.SEND_OPTIONS_BYTE_MESSAGE;
            if ( readTest ) options = (options | Channel.SEND_OPTIONS_USE_ACK);
            else options = (options & (~Channel.SEND_OPTIONS_USE_ACK));
            data.setOptions(options);
            byte[] message = XByteBuffer.createDataPackage(data);
            socket.getOutputStream().write(message);
            if ( readTest ) {
                int length = socket.getInputStream().read(message);
                return length > 0;
            }
        }//end if
        return true;
    } catch (SocketTimeoutException | ConnectException | NoRouteToHostException noop) {
        //do nothing, we couldn't connect
    } catch (Exception x) {
        log.error(sm.getString("tcpFailureDetector.failureDetection.failed", mbr),x);
    }
    return false;
}
 
Example #24
Source File: NonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public ChannelData createData(CoordinationMessage msg, Member local) {
    msg.write();
    ChannelData data = new ChannelData(true);
    data.setAddress(local);
    data.setMessage(msg.getBuffer());
    data.setOptions(Channel.SEND_OPTIONS_USE_ACK);
    data.setTimestamp(System.currentTimeMillis());
    return data;
}
 
Example #25
Source File: TcpPingInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void sendPingMessage(Member[] members) {
    if ( members == null || members.length == 0 ) return;
    ChannelData data = new ChannelData(true);//generates a unique Id
    data.setAddress(getLocalMember(false));
    data.setTimestamp(System.currentTimeMillis());
    data.setOptions(getOptionFlag());
    data.setMessage(new XByteBuffer(TCP_PING_DATA, false));
    try {
        super.sendMessage(members, data, null);
    }catch (ChannelException x) {
        log.warn(sm.getString("tcpPingInterceptor.ping.failed"),x);
    }
}
 
Example #26
Source File: StaticMembershipInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void sendMemberMessage(Member[] members, byte[] message) throws ChannelException {
    if ( members == null || members.length == 0 ) return;
    ChannelData data = new ChannelData(true);
    data.setAddress(getLocalMember(false));
    data.setTimestamp(System.currentTimeMillis());
    data.setOptions(getOptionFlag());
    data.setMessage(new XByteBuffer(message, false));
    super.sendMessage(members, data, null);
}
 
Example #27
Source File: BioReplicationTask.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void execute(ObjectReader reader) throws Exception{
    int pkgcnt = reader.count();

    if ( pkgcnt > 0 ) {
        ChannelMessage[] msgs = reader.execute();
        for ( int i=0; i<msgs.length; i++ ) {
            /**
             * Use send ack here if you want to ack the request to the remote
             * server before completing the request
             * This is considered an asynchronous request
             */
            if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            try {
                //process the message
                getCallback().messageDataReceived(msgs[i]);
                /**
                 * Use send ack here if you want the request to complete on this
                 * server before sending the ack to the remote server
                 * This is considered a synchronized request
                 */
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
            }catch  ( Exception x ) {
                if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND);
                log.error(sm.getString("bioReplicationTask.messageDataReceived.error"),x);
            }
            if ( getUseBufferPool() ) {
                BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
                msgs[i].setMessage(null);
            }
        }
    }


}
 
Example #28
Source File: TestEncryptInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Actually go through the interceptor's send/receive message methods.
 */
private static byte[] roundTrip(byte[] input, EncryptInterceptor src, EncryptInterceptor dest) throws Exception {
    ChannelData msg = new ChannelData(false);
    msg.setMessage(new XByteBuffer(input, false));
    src.sendMessage(null, msg, null);

    return ((ValueCaptureInterceptor)dest.getPrevious()).getValue();
}
 
Example #29
Source File: SocketNioReceive.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Member mbr = new MemberImpl("localhost", 9999, 0);
    ChannelData data = new ChannelData();
    data.setAddress(mbr);
    byte[] buf = new byte[8192 * 4];
    data.setMessage(new XByteBuffer(buf, false));
    buf = XByteBuffer.createDataPackage(data);
    len = buf.length;
    NioReceiver receiver = new NioReceiver();
    receiver.setPort(9999);
    receiver.setHost("localhost");
    MyList list = new MyList();
    receiver.setMessageListener(list);
    receiver.start();
    System.out.println("Listening on 9999");
    while (true) {
        try {
            synchronized (mutex) {
                mutex.wait(5000);
                if ( start != 0 ) {
                    System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, messages "+count+" accepts "+accept+", total "+mb+" MB.");
                }
            }
        }catch (Throwable x) {
            x.printStackTrace();
        }
    }
}
 
Example #30
Source File: NioSenderTest.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public synchronized ChannelData getMessage(Member mbr) {
    String msg = "Thread-"+Thread.currentThread().getName()+" Message:"+inc();
    ChannelData data = new ChannelData(true);
    data.setMessage(new XByteBuffer(msg.getBytes(),false));
    data.setAddress(mbr);

    return data;
}