Search in sources :

Example 1 with MCMPConfig

use of io.undertow.server.handlers.proxy.mod_cluster.MCMPConfig in project undertow by undertow-io.

the class ModClusterProxyServer method main.

public static void main(final String[] args) throws IOException {
    final XnioWorker worker = Xnio.getInstance().createWorker(OptionMap.EMPTY);
    final Undertow server;
    final ModCluster modCluster = ModCluster.builder(worker).build();
    try {
        if (chost == null) {
            // We are going to guess it.
            chost = java.net.InetAddress.getLocalHost().getHostName();
            System.out.println("Using: " + chost + ":" + cport);
        }
        modCluster.start();
        // Create the proxy and mgmt handler
        final HttpHandler proxy = modCluster.createProxyHandler();
        final MCMPConfig config = MCMPConfig.webBuilder().setManagementHost(chost).setManagementPort(cport).enableAdvertise().getParent().build();
        final HttpHandler mcmp = config.create(modCluster, proxy);
        server = Undertow.builder().addHttpListener(cport, chost).addHttpListener(pport, phost).setHandler(mcmp).build();
        server.start();
        // Start advertising the mcmp handler
        modCluster.advertise(config);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HttpHandler(io.undertow.server.HttpHandler) ModCluster(io.undertow.server.handlers.proxy.mod_cluster.ModCluster) XnioWorker(org.xnio.XnioWorker) MCMPConfig(io.undertow.server.handlers.proxy.mod_cluster.MCMPConfig) Undertow(io.undertow.Undertow) IOException(java.io.IOException)

Aggregations

Undertow (io.undertow.Undertow)1 HttpHandler (io.undertow.server.HttpHandler)1 MCMPConfig (io.undertow.server.handlers.proxy.mod_cluster.MCMPConfig)1 ModCluster (io.undertow.server.handlers.proxy.mod_cluster.ModCluster)1 IOException (java.io.IOException)1 XnioWorker (org.xnio.XnioWorker)1