/** * Called by a {@link Connection} implementation when a message has been received */ public void receive(Address sender, ByteBuffer buf) { if(this.receiver != null) this.receiver.receive(sender, buf); }
/** * Called by a {@link Connection} implementation when a message has been received. Note that data might be a * reused buffer, so unless used to de-serialize an object from it, it should be copied (e.g. if we store a ref * to it beyone the scope of this receive() method) */ public void receive(Address sender, byte[] data, int offset, int length) { if(this.receiver != null) this.receiver.receive(sender, data, offset, length); }
public void receive(Address sender, DataInput in, int len) throws Exception { if(this.receiver != null) this.receiver.receive(sender, in); else { // discard len bytes (in.skip() is not guaranteed to discard *all* len bytes) byte[] buf=new byte[len]; in.readFully(buf, 0, len); } }
public static void bufferToArray(final Address sender, final ByteBuffer buf, org.jgroups.blocks.cs.Receiver target) { if(buf == null) return; int offset=buf.hasArray()? buf.arrayOffset() + buf.position() : buf.position(), len=buf.remaining(); if(!buf.isDirect()) target.receive(sender, buf.array(), offset, len); else { // by default use a copy; but of course implementers of Receiver can override this byte[] tmp=new byte[len]; buf.get(tmp, 0, len); target.receive(sender, tmp, 0, len); } }
protected boolean _receive(boolean update) throws Exception { ByteBuffer msg; Receiver receiver=server.receiver(); if(peer_addr == null && server.usePeerConnections() && (peer_addr=readPeerAddress()) != null) { recv_buf=new Buffers(2).add(ByteBuffer.allocate(Global.INT_SIZE), null); server.addConnection(peer_addr, this); return true; } if((msg=recv_buf.readLengthAndData(channel)) == null) return false; if(receiver != null) receiver.receive(peer_addr, msg); if(update) updateLastAccessed(); return true; }
/** * Called by a {@link Connection} implementation when a message has been received. Note that data might be a * reused buffer, so unless used to de-serialize an object from it, it should be copied (e.g. if we store a ref * to it beyone the scope of this receive() method) */ public void receive(Address sender, byte[] data, int offset, int length) { if(this.receiver != null) this.receiver.receive(sender, data, offset, length); }
/** * Called by a {@link Connection} implementation when a message has been received */ public void receive(Address sender, ByteBuffer buf) { if(this.receiver != null) this.receiver.receive(sender, buf); }
public void receive(Address sender, DataInput in, int len) throws Exception { if(this.receiver != null) this.receiver.receive(sender, in); else { // discard len bytes (in.skip() is not guaranteed to discard *all* len bytes) byte[] buf=new byte[len]; in.readFully(buf, 0, len); } }
public static void bufferToArray(final Address sender, final ByteBuffer buf, org.jgroups.blocks.cs.Receiver target) { if(buf == null) return; int offset=buf.hasArray()? buf.arrayOffset() + buf.position() : buf.position(), len=buf.remaining(); if(!buf.isDirect()) target.receive(sender, buf.array(), offset, len); else { // by default use a copy; but of course implementers of Receiver can override this byte[] tmp=new byte[len]; buf.get(tmp, 0, len); target.receive(sender, tmp, 0, len); } }
protected boolean _receive(boolean update) throws Exception { ByteBuffer msg; Receiver receiver=server.receiver(); if(peer_addr == null && server.usePeerConnections() && (peer_addr=readPeerAddress()) != null) { recv_buf=new Buffers(2).add(ByteBuffer.allocate(Global.INT_SIZE), null); server.addConnection(peer_addr, this); return true; } if((msg=recv_buf.readLengthAndData(channel)) == null) return false; if(receiver != null) receiver.receive(peer_addr, msg); if(update) updateLastAccessed(); return true; }