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();
}
}
Aggregations