Java Code Examples for org.wildfly.swarm.topology.Topology#Entry

The following examples show how to use org.wildfly.swarm.topology.Topology#Entry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopologyProxyService.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void onChange(Topology topology) {
    Map<String, List<Topology.Entry>> topologyMap = topology.asMap();
    for (String serviceName : serviceNames) {
        if (topologyMap.containsKey(serviceName)) {
            updateProxyHosts(serviceName, topologyMap.get(serviceName));
        } else {
            // All instances of this service went away
            updateProxyHosts(serviceName, Collections.emptyList());
        }
    }
}
 
Example 2
Source File: TopologyProxyService.java    From thorntail with Apache License 2.0 5 votes vote down vote up
private URI entryToURI(Topology.Entry entry) throws URISyntaxException {
    List<String> tags = entry.getTags();
    String scheme = "http";
    if (tags.contains("https")) {
        scheme = "https";
    }
    return new URI(scheme, null, entry.getAddress(), entry.getPort(), null, null, null);
}
 
Example 3
Source File: App.java    From drools-workshop with Apache License 2.0 4 votes vote down vote up
public static void printTopology(Topology lookup) {
    Map<String, List<Topology.Entry>> asMap = lookup.asMap();
    for (String key : asMap.keySet()) {
        System.out.println("Key: " + key + " - Value: " + asMap.get(key));
    }
}
 
Example 4
Source File: App.java    From drools-workshop with Apache License 2.0 4 votes vote down vote up
public static void printTopology(Topology lookup){
    Map<String, List<Topology.Entry>> asMap = lookup.asMap();
    for(String key : asMap.keySet()){
        System.out.println("Key: "+ key + " - Value: "+asMap.get(key));
    }
}
 
Example 5
Source File: App.java    From drools-workshop with Apache License 2.0 4 votes vote down vote up
public static void printTopology(Topology lookup){
    Map<String, List<Topology.Entry>> asMap = lookup.asMap();
    for(String key : asMap.keySet()){
        System.out.println("Key: "+ key + " - Value: "+asMap.get(key));
    }
}
 
Example 6
Source File: TopologySSEServlet.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
protected String topologyToJson(int externalPort) {
    StringBuilder json = new StringBuilder();

    json.append("{");

    Map<String, List<Topology.Entry>> map = this.topology.asMap();

    Set<String> keys = map.keySet();
    Iterator<String> keyIter = keys.iterator();

    while (keyIter.hasNext()) {
        String key = keyIter.next();
        json.append("  ").append('"').append(key).append('"').append(": [");
        List<Topology.Entry> list = map.get(key);
        Iterator<Topology.Entry> listIter = list.iterator();
        while (listIter.hasNext()) {
            Topology.Entry server = listIter.next();
            server = this.externalAddressMapper.toExternal(server, externalPort);
            json.append("{");
            json.append("\"endpoint\": \"").append(server.getAddress() + ":" + server.getPort()).append("\",");
            json.append("\"tags\":[");

            List<String> tags = server.getTags();
            Iterator<String> tagIter = tags.iterator();
            while ( tagIter.hasNext() ) {
                String tag = tagIter.next();
                json.append("\"").append(tag).append("\"");
                if ( tagIter.hasNext() ) {
                    json.append(",");
                }
            }
            json.append("]");
            json.append("}");
            if (listIter.hasNext()) {
                json.append(",");
            }
        }
        json.append("]");
        if (keyIter.hasNext()) {
            json.append(",");
        }
    }

    json.append("}\n\n");

    return json.toString();
}
 
Example 7
Source File: IdentityExternalAddressMapper.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
@Override
public Topology.Entry toExternal(Topology.Entry internalServer, int defaultPort) {
    return internalServer;
}