use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class UtilTest method testWriteAddress.
public void testWriteAddress() throws Exception {
Address a1 = Util.createRandomAddress();
Address a2 = Util.createRandomAddress();
Address a4 = Util.createRandomAddress();
Address a5 = new IpAddress("127.0.0.1", 5555);
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(outstream);
Util.writeAddress(a1, dos);
Util.writeAddress(a2, dos);
Util.writeAddress(a4, dos);
Util.writeAddress(a5, dos);
dos.close();
byte[] buf = outstream.toByteArray();
ByteArrayInputStream instream = new ByteArrayInputStream(buf);
DataInputStream dis = new DataInputStream(instream);
Assert.assertEquals(a1, Util.readAddress(dis));
Assert.assertEquals(a2, Util.readAddress(dis));
Assert.assertEquals(a4, Util.readAddress(dis));
Address tmp = Util.readAddress(dis);
assert a5.equals(tmp);
}
use of org.jgroups.stack.IpAddress in project fabric8 by jboss-fuse.
the class KubernetesDiscovery method findKubernetesHosts.
public List<PhysicalAddress> findKubernetesHosts() {
List<PhysicalAddress> addresses = new ArrayList<>();
Map<String, String> labels = Collections.singletonMap(Constants.JGROUPS_CLUSTER_NAME, cluster_name);
for (Pod pod : client.pods().withLabels(labels).list().getItems()) {
List<Container> containers = KubernetesHelper.getContainers(pod);
for (Container container : containers) {
for (ContainerPort port : container.getPorts()) {
if (Constants.JGROUPS_TCP_PORT.equals(port.getName())) {
try {
String ip = pod.getStatus().getPodIP();
if (ip != null) {
addresses.add(new IpAddress(ip, port.getContainerPort()));
}
} catch (Exception ex) {
LOGGER.warn("Failed to create Address {}.", pod.getStatus().getPodIP());
}
}
}
}
}
return addresses;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class SizeTest method testFdHeaders.
public void testFdHeaders() throws Exception {
IpAddress a1 = new IpAddress("127.0.0.1", 5555);
IpAddress a2 = new IpAddress("127.0.0.1", 6666);
FD_SOCK.FdHeader sockhdr = new FD_SOCK.FdHeader(FD_SOCK.FdHeader.GET_CACHE);
_testSize(sockhdr);
sockhdr = new FD_SOCK.FdHeader(FD_SOCK.FdHeader.SUSPECT, new IpAddress("127.0.0.1", 5555));
_testSize(sockhdr);
Set<Address> tmp = Set.of(a1, a2);
sockhdr = new FD_SOCK.FdHeader(FD_SOCK.FdHeader.SUSPECT);
_testSize(sockhdr);
sockhdr.mbrs(tmp);
_testSize(sockhdr);
FD_SOCK2.FdHeader hdr = new FD_SOCK2.FdHeader(FD_SOCK2.FdHeader.SUSPECT);
_testSize(hdr);
hdr.mbrs(tmp);
_testSize(hdr);
hdr = new FD_SOCK2.FdHeader(FD_SOCK2.FdHeader.CONNECT_RSP);
hdr.serverAddress(a1);
_testSize(hdr);
hdr.cluster("demo");
_testSize(hdr);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class SizeTest method testIpAddressWithHighPort.
public static void testIpAddressWithHighPort() throws Exception {
IpAddress addr = new IpAddress("127.0.0.1", 65535);
_testSize(addr);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class SizeTest method testPingData.
public static void testPingData() throws Exception {
PingData data;
final Address a = Util.createRandomAddress("A");
final PhysicalAddress physical_addr = new IpAddress("127.0.0.1", 7500);
data = new PingData(null, false);
_testSize(data);
data = new PingData(a, true);
_testSize(data);
data = new PingData(a, true, "A", physical_addr).coord(true);
_testSize(data);
data = new PingData(a, true, "A", physical_addr).coord(true).mbrs(Arrays.asList(Util.createRandomAddress("A"), Util.createRandomAddress("B")));
_testSize(data);
}
Aggregations