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;
}
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);
}
}
Aggregations