示例#1
0
文件: GMS.java 项目: jtoerber/JGroups
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type);
   boolean isMergeView = view != null && view instanceof MergeView;
   out.writeBoolean(isMergeView);
   Util.writeStreamable(view, out);
   Util.writeAddress(mbr, out);
   Util.writeAddresses(mbrs, out);
   Util.writeStreamable(join_rsp, out);
   Util.writeStreamable(my_digest, out);
   Util.writeStreamable(merge_id, out);
   out.writeBoolean(merge_rejected);
   out.writeBoolean(useFlushIfPresent);
 }
示例#2
0
  public static void testWriteView() throws Exception {
    List<Address> members = new ArrayList<>();
    View v;
    Address a1 = Util.createRandomAddress();
    Address a2 = Util.createRandomAddress();
    Address a4 = Util.createRandomAddress();
    ViewId vid = new ViewId(a1, 12345);
    members.add(a1);
    members.add(a2);
    members.add(a4);
    v = new View(vid, members);

    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(outstream);
    Util.writeGenericStreamable(v, dos);
    Util.writeStreamable(v, dos);
    dos.close();
    byte[] buf = outstream.toByteArray();
    ByteArrayInputStream instream = new ByteArrayInputStream(buf);
    DataInputStream dis = new DataInputStream(instream);
    View v2 = (View) Util.readGenericStreamable(dis);
    Assert.assertEquals(v, v2);
    v2 = (View) Util.readStreamable(View.class, dis);
    Assert.assertEquals(v, v2);
  }