use of com.predic8.membrane.core.interceptor.balancer.Node in project service-proxy by membrane.
the class AuthHead2BodyInterceptor method getPassword.
private Node getPassword(Document doc, Element header) {
Element e = doc.createElement("password");
e.appendChild(doc.createTextNode(((Element) doc.getElementsByTagNameNS(COM_NS, "password").item(0)).getTextContent()));
e.setAttributeNS(XSI_NS, "xsi:type", "xsd:string");
return e;
}
use of com.predic8.membrane.core.interceptor.balancer.Node in project service-proxy by membrane.
the class NodeOnlineCheckerTest method testExchangeWithException.
@Test
public void testExchangeWithException() {
Node node = new Node("http://www.predic8.de", 80);
Exchange exc = new Exchange(null);
exc.getDestinations().add(0, "http://www.predic8.de:80");
exc.setNodeException(0, new Exception());
LoadBalancingInterceptor lbi = new LoadBalancingInterceptor();
Cluster cl = lbi.getClusterManager().getClusters().get(0);
cl.nodeUp(node);
assertEquals(Node.Status.UP, cl.getNode(node).getStatus());
NodeOnlineChecker noc = new NodeOnlineChecker();
lbi.setNodeOnlineChecker(noc);
noc.handle(exc);
assertEquals(Node.Status.DOWN, cl.getNode(node).getStatus());
}
use of com.predic8.membrane.core.interceptor.balancer.Node in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method doTestGetDestinationURL.
private void doTestGetDestinationURL(String requestUri, String expectedUri) throws URISyntaxException {
Exchange exc = new Exchange(null);
exc.setRequest(new Request());
exc.getRequest().setUri(URLUtil.getPathQuery(new URIFactory(), requestUri));
exc.setOriginalRequestUri(requestUri);
assertEquals(expectedUri, new Node("thomas-bayer.com", 80).getDestinationURL(exc));
}
use of com.predic8.membrane.core.interceptor.balancer.Node in project service-proxy by membrane.
the class EtcdBasedConfigurator method setUpClusterNode.
private void setUpClusterNode(EtcdNodeInformation node) {
log.info("Creating " + node);
ServiceProxy sp = runningServiceProxyForModule.get(node.getModule());
LoadBalancingInterceptor lbi = (LoadBalancingInterceptor) sp.getInterceptors().get(0);
lbi.getClusterManager().getClusters().get(0).nodeUp(new Node(node.getTargetHost(), Integer.parseInt(node.getTargetPort())));
runningNodesForModule.get(node.getModule()).add(node);
}
use of com.predic8.membrane.core.interceptor.balancer.Node in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleNodeSessionsRequest.
@Mapping("/admin/node/sessions/?(\\?.*)?")
public Response handleNodeSessionsRequest(final Map<String, String> params, String relativeRootPath) throws Exception {
StringWriter writer = new StringWriter();
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_LOAD_BALANCING;
}
@Override
protected void createTabContent() throws Exception {
h2().text("Node " + params.get("host") + ":" + params.get("port")).end();
h3().text("Sessions").end();
createSessionsTable(BalancerUtil.lookupBalancer(router, getBalancerParam(params)).getSessionsByNode(params.get("cluster"), new Node(params.get("host"), Integer.parseInt(params.get("port")))));
}
}.createPage());
}
Aggregations