*/
public void distributeConsumers(){
for (SubBrokerData subBroker : this.subBrokers.values()){
List<BConsumer> regCon = subBroker.getRegisteredConsumers();
BrokerUpdateMessageCollector messageList = new BrokerUpdateMessageCollector();
for(BConsumer curCon : regCon){
int sum = 0;
int ownSum = 0;
SubBrokerData chosenBroker = null;
for (SubBrokerData subBroker2 : this.subBrokers.values()){
int tempSum=0;
List<BProducer> regPro = subBroker2.getRegisteredProducers();
for(BProducer curPro : regPro){
for(String curConEvent : curCon.getWantedEvents()){
if(curPro.getProducedEvent().equals(curConEvent)){
if(!subBroker.equals(subBroker2)){
tempSum++;
} else{
ownSum++;
}
}
}
}
if(tempSum>sum){
sum = tempSum;
chosenBroker = subBroker2;
}
}
if(sum>ownSum){
BrokerUpdateMessage message = new BrokerUpdateMessage(chosenBroker.getMessageService().getConnectionInfo(),curCon);
messageList.addMessage(message);
System.out.println("Forwarded Consumer from "+subBroker.getMessageService().getConnectionInfo().getHost()
+":"+subBroker.getMessageService().getConnectionInfo().getPort()+" to "
+chosenBroker.getMessageService().getConnectionInfo().getHost()+":"
+chosenBroker.getMessageService().getConnectionInfo().getPort());
}