use of com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.Node in project service-proxy by membrane.
the class NodeOnlineCheckerTest method testPutNodesBackOnline.
@Test
public void testPutNodesBackOnline() throws InterruptedException {
Node node = new Node("http://www.predic8.de", 80);
Exchange exc = new Exchange(null);
exc.getDestinations().add(0, "http://www.predic8.de:80");
exc.setNodeStatusCode(0, 500);
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);
final int limit = 10;
noc.setNodeCounterLimit5XX(limit);
noc.setRetryTimeInSeconds(1);
assertEquals(Node.Status.UP, cl.getNode(node).getStatus());
for (int i = 0; i < limit + 1; i++) {
noc.handle(exc);
}
assertEquals(Node.Status.DOWN, cl.getNode(node).getStatus());
noc.putNodesBackUp();
assertEquals(Node.Status.DOWN, cl.getNode(node).getStatus());
Thread.sleep(noc.getRetryTimeInSeconds() * 1000);
noc.putNodesBackUp();
assertEquals(Node.Status.UP, cl.getNode(node).getStatus());
}
use of com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.Node in project service-proxy by membrane.
the class NodeOnlineCheckerTest method testExchangeWithBadStatuscode.
@Test
public void testExchangeWithBadStatuscode() {
Node node = new Node("http://www.predic8.de", 80);
Exchange exc = new Exchange(null);
exc.getDestinations().add(0, "http://www.predic8.de:80");
exc.setNodeStatusCode(0, 500);
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);
final int limit = 10;
noc.setNodeCounterLimit5XX(limit);
for (int i = 0; i < limit; i++) {
noc.handle(exc);
}
assertEquals(Node.Status.UP, cl.getNode(node).getStatus());
exc.setNodeStatusCode(0, 400);
noc.handle(exc);
assertEquals(Node.Status.UP, cl.getNode(node).getStatus());
exc.setNodeStatusCode(0, 500);
for (int i = 0; i < limit + 1; i++) {
noc.handle(exc);
}
assertEquals(Node.Status.DOWN, cl.getNode(node).getStatus());
}
use of com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.Node in project service-proxy by membrane.
the class LoadBalancingWithClusterManagerTest method startNode.
private DummyWebServiceInterceptor startNode(HttpRouter node, int port) throws Exception {
DummyWebServiceInterceptor service1 = new DummyWebServiceInterceptor();
node.addUserFeatureInterceptor(service1);
node.getRuleManager().addProxyAndOpenPortIfNew(new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", port), "thomas-bayer.com", 80));
node.init();
return service1;
}
use of com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.Node in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleNodeShowRequest.
@Mapping("/admin/node/show/?(\\?.*)?")
public Response handleNodeShowRequest(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 {
String balancer = getBalancerParam(params);
h2().text("Node " + params.get("host") + ":" + params.get("port") + " (" + "Cluster " + params.get("cluster") + " of Balancer " + balancer + ")").end();
h3().text("Status Codes").end();
Node n = BalancerUtil.lookupBalancer(router, balancer).getNode(params.get("cluster"), params.get("host"), Integer.parseInt(params.get("port")));
createStatusCodesTable(n.getStatisticsByStatusCodes());
p().text("Total requests: " + n.getCounter()).end();
p().text("Current threads: " + n.getThreads()).end();
p().text("Requests without responses: " + n.getLost()).end();
span().classAttr("mb-button");
createLink("Reset Counter", "node", "reset", createQueryString("balancer", balancer, "cluster", params.get("cluster"), "host", n.getHost(), "port", "" + n.getPort()));
end();
span().classAttr("mb-button");
createLink("Show Sessions", "node", "sessions", createQueryString("balancer", balancer, "cluster", params.get("cluster"), "host", n.getHost(), "port", "" + n.getPort()));
end();
}
}.createPage());
}
Aggregations