private RemoteHESInstance chooseNextInstance() {
   Log.log(DispatcherImpl.class.getName(), "CHOOSE NEW INSTANCE");
   Log.log(
       DispatcherImpl.class.getName(),
       "number of registered instances:",
       "" + liveHESInstances.size());
   if (!liveHESInstances.isEmpty()) {
     if (i >= liveHESInstances.size()) {
       i = 0;
     }
     RemoteHESInstance instance = liveHESInstances.get(i);
     Log.log(DispatcherImpl.class.getName(), "chose: ", instance.getHesInstanceName());
     i++;
     dashboard.increaseCount(instance.getHesInstanceName());
     return instance;
   } else return null;
 }
 public void iAmAlive(RemoteHESInstance hesInstance) {
   if (!liveHESInstances.contains(hesInstance)) {
     liveHESInstances.add(hesInstance);
   }
   Log.log(
       DispatcherImpl.class.getName(),
       "I am Alive - Nachricht erhalten von " + hesInstance.getHesInstanceName());
 }
 public void iAmNotAlive(RemoteHESInstance hesInstance) {
   if (liveHESInstances.contains(hesInstance)) {
     liveHESInstances.remove(hesInstance);
   }
   Log.log(
       DispatcherImpl.class.getName(),
       "I am not Alive - HES Instanz " + hesInstance.getHesInstanceName() + "wurde geloescht");
 }
 public void changeInstanceState(String instanzname, boolean state) {
   Log.log(
       DispatcherImpl.class.getName(),
       "Aufruf changeInstanceState mit Instanz "
           + instanzname
           + " und Status "
           + state
           + " wird an ServerController weitergeleitet");
   Log.log(DispatcherImpl.class.getName(), "size of liveinstances: " + liveHESInstances.size());
   for (RemoteHESInstance instance : liveHESInstances) {
     if (instance.getHesInstanceName().equals(instanzname)) {
       Log.log(
           DispatcherImpl.class.getName(), "name of instance::: " + instance.getHesInstanceName());
       try {
         instance.getServerController().changeInstanceState(state);
       } catch (RemoteException e) {
         Log.log(
             DispatcherImpl.class.getName(),
             "changeInstanceState",
             "couldnt get ServerController");
       }
     }
   }
 }