Search in sources :

Example 1 with Node

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;
}
Also used : Element(org.w3c.dom.Element) MCElement(com.predic8.membrane.annot.MCElement)

Example 2 with Node

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());
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Example 3 with Node

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));
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Node(com.predic8.membrane.core.interceptor.balancer.Node) Request(com.predic8.membrane.core.http.Request) URIFactory(com.predic8.membrane.core.util.URIFactory)

Example 4 with Node

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);
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Node(com.predic8.membrane.core.interceptor.balancer.Node)

Example 5 with 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());
}
Also used : StringWriter(java.io.StringWriter) Node(com.predic8.membrane.core.interceptor.balancer.Node)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)5 Node (com.predic8.membrane.core.interceptor.balancer.Node)5 ContainerNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.ContainerNode)4 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)4 MCElement (com.predic8.membrane.annot.MCElement)3 Test (org.junit.Test)3 Element (org.w3c.dom.Element)3 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)2 Node (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.Node)2 RoundBracketNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.RoundBracketNode)2 SquareBracketNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.SquareBracketNode)2 StringNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.StringNode)2 UnparsedStringNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.UnparsedStringNode)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 Router (com.predic8.membrane.core.Router)1 EtcdNodeInformation (com.predic8.membrane.core.cloud.etcd.EtcdNodeInformation)1