Пример #1
0
  // select the node state variable in order
  @Override
  public IntDomainVar selectVar() {
    //    	 ManagedElementSet<VirtualMachine> allVMS =
    // pb.getSourceConfiguration().getAllVirtualMachines();
    //         IntDomainVar[] hosters = new IntDomainVar[allVMS.size()];
    //         for(int i = 0; i < allVMS.size(); i++) {
    //             VirtualMachine vm = pb.getVirtualMachine(i);
    //             hosters[i] = pb.getAssociatedAction(vm).getDemandingSlice().hoster();
    //             if(hosters[i].isInstantiated()) {
    //             	log.debug("hoster " + i + " instancied " + hosters[i].getVal());
    //             } else {
    //             	log.debug("hoster " + i + " not instancied ");
    //             }
    //         }

    for (int i = 0; i < nodes.size(); i++) {
      Node n = nodes.get(i);

      // future online and future offline should have their state set already
      if (!pb.getFutureOnlines().contains(n) && !pb.getFutureOfflines().contains(n)) {
        ManageableNodeActionModel action = (ManageableNodeActionModel) pb.getAssociatedAction(n);
        log.debug("Node " + n.getName());
        log.debug("state instancied " + action.getState().isInstantiated());
        // Select the empty nodes first
        if (!action.getState().isInstantiated() && pb.getUsedMem(n).isInstantiatedTo(0)) {
          log.debug("select node " + n.getName() + " for switch off");
          return action.getState();
        }
        if (pb.getUsedMem(n).isInstantiatedTo(0) && !action.start().isInstantiated()) {
          log.debug("select node " + n.getName() + " for start");
          return action.start();
        }
      }
    }
    return null;
  }