protected static final Message readMessage(DataInput in) throws Exception { short ver=in.readShort(); byte flags=in.readByte(); // final boolean multicast=(flags & (byte)2) == (byte)2; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
public static Message readMessage(DataInput instream) throws Exception { Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(instream); return msg; }
public static Message byteBufferToMessage(byte[] buffer,int offset,int length) throws Exception { DataInput in=new ByteArrayDataInputStream(buffer,offset,length); if(!in.readBoolean()) return null; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
public void run() { // System.out.printf("[%s] reading from sock, conn: %s\n", Thread.currentThread().getName(), this); try { int len=in.readInt(); if(buffer == null || buffer.length < len) buffer=new byte[len]; in.readFully(buffer, 0, len); ByteArrayDataInputStream input=new ByteArrayDataInputStream(buffer, 0, len); Message msg=new Message(false); msg.readFrom(input); thread_pool.execute(() -> up_prot.up(msg)); } catch(IOException io_ex) { runner.stop(); throw new RuntimeException(io_ex); } catch(Exception ex) { if(sock.isClosed()) runner.stop(); throw new RuntimeException(ex); } }
protected static Message readMessage(byte[] buf, int offset, int length) throws Exception { ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length); short ver=in.readShort(); byte flags=in.readByte(); // final boolean multicast=(flags & (byte)2) == (byte)2; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
public static List<Message> readMessageList(DataInput in, short transport_id) throws Exception { List<Message> list=new LinkedList<>(); Address dest=Util.readAddress(in); Address src=Util.readAddress(in); // AsciiString cluster_name=Bits.readAsciiString(in); // not used here short length=in.readShort(); byte[] cluster_name=length >= 0? new byte[length] : null; if(cluster_name != null) in.readFully(cluster_name, 0, cluster_name.length); int len=in.readInt(); for(int i=0; i < len; i++) { Message msg=new Message(false); msg.readFrom(in); msg.setDest(dest); if(msg.getSrc() == null) msg.setSrc(src); // Now add a TpHeader back on, was not marshalled. Every message references the *same* TpHeader, saving memory ! msg.putHeader(transport_id, new TpHeader(cluster_name)); list.add(msg); } return list; }
public void run() { final byte[] receive_buf=new byte[65535]; DatagramPacket packet=new DatagramPacket(receive_buf, receive_buf.length); DataInput inp; while(sock != null && receiver != null && Thread.currentThread().equals(receiver)) { packet.setData(receive_buf, 0, receive_buf.length); try { sock.receive(packet); inp=new ByteArrayDataInputStream(packet.getData(), packet.getOffset(), packet.getLength()); Message msg=new Message(); msg.readFrom(inp); up(msg); } catch(SocketException socketEx) { break; } catch(Throwable ex) { log.error(Util.getMessage("FailedReceivingPacketFrom"), packet.getSocketAddress(), ex); } } if(log.isTraceEnabled()) log.trace("receiver thread terminated"); }
public void run() { final byte[] receive_buf=new byte[65535]; DatagramPacket packet=new DatagramPacket(receive_buf, receive_buf.length); while(mcast_sock != null && receiver != null && Thread.currentThread().equals(receiver)) { packet.setData(receive_buf, 0, receive_buf.length); try { mcast_sock.receive(packet); DataInput inp=new ByteArrayDataInputStream(packet.getData(), packet.getOffset(), packet.getLength()); Message msg=new Message(); msg.readFrom(inp); if(!Objects.equals(local_addr,msg.getSrc())) // discard discovery request from self up(msg); } catch(SocketException socketEx) { break; } catch(Throwable ex) { log.error(Util.getMessage("FailedReceivingPacketFrom"), packet.getSocketAddress(), ex); } } log.debug("receiver thread terminated"); }
protected void handleSingleMessage(DataInput in, boolean multicast) { try { Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); if(!multicast && unicastDestMismatch(msg.getDest())) return; boolean oob=msg.isFlagSet(Message.Flag.OOB), internal=msg.isFlagSet(Message.Flag.INTERNAL); msg_processing_policy.process(msg, oob, internal); } catch(Throwable t) { log.error(String.format(Util.getMessage("IncomingMsgFailure"), local_addr), t); } }
for(int i=0; i < len; i++) { Message msg=new Message(false); msg.readFrom(in); msg.setDest(dest); if(msg.getSrc() == null)
DataInput in=new ByteArrayDataInputStream(buf); Message assembled_msg=new Message(false); assembled_msg.readFrom(in);
public static Message readMessage(DataInput instream) throws Exception { Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(instream); return msg; }
protected static final Message readMessage(DataInput in) throws Exception { short ver=in.readShort(); byte flags=in.readByte(); // final boolean multicast=(flags & (byte)2) == (byte)2; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
public static Message byteBufferToMessage(byte[] buffer,int offset,int length) throws Exception { DataInput in=new ByteArrayDataInputStream(buffer,offset,length); if(!in.readBoolean()) return null; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
private Message readMessage(DataInputStream instream, Address dest, Address sender, boolean multicast) throws Exception { Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(instream); postUnmarshalling(msg, dest, sender, multicast); // allows for optimization by subclass return msg; }
public void handlePingRequest(InputStream stream) throws Exception { DataInputStream dataInput = new DataInputStream(stream); Message msg = new Message(); msg.readFrom(dataInput); try { sendUp(msg); } catch (Exception e) { log.error("Error processing GET_MBRS_REQ.", e); } }
private List<Message> readMessageList(DataInputStream instream, Address dest, boolean multicast) throws Exception { List<Message> list=new LinkedList<Message>(); int len; Message msg; Address src; len=instream.readInt(); src=Util.readAddress(instream); for(int i=0; i < len; i++) { msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(instream); postUnmarshallingList(msg, dest, multicast); msg.setSrc(src); list.add(msg); } return list; }
public void handlePingRequest(InputStream stream) throws Exception { DataInputStream dataInput = new DataInputStream(stream); Message msg = new Message(); msg.readFrom(dataInput); try { up(new Event(Event.MSG, msg)); } catch (Exception e) { log.error("Error processing GET_MBRS_REQ.", e); } }
protected static Message readMessage(byte[] buf, int offset, int length) throws Exception { ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length); short ver=in.readShort(); byte flags=in.readByte(); // final boolean multicast=(flags & (byte)2) == (byte)2; Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); return msg; }
protected void handleSingleMessage(DataInput in, boolean multicast) { try { Message msg=new Message(false); // don't create headers, readFrom() will do this msg.readFrom(in); if(!multicast && unicastDestMismatch(msg.getDest())) return; boolean oob=msg.isFlagSet(Message.Flag.OOB), internal=msg.isFlagSet(Message.Flag.INTERNAL); msg_processing_policy.process(msg, oob, internal); } catch(Throwable t) { log.error(String.format(Util.getMessage("IncomingMsgFailure"), local_addr), t); } }