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);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class DefaultDNSResolverTest method test_parsing_srv_entries.
@Test
public void test_parsing_srv_entries() throws Exception {
// given
MockDirContext mockDirContext = MockDirContext.newDefault().addEntry("test", "10 100 8888 9089f34a.jgroups-dns-ping.local.", DNSResolver.DNSRecordType.SRV).addEntry("9089f34a.jgroups-dns-ping.local", "192.168.0.1", DNSResolver.DNSRecordType.A).addEntry("9089f34a.jgroups-dns-ping.local", "192.168.0.2", DNSResolver.DNSRecordType.A);
DefaultDNSResolver resolver = new DefaultDNSResolver(mockDirContext);
// when
List<Address> addresses = resolver.resolveIps("test", DNSResolver.DNSRecordType.SRV);
// then
List<Address> expectedResults = Arrays.asList(new IpAddress("192.168.0.1"), new IpAddress("192.168.0.2"));
Assert.assertEquals(addresses, expectedResults);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testCopy.
public void testCopy() {
IpAddress tmp = a.copy();
assert tmp.equals(a);
tmp = j.copy();
assert tmp.equals(j);
}
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 keycloak by keycloak.
the class TopologyInfo method getRouteName.
/**
* Get route to be used as the identifier for sticky session. Return null if I am not able to find the appropriate route (or in case of local mode)
*/
public String getRouteName(Cache cache, Object key) {
if (cache.getCacheConfiguration().clustering().cacheMode().isClustered() && isGeneratedNodeName) {
logger.warn("Clustered configuration used, but node name is not properly set. Make sure to start server with jboss.node.name property identifying cluster node");
}
if (isGeneratedNodeName) {
return null;
}
// Impl based on Wildfly sticky session algorithm for generating routes ( org.wildfly.clustering.web.infinispan.session.InfinispanRouteLocator )
Address address = getOwnerAddress(cache, key);
// Local mode
if (address == null || (address == LocalModeAddress.INSTANCE)) {
return myNodeName;
}
org.jgroups.Address jgroupsAddress = toJGroupsAddress(address);
String name = NameCache.get(jgroupsAddress);
// If no logical name exists, create one using physical address
if (name == null) {
Transport transport = cache.getCacheManager().getTransport();
JChannel jgroupsChannel = ((JGroupsTransport) transport).getChannel();
IpAddress ipAddress = (IpAddress) jgroupsChannel.down(new Event(Event.GET_PHYSICAL_ADDRESS, jgroupsAddress));
// Physical address might be null if node is no longer a member of the cluster
InetSocketAddress socketAddress = (ipAddress != null) ? new InetSocketAddress(ipAddress.getIpAddress(), ipAddress.getPort()) : new InetSocketAddress(0);
name = String.format("%s:%s", socketAddress.getHostString(), socketAddress.getPort());
logger.debugf("Address not found in NameCache. Fallback to %s", name);
}
return name;
}
Aggregations