use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class AsciiStringTest method testCreation.
public void testCreation() {
String orig = "hello";
AsciiString str = new AsciiString(orig);
assert str.length() == orig.length();
assert str.toString().equals(orig);
AsciiString str2 = new AsciiString(str);
assert str2.equals(str);
assert str2.length() == str.length();
byte[] tmp = { 'h', 'e', 'l', 'l', 'o' };
str2 = new AsciiString(tmp);
assert str2.equals(str);
assert str2.length() == str.length();
assert str.equals(tmp);
assert str.equals(str.chars());
tmp = null;
assert !str.equals(tmp);
}
use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class BitsTest method testAsciiStringByteBuffer.
public void testAsciiStringByteBuffer() throws Exception {
AsciiString[] strings = { null, new AsciiString("hello world"), new AsciiString("1") };
for (AsciiString str : strings) {
ByteBuffer buf = marshallToByteBuffer(str);
buf.rewind();
AsciiString s = unmarshallAsciiString(buf);
assert str == null && s == null || str.equals(s);
}
}
use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class SHARED_LOOPBACK method dumpRoutingTable.
@ManagedOperation(description = "Dumps the contents of the routing table")
public static String dumpRoutingTable() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<AsciiString, Map<Address, SHARED_LOOPBACK>> entry : routing_table.entrySet()) {
AsciiString cluster_name = entry.getKey();
Set<Address> mbrs = entry.getValue().keySet();
sb.append(cluster_name).append(": ").append(mbrs).append("\n");
}
return sb.toString();
}
use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class SHARED_LOOPBACK method getDiscoveryResponsesFor.
public static List<PingData> getDiscoveryResponsesFor(String cluster_name) {
if (cluster_name == null)
return null;
Map<Address, SHARED_LOOPBACK> mbrs = routing_table.get(new AsciiString(cluster_name));
List<PingData> rsps = new ArrayList<>(mbrs != null ? mbrs.size() : 0);
if (mbrs != null) {
for (Map.Entry<Address, SHARED_LOOPBACK> entry : mbrs.entrySet()) {
Address addr = entry.getKey();
SHARED_LOOPBACK slp = entry.getValue();
PingData data = new PingData(addr, slp.isServer(), NameCache.get(addr), null).coord(slp.isCoord());
rsps.add(data);
}
}
return rsps;
}
use of org.jgroups.util.AsciiString in project JGroups by belaban.
the class AsciiStringTest method testCompareTo.
public void testCompareTo() {
AsciiString str = new AsciiString("hello"), str2 = new AsciiString("hello world");
int comp = str.compareTo(str2);
assert comp < 0;
}
Aggregations