public void writeTo(DataOutput out) throws Exception { out.writeByte(type.ordinal()); Bits.writeString(group, out); Util.writeAddress(addr, out); Util.writeAddress(sender, out); if(type != GossipType.MESSAGE) { Bits.writeString(logical_name, out); out.writeShort(ping_data != null? ping_data.size() : 0); if(ping_data != null) for(PingData data : ping_data) data.writeTo(out); Util.writeAddress(physical_addr, out); } out.writeInt(buffer != null? length : 0); if(buffer != null) out.write(buffer, offset, length); }
protected void readFrom(DataInput in, boolean read_type) throws Exception { if(read_type) type=GossipType.values()[in.readByte()]; group=Bits.readString(in); addr=Util.readAddress(in); sender=Util.readAddress(in); if(type != GossipType.MESSAGE) { logical_name=Bits.readString(in); short len=in.readShort(); if(len > 0) { ping_data=new ArrayList<>(len); for(int i=0; i < len; i++) { PingData data=new PingData(); data.readFrom(in); ping_data.add(data); } } physical_addr=(PhysicalAddress)Util.readAddress(in); } length=in.readInt(); if(length > 0) { buffer=new byte[length]; in.readFully(buffer, offset=0, length); } }
public void receive(Address sender, DataInput in) throws Exception { GossipType type=GossipType.values()[in.readByte()];
public void writeTo(DataOutput out) throws Exception { out.writeByte(type.ordinal()); Bits.writeString(group, out); Util.writeAddress(addr, out); Util.writeAddress(sender, out); if(type != GossipType.MESSAGE) { Bits.writeString(logical_name, out); out.writeShort(ping_data != null? ping_data.size() : 0); if(ping_data != null) for(PingData data : ping_data) data.writeTo(out); Util.writeAddress(physical_addr, out); } out.writeInt(buffer != null? length : 0); if(buffer != null) out.write(buffer, offset, length); }
GossipType type; try { type=GossipType.values()[in.readByte()]; in.position(Global.BYTE_SIZE);
protected void readFrom(DataInput in, boolean read_type) throws Exception { if(read_type) type=GossipType.values()[in.readByte()]; group=Bits.readString(in); addr=Util.readAddress(in); sender=Util.readAddress(in); if(type != GossipType.MESSAGE) { logical_name=Bits.readString(in); short len=in.readShort(); if(len > 0) { ping_data=new ArrayList<>(len); for(int i=0; i < len; i++) { PingData data=new PingData(); data.readFrom(in); ping_data.add(data); } } physical_addr=(PhysicalAddress)Util.readAddress(in); } length=in.readInt(); if(length > 0) { buffer=new byte[length]; in.readFully(buffer, offset=0, length); } }
public void receive(Address sender, DataInput in) throws Exception { GossipType type=GossipType.values()[in.readByte()];
GossipType type; try { type=GossipType.values()[in.readByte()]; in.position(Global.BYTE_SIZE);