Package org.jgroups.util

Examples of org.jgroups.util.ExtendedUUID


      }

      @Override
      public JGroupsTopologyAwareAddress readObject(ObjectInput unmarshaller) throws IOException, ClassNotFoundException {
         try {
            ExtendedUUID jgroupsAddress = (ExtendedUUID) org.jgroups.util.Util.readAddress(unmarshaller);
            return new JGroupsTopologyAwareAddress(jgroupsAddress);
         } catch (Exception e) {
            throw new IOException(e);
         }
      }
View Full Code Here


        this.topology = topology;
    }

    @Override
    public Address generateAddress() {
        ExtendedUUID uuid = ExtendedUUID.randomUUID();
        uuid.put(SITE, Util.stringToBytes(this.topology.getSite()));
        uuid.put(RACK, Util.stringToBytes(this.topology.getRack()));
        uuid.put(MACHINE, Util.stringToBytes(this.topology.getMachine()));
        return uuid;
    }
View Full Code Here

      }

      @Override
      public JGroupsTopologyAwareAddress readObject(ObjectInput unmarshaller) throws IOException, ClassNotFoundException {
         try {
            ExtendedUUID jgroupsAddress = (ExtendedUUID) org.jgroups.util.Util.readAddress(unmarshaller);
            return new JGroupsTopologyAwareAddress(jgroupsAddress);
         } catch (Exception e) {
            throw new IOException(e);
         }
      }
View Full Code Here

*/
@Test(groups=Global.FUNCTIONAL)
public class ExtendedUUIDTest {

    public void testCreation() {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A").setFlag(ExtendedUUID.site_master);
        System.out.println("uuid = " + uuid);
    }
View Full Code Here

        ExtendedUUID uuid=ExtendedUUID.randomUUID("A").setFlag(ExtendedUUID.site_master);
        System.out.println("uuid = " + uuid);
    }

    public void testFlags() {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A").setFlag(ExtendedUUID.site_master).setFlag((short)2).setFlag((short)4);
        System.out.println("uuid = " + uuid);
        assert uuid.isFlagSet(ExtendedUUID.site_master);
        assert uuid.isFlagSet((short)2);
        assert uuid.isFlagSet((short)4);
        uuid.clearFlag((short)2);
        assert !uuid.isFlagSet((short)2);
    }
View Full Code Here

        uuid.clearFlag((short)2);
        assert !uuid.isFlagSet((short)2);
    }

    public void testPut() throws Exception {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A").put("name", Util.objectToByteBuffer("Bela"))
          .put("age",Util.objectToByteBuffer(49)).put("bool",Util.objectToByteBuffer(true));
        System.out.println("uuid = " + uuid);
        assert uuid.keyExists("name");
        assert uuid.keyExists("bool");
        byte[] val=uuid.get("age");
        assert Util.objectFromByteBuffer(val).equals(49);
    }
View Full Code Here

        byte[] val=uuid.get("age");
        assert Util.objectFromByteBuffer(val).equals(49);
    }

    public void testAddContents() throws Exception {
        ExtendedUUID a=ExtendedUUID.randomUUID("A").setFlag((short)1).put("name",Util.stringToBytes("Bela"))
          .put("age",Util.objectToByteBuffer(49)).put("bool",Util.objectToByteBuffer(true));
        ExtendedUUID b=ExtendedUUID.randomUUID("B").setFlag((short)2).setFlag((short)4)
          .put("one",null).put("two",Util.stringToBytes("two")).put("name", Util.stringToBytes("Michelle"));
        a.addContents(b);
        System.out.println("a = " + a);
        for(short flag: Arrays.asList((short)1,(short)2, (short)4))
            assert a.isFlagSet(flag);
View Full Code Here

        assert Util.bytesToString(a.get("name")).equals("Bela");
    }


    public void testRemove() throws Exception {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A");
        byte[] val=Util.objectToByteBuffer("tmp");
        for(int i=1; i <= 10; i++)
            uuid.put(String.valueOf(i), val);
        System.out.println("uuid = " + uuid);

        byte[] tmp=uuid.remove(String.valueOf(5));
        assert tmp != null && Arrays.equals(tmp, val);

        tmp=uuid.get(String.valueOf(5));
        assert tmp == null;

        tmp=uuid.get(String.valueOf(7));
        assert tmp != null && Arrays.equals(tmp, val);

        uuid.remove(String.valueOf(7));
        assert uuid.keyExists(String.valueOf(8));
    }
View Full Code Here

        uuid.remove(String.valueOf(7));
        assert uuid.keyExists(String.valueOf(8));
    }

    public void testResize() throws Exception {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A");
        byte[] val=Util.objectToByteBuffer("tmp");
        for(int i=1000; i <= 1005; i++) {
            uuid.put(String.valueOf(i), val);
            assert uuid.keyExists(String.valueOf(i));
        }
        System.out.println("uuid = " + uuid);
    }
View Full Code Here

        }
        System.out.println("uuid = " + uuid);
    }

    public void testResizeBeyond255() throws Exception {
        ExtendedUUID uuid=ExtendedUUID.randomUUID("A");
        byte[] val=Util.objectToByteBuffer("tmp");
        for(int i=1; i <= 0xff; i++)
            uuid.put(String.valueOf(i), val);
        System.out.println("uuid = " + uuid);

        try {
            uuid.put(String.valueOf(256), val);
            assert false : " should have thrown an exception";
        }
        catch(ArrayIndexOutOfBoundsException ex) {
            System.out.println("got exception as expected: " + ex);
        }
View Full Code Here

TOP

Related Classes of org.jgroups.util.ExtendedUUID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.