Search in sources :

Example 1 with FailoverTargetSelector

use of org.apache.cxf.clustering.FailoverTargetSelector in project cxf by apache.

the class LoadDistributorTest method verifyStrategy.

protected void verifyStrategy(Object proxy, Class<?> clz) {
    ConduitSelector conduitSelector = WebClient.getConfig(proxy).getConduitSelector();
    if (conduitSelector instanceof FailoverTargetSelector) {
        Object strategy = ((FailoverTargetSelector) conduitSelector).getStrategy();
        assertTrue("unexpected strategy", clz.isInstance(strategy));
    } else {
        fail("unexpected conduit selector: " + conduitSelector);
    }
}
Also used : FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 2 with FailoverTargetSelector

use of org.apache.cxf.clustering.FailoverTargetSelector in project cxf by apache.

the class AbstractFailoverTest method verifyStrategy.

protected void verifyStrategy(Object proxy, Class<?> clz) {
    ConduitSelector conduitSelector = WebClient.getConfig(proxy).getConduitSelector();
    if (conduitSelector instanceof FailoverTargetSelector) {
        Object strategy = ((FailoverTargetSelector) conduitSelector).getStrategy();
        assertTrue("unexpected strategy", clz.isInstance(strategy));
    } else {
        fail("unexpected conduit selector: " + conduitSelector);
    }
}
Also used : FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 3 with FailoverTargetSelector

use of org.apache.cxf.clustering.FailoverTargetSelector in project cxf by apache.

the class FailoverTest method getCustomFeature.

private FailoverFeature getCustomFeature(boolean custom, boolean random, String... address) {
    FailoverFeature feature = new FailoverFeature();
    List<String> alternateAddresses = new ArrayList<>();
    for (String s : address) {
        alternateAddresses.add(s);
    }
    if (!random) {
        SequentialStrategy strategy = new SequentialStrategy();
        strategy.setAlternateAddresses(alternateAddresses);
        feature.setStrategy(strategy);
    } else {
        RandomStrategy strategy = new RandomStrategy();
        strategy.setAlternateAddresses(alternateAddresses);
        feature.setStrategy(strategy);
    }
    if (custom) {
        FailoverTargetSelector selector = new ReplaceInitialAddressSelector();
        feature.setTargetSelector(selector);
    }
    return feature;
}
Also used : SequentialStrategy(org.apache.cxf.clustering.SequentialStrategy) RandomStrategy(org.apache.cxf.clustering.RandomStrategy) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) ArrayList(java.util.ArrayList) FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector)

Example 4 with FailoverTargetSelector

use of org.apache.cxf.clustering.FailoverTargetSelector in project cxf by apache.

the class FailoverAddressOverrideTest method verifyStrategy.

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);
    }
}
Also used : AbstractStaticFailoverStrategy(org.apache.cxf.clustering.AbstractStaticFailoverStrategy) FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Example 5 with FailoverTargetSelector

use of org.apache.cxf.clustering.FailoverTargetSelector in project cxf by apache.

the class FailoverTest method verifyStrategy.

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);
    }
}
Also used : FailoverTargetSelector(org.apache.cxf.clustering.FailoverTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector)

Aggregations

FailoverTargetSelector (org.apache.cxf.clustering.FailoverTargetSelector)6 ConduitSelector (org.apache.cxf.endpoint.ConduitSelector)4 ArrayList (java.util.ArrayList)1 AbstractStaticFailoverStrategy (org.apache.cxf.clustering.AbstractStaticFailoverStrategy)1 FailoverFeature (org.apache.cxf.clustering.FailoverFeature)1 RandomStrategy (org.apache.cxf.clustering.RandomStrategy)1 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)1 ClusteredGreeterService (org.apache.cxf.greeter_control.ClusteredGreeterService)1