use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class BuffersTest method testRead3.
public void testRead3() throws Exception {
byte[] cookie = { 'b', 'e', 'l', 'a' };
IpAddress addr = new IpAddress(7500);
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream();
addr.writeTo(out);
MockSocketChannel ch = new MockSocketChannel().bytesToRead((ByteBuffer) ByteBuffer.allocate(cookie.length + Global.SHORT_SIZE + out.position()).put(cookie).putShort(Version.version).put(out.buffer(), 0, out.position()).flip());
int remaining = ch.bytesToRead().remaining();
ch.bytesToRead().limit(remaining - 10);
Buffers bufs = new Buffers(ByteBuffer.allocate(cookie.length), ByteBuffer.allocate(Global.SHORT_SIZE), ByteBuffer.allocate(out.position()));
boolean rc = bufs.read(ch);
assert !rc;
ch.bytesToRead().limit(remaining - 2);
rc = bufs.read(ch);
assert !rc;
ch.bytesToRead().limit(remaining);
rc = bufs.read(ch);
assert rc;
readCookieVersionAndAddress(bufs, cookie, addr);
}
use of org.jgroups.stack.IpAddress in project fabric8 by fabric8io.
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 wildfly by wildfly.
the class AddressSerializerTestCase method test.
private static void test(Tester<Address> tester) throws IOException {
UUID uuid = UUID.randomUUID();
InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), Short.MAX_VALUE);
IpAddress ipAddress = new IpAddress(address);
IpAddressUUID ipAddressUUID = new IpAddressUUID(address);
tester.test(uuid);
tester.test(ipAddress);
tester.test(ipAddressUUID);
}
Aggregations