Search in sources :

Example 16 with ByteArrayDataOutputStream

use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.

the class NoBundler method send.

public void send(Message msg) throws Exception {
    ByteArrayDataOutputStream out = new ByteArrayDataOutputStream((int) (msg.size() + 10));
    sendSingleMessage(msg, out);
}
Also used : ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream)

Example 17 with ByteArrayDataOutputStream

use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.

the class AsyncNoBundler method send.

@Override
public void send(final Message msg) throws Exception {
    Runnable async_send = () -> {
        ByteArrayDataOutputStream out = new ByteArrayDataOutputStream((int) (msg.size() + 10));
        sendSingleMessage(msg, out);
    };
    thread_pool.execute(async_send);
}
Also used : ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream)

Example 18 with ByteArrayDataOutputStream

use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.

the class BPING method sendMcastDiscoveryRequest.

@Override
protected void sendMcastDiscoveryRequest(Message msg) {
    try {
        if (msg.getSrc() == null)
            msg.setSrc(local_addr);
        ByteArrayDataOutputStream out = new ByteArrayDataOutputStream((int) msg.size());
        msg.writeTo(out);
        for (int i = bind_port; i <= bind_port + port_range; i++) {
            DatagramPacket packet = new DatagramPacket(out.buffer(), 0, out.position(), dest_addr, i);
            sock.send(packet);
        }
    } catch (Exception ex) {
        log.error(Util.getMessage("FailedSendingDiscoveryRequest"), ex);
    }
}
Also used : DatagramPacket(java.net.DatagramPacket) ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream) SocketException(java.net.SocketException)

Example 19 with ByteArrayDataOutputStream

use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.

the class BaseBundler method init.

public void init(TP transport) {
    this.transport = transport;
    log = transport.getLog();
    output = new ByteArrayDataOutputStream(transport.getMaxBundleSize() + MSG_OVERHEAD);
}
Also used : ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream)

Example 20 with ByteArrayDataOutputStream

use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.

the class TUNNEL method send.

@Override
protected void send(Message msg, Address dest) throws Exception {
    // we don't currently support message bundling in TUNNEL
    TpHeader hdr = msg.getHeader(this.id);
    if (hdr == null)
        throw new Exception("message " + msg + " doesn't have a transport header, cannot route it");
    String group = cluster_name != null ? cluster_name.toString() : null;
    ByteArrayDataOutputStream dos = new ByteArrayDataOutputStream((int) (msg.size() + 50));
    Util.writeMessage(msg, dos, dest == null);
    if (stats) {
        msg_stats.incrNumMsgsSent(1);
        msg_stats.incrNumBytesSent(dos.position());
    }
    if (dest == null)
        tunnel_policy.sendToAllMembers(group, local_addr, dos.buffer(), 0, dos.position());
    else
        tunnel_policy.sendToSingleMember(group, dest, local_addr, dos.buffer(), 0, dos.position());
}
Also used : ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream) UnknownHostException(java.net.UnknownHostException)

Aggregations

ByteArrayDataOutputStream (org.jgroups.util.ByteArrayDataOutputStream)33 ByteArrayDataInputStream (org.jgroups.util.ByteArrayDataInputStream)19 IpAddress (org.jgroups.stack.IpAddress)3 Buffers (org.jgroups.nio.Buffers)2 MockSocketChannel (org.jgroups.nio.MockSocketChannel)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 DatagramPacket (java.net.DatagramPacket)1 SocketException (java.net.SocketException)1 UnknownHostException (java.net.UnknownHostException)1 ByteBuffer (java.nio.ByteBuffer)1 Address (org.jgroups.Address)1 IpAddressUUID (org.jgroups.stack.IpAddressUUID)1