Search in sources :

Example 6 with LoadBalanceDefinition

use of org.apache.camel.model.LoadBalanceDefinition in project camel by apache.

the class ManagedFailoverLoadBalancer method getLastGoodProcessorId.

@Override
public String getLastGoodProcessorId() {
    int idx = processor.getLastGoodIndex();
    if (idx != -1) {
        LoadBalanceDefinition def = getDefinition();
        ProcessorDefinition<?> output = def.getOutputs().get(idx);
        if (output != null) {
            return output.getId();
        }
    }
    return null;
}
Also used : LoadBalanceDefinition(org.apache.camel.model.LoadBalanceDefinition)

Example 7 with LoadBalanceDefinition

use of org.apache.camel.model.LoadBalanceDefinition in project camel by apache.

the class RandomLoadBalanceJavaDSLBuilderTest method navigateDefinition.

private void navigateDefinition(ProcessorDefinition<?> def, StringBuilder sb) {
    // must do this ugly cast to avoid compiler error on HP-UX
    ProcessorDefinition<?> defn = (ProcessorDefinition<?>) def;
    if (defn instanceof LoadBalanceDefinition) {
        sb.append(".loadBalance()");
        LoadBalanceDefinition lbd = (LoadBalanceDefinition) defn;
        LoadBalancer balancer = lbd.getLoadBalancerType().getLoadBalancer(null);
        if (balancer instanceof RandomLoadBalancer) {
            sb.append(".random()");
        }
    }
    if (defn instanceof SendDefinition) {
        SendDefinition<?> send = (SendDefinition<?>) defn;
        sb.append(".to(\"" + send.getUri() + "\")");
    }
    List<ProcessorDefinition<?>> children = defn.getOutputs();
    if (children == null || children.isEmpty()) {
        return;
    }
    for (ProcessorDefinition<?> child : children) {
        navigateDefinition(child, sb);
    }
}
Also used : SendDefinition(org.apache.camel.model.SendDefinition) ProcessorDefinition(org.apache.camel.model.ProcessorDefinition) LoadBalanceDefinition(org.apache.camel.model.LoadBalanceDefinition) LoadBalancer(org.apache.camel.processor.loadbalancer.LoadBalancer) RandomLoadBalancer(org.apache.camel.processor.loadbalancer.RandomLoadBalancer) RandomLoadBalancer(org.apache.camel.processor.loadbalancer.RandomLoadBalancer)

Aggregations

LoadBalanceDefinition (org.apache.camel.model.LoadBalanceDefinition)7 Iterator (java.util.Iterator)1 DelegateProcessor (org.apache.camel.DelegateProcessor)1 Processor (org.apache.camel.Processor)1 BeanProcessor (org.apache.camel.component.bean.BeanProcessor)1 LogEndpoint (org.apache.camel.component.log.LogEndpoint)1 ManagedAggregateProcessor (org.apache.camel.management.mbean.ManagedAggregateProcessor)1 ManagedBeanProcessor (org.apache.camel.management.mbean.ManagedBeanProcessor)1 ManagedChoice (org.apache.camel.management.mbean.ManagedChoice)1 ManagedCircuitBreakerLoadBalancer (org.apache.camel.management.mbean.ManagedCircuitBreakerLoadBalancer)1 ManagedConvertBody (org.apache.camel.management.mbean.ManagedConvertBody)1 ManagedCustomLoadBalancer (org.apache.camel.management.mbean.ManagedCustomLoadBalancer)1 ManagedDelayer (org.apache.camel.management.mbean.ManagedDelayer)1 ManagedDynamicRouter (org.apache.camel.management.mbean.ManagedDynamicRouter)1 ManagedEnricher (org.apache.camel.management.mbean.ManagedEnricher)1 ManagedErrorHandler (org.apache.camel.management.mbean.ManagedErrorHandler)1 ManagedFailoverLoadBalancer (org.apache.camel.management.mbean.ManagedFailoverLoadBalancer)1 ManagedFilter (org.apache.camel.management.mbean.ManagedFilter)1 ManagedIdempotentConsumer (org.apache.camel.management.mbean.ManagedIdempotentConsumer)1 ManagedLog (org.apache.camel.management.mbean.ManagedLog)1