Search in sources :

Example 1 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testResize.

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));
    }
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 2 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testMarshalling.

public void testMarshalling() throws Exception {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A").setFlag((short) 16).setFlag((short) 32);
    uuid.put("name", Util.objectToByteBuffer("Bela")).put("age", Util.objectToByteBuffer(49)).put("bool", Util.objectToByteBuffer(true));
    int size = uuid.serializedSize();
    byte[] buffer = Util.streamableToByteBuffer(uuid);
    assert size == buffer.length : "expected size of " + size + ", but got " + buffer.length;
    ExtendedUUID uuid2 = Util.streamableFromByteBuffer(ExtendedUUID::new, buffer);
    assert uuid2.isFlagSet((short) 16);
    assert uuid2.isFlagSet((short) 32);
    for (String key : Arrays.asList("name", "age", "bool")) assert uuid2.keyExists(key);
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 3 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testRemove.

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);
    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));
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 4 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project JGroups by belaban.

the class ExtendedUUIDTest method testMarshallingLargeValues.

public void testMarshallingLargeValues() throws Exception {
    ExtendedUUID uuid = ExtendedUUID.randomUUID("A");
    for (int i = 1; i <= 5; i++) uuid.put(String.valueOf(i), new byte[250]);
    System.out.println("uuid = " + uuid);
    int size = uuid.serializedSize();
    byte[] buffer = Util.streamableToByteBuffer(uuid);
    assert size == buffer.length : "expected size of " + size + ", but got " + buffer.length;
    ExtendedUUID uuid2 = Util.streamableFromByteBuffer(ExtendedUUID::new, buffer);
    System.out.println("uuid2 = " + uuid2);
    for (int i = 1; i <= 5; i++) {
        byte[] val = uuid.get(String.valueOf(i));
        assert val != null && val.length == 250;
    }
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Example 5 with ExtendedUUID

use of org.jgroups.util.ExtendedUUID in project wildfly by wildfly.

the class TopologyAddressGenerator method generateAddress.

@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;
}
Also used : ExtendedUUID(org.jgroups.util.ExtendedUUID)

Aggregations

ExtendedUUID (org.jgroups.util.ExtendedUUID)14