private LoadBalanceDefinitionRenderer() {
// Utility class, no public or protected default constructor
}
public static void render(StringBuilder buffer, ProcessorDefinition<?> processor) {
LoadBalanceDefinition loadB = (LoadBalanceDefinition)processor;
// buffer.append(".").append(output.getShortName()).append("()");
buffer.append(".").append("loadBalance").append("()");
LoadBalancer lb = loadB.getLoadBalancerType().getLoadBalancer(null);
if (lb instanceof FailOverLoadBalancer) {
buffer.append(".failover(");
List<Class<?>> exceptions = ((FailOverLoadBalancer)lb).getExceptions();
for (Class<?> excep : exceptions) {
buffer.append(excep.getSimpleName()).append(".class");
if (excep != exceptions.get(exceptions.size() - 1)) {
buffer.append(", ");
}
}
buffer.append(")");
} else if (lb instanceof RandomLoadBalancer) {
buffer.append(".random()");
} else if (lb instanceof RoundRobinLoadBalancer) {
buffer.append(".roundRobin()");
} else if (lb instanceof StickyLoadBalancer) {
buffer.append(".sticky(");
ExpressionRenderer.renderExpression(buffer, ((StickyLoadBalancer)lb).getCorrelationExpression().toString());
buffer.append(")");
} else if (lb instanceof TopicLoadBalancer) {
buffer.append(".topic()");
}
List<ProcessorDefinition> branches = loadB.getOutputs();
for (ProcessorDefinition branch : branches) {
ProcessorDefinitionRenderer.render(buffer, branch);
}
}