Search in sources :

Example 1 with Topology

use of org.wildfly.swarm.topology.Topology in project wildfly-swarm by wildfly-swarm.

the class ArqTopologyJGroupsTest method testIt.

@Test
public void testIt() throws Exception {
    Topology topology = Topology.lookup();
    assertThat(topology).isNotNull();
}
Also used : Topology(org.wildfly.swarm.topology.Topology) Test(org.junit.Test)

Example 2 with Topology

use of org.wildfly.swarm.topology.Topology in project wildfly-swarm by wildfly-swarm.

the class ArqTopologyOpenShiftTest method testIt.

@Test
public void testIt() throws Exception {
    Topology topology = Topology.lookup();
    assertThat(topology).isNotNull();
}
Also used : Topology(org.wildfly.swarm.topology.Topology) Test(org.junit.Test)

Example 3 with Topology

use of org.wildfly.swarm.topology.Topology in project wildfly-swarm by wildfly-swarm.

the class ArqTopologyConsulTest method testIt.

@Test
public void testIt() throws Exception {
    Topology topology = Topology.lookup();
    assertThat(topology).isNotNull();
}
Also used : Topology(org.wildfly.swarm.topology.Topology) Test(org.junit.Test)

Example 4 with Topology

use of org.wildfly.swarm.topology.Topology in project wildfly-swarm by wildfly-swarm.

the class TopologyProxyService method start.

@Override
public void start(StartContext context) throws StartException {
    try {
        Topology topology = Topology.lookup();
        topology.addListener(this);
    } catch (NamingException ex) {
        throw new StartException(ex);
    }
}
Also used : NamingException(javax.naming.NamingException) StartException(org.jboss.msc.service.StartException) Topology(org.wildfly.swarm.topology.Topology)

Example 5 with Topology

use of org.wildfly.swarm.topology.Topology in project wildfly-swarm by wildfly-swarm.

the class TopologyProxyService method updateProxyHosts.

private void updateProxyHosts(String serviceName, List<Topology.Entry> entries) {
    HttpHandler proxyHandler = proxyHandlerMap.get(serviceName).getOptionalValue();
    if (proxyHandler == null) {
        // Service has been shutdown
        proxyHandlerMap.remove(serviceName);
        return;
    }
    LoadBalancingProxyClient proxyClient = null;
    // which then wraps the next handler in the chain
    if (proxyHandler instanceof GlobalRequestControllerHandler) {
        // next in the chain of handlers
        ProxyHandler proxy = (ProxyHandler) ((GlobalRequestControllerHandler) proxyHandler).getNext();
        proxyClient = (LoadBalancingProxyClient) proxy.getProxyClient();
    } else {
        proxyClient = (LoadBalancingProxyClient) ((ProxyHandler) proxyHandler).getProxyClient();
    }
    List<Topology.Entry> oldEntries = proxyEntries.get(serviceName);
    List<Topology.Entry> entriesToRemove = new ArrayList<>();
    List<Topology.Entry> entriesToAdd = new ArrayList<>();
    if (oldEntries == null) {
        entriesToAdd.addAll(entries);
    } else {
        for (Topology.Entry oldEntry : oldEntries) {
            if (!entries.contains(oldEntry)) {
                entriesToRemove.add(oldEntry);
            }
        }
        for (Topology.Entry entry : entries) {
            if (!oldEntries.contains(entry)) {
                entriesToAdd.add(entry);
            }
        }
    }
    for (Topology.Entry entry : entriesToRemove) {
        try {
            proxyClient.removeHost(entryToURI(entry));
        } catch (URISyntaxException ex) {
            log.log(Level.WARNING, "Error converting topology entry to URI", ex);
        }
    }
    for (Topology.Entry entry : entriesToAdd) {
        try {
            proxyClient.addHost(entryToURI(entry));
        } catch (URISyntaxException ex) {
            log.log(Level.WARNING, "Error converting topology entry to URI", ex);
        }
    }
    proxyEntries.put(serviceName, entries);
}
Also used : HttpHandler(io.undertow.server.HttpHandler) GlobalRequestControllerHandler(org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler) ProxyHandler(io.undertow.server.handlers.proxy.ProxyHandler) ArrayList(java.util.ArrayList) Topology(org.wildfly.swarm.topology.Topology) URISyntaxException(java.net.URISyntaxException) LoadBalancingProxyClient(io.undertow.server.handlers.proxy.LoadBalancingProxyClient)

Aggregations

Topology (org.wildfly.swarm.topology.Topology)5 Test (org.junit.Test)3 HttpHandler (io.undertow.server.HttpHandler)1 LoadBalancingProxyClient (io.undertow.server.handlers.proxy.LoadBalancingProxyClient)1 ProxyHandler (io.undertow.server.handlers.proxy.ProxyHandler)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 NamingException (javax.naming.NamingException)1 StartException (org.jboss.msc.service.StartException)1 GlobalRequestControllerHandler (org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler)1