@Override public void initialize(Client client, Bus bus) { ConduitSelector selector = initTargetSelector(client.getConduitSelector().getEndpoint()); client.setConduitSelector(selector); }
@Override public void initialize(Client client, Bus bus) { ConduitSelector selector = initTargetSelector(client.getConduitSelector().getEndpoint()); client.setConduitSelector(selector); }
protected void verifyConduitSelector(Greeter g) { assertTrue("unexpected conduit slector", ClientProxy.getClient(g).getConduitSelector() instanceof FailoverTargetSelector); }
protected void verifyStrategy(Object proxy, Class<?> clz) { ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector(); if (conduitSelector instanceof FailoverTargetSelector) { Object strategy = ((FailoverTargetSelector)conduitSelector).getStrategy(); assertTrue("unexpected strategy", clz.isInstance(strategy)); } else { fail("unexpected conduit selector: " + conduitSelector); } }
protected void setupGreeter() throws Exception { ClusteredGreeterService cs = new ClusteredGreeterService(); // REVISIT: why doesn't the generic (i.e. non-Port-specific) // Service.getPort() load the <jaxws:client> configuration? greeter = cs.getReplicatedPortA(); updateAddressPort(greeter, PORT_A); assertTrue("unexpected conduit selector: " + ClientProxy.getClient(greeter).getConduitSelector().getClass().getName(), ClientProxy.getClient(greeter).getConduitSelector() instanceof FailoverTargetSelector); updateWsdlExtensors("9051", PORT_A); updateWsdlExtensors("9052", PORT_B); updateWsdlExtensors("9053", PORT_C); updateWsdlExtensors("9055", PORT_E); }
protected void verifyStrategy(Object proxy, Class<?> clz, int count) { ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector(); if (conduitSelector instanceof FailoverTargetSelector) { AbstractStaticFailoverStrategy strategy = (AbstractStaticFailoverStrategy) ((FailoverTargetSelector)conduitSelector).getStrategy(); assertTrue("unexpected strategy", clz.isInstance(strategy)); List<String> alternates = strategy.getAlternateAddresses(null); assertNotNull("expected alternate addresses", alternates); assertEquals("unexpected alternate addresses", count, alternates.size()); } else { fail("unexpected conduit selector: " + conduitSelector); } }
@Test public void testDistributedSequentialStrategyWithFailover() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_B); startTarget(REPLICA_C); setupGreeter(); stopTarget(REPLICA_B); ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy( new LoadDistributorStaticStrategy()); } else { fail("unexpected conduit selector: " + conduitSelector); } Map< String, Integer > responseCounts = new HashMap<>(); for (int i = 0; i < 12; ++i) { String response = greeter.greetMe("fred"); assertNotNull("expected non-null response", response); incrementResponseCount(responseCounts, response); } assertTrue((long)responseCounts.get(REPLICA_A) > 0); assertTrue((long)responseCounts.get(REPLICA_C) > 0); assertEquals(12, responseCounts.get(REPLICA_A) + responseCounts.get(REPLICA_C)); stopTarget(REPLICA_A); stopTarget(REPLICA_C); }
verifyStrategy(greeter, SequentialStrategy.class, 3); ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setFailover(false);
ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy(
stopTarget(REPLICA_B); ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy(