public void init(SynapseEnvironment se) {
if (endpoints == null) {
String msg = "Endpoints are not set, cannot initialize the algorithm";
log.error(msg);
throw new SynapseException(msg);
}
endpointStates = new EndpointState[endpoints.size()];
for (int i = 0; i < endpoints.size(); i++) {
Endpoint endpoint = endpoints.get(i);
if (!(endpoint instanceof PropertyInclude)) {
EndpointState state = new EndpointState(i, DEFAULT_WEIGHT);
endpointStates[i] = state;
} else {
MediatorProperty property =
((PropertyInclude)endpoint).getProperty(LOADBALANCE_WEIGHT);
EndpointState state;
if (property != null) {
int weight = Integer.parseInt(property.getValue());
if (weight <= 0) {
String msg = "Weight must be greater than zero";
log.error(msg);
throw new SynapseException(msg);
}
state = new EndpointState(i, weight);
} else {
state = new EndpointState(i, DEFAULT_WEIGHT);