Exemplo n.º 1
0
 public static void serialiseView(View view, ByteBuf buf) {
   buf.writeInt(view.id);
   buf.writeInt(view.members.size());
   for (Address addr : view.members) {
     AddressSerializer.INSTANCE.toBinary(addr, buf);
   }
 }
Exemplo n.º 2
0
 public static byte[] serialiseAddress(Address addr) {
   ByteBuf buf = Unpooled.buffer();
   AddressSerializer.INSTANCE.toBinary(addr, buf);
   byte[] bytes = new byte[buf.readableBytes()];
   buf.readBytes(bytes);
   buf.release();
   return bytes;
 }
Exemplo n.º 3
0
 public static View deserialiseView(ByteBuf buf) {
   int id = buf.readInt();
   int memsize = buf.readInt();
   ImmutableSortedSet.Builder<Address> addrs = ImmutableSortedSet.naturalOrder();
   for (int i = 0; i < memsize; i++) {
     Address addr = (Address) AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent());
     addrs.add(addr);
   }
   return new View(addrs.build(), id);
 }
Exemplo n.º 4
0
 public static Address deserialiseAddress(byte[] data) {
   ByteBuf buf = Unpooled.wrappedBuffer(data);
   Address addr = (Address) AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent());
   buf.release();
   return addr;
 }