Пример #1
0
 private void actualSwitchOff() {
   switch (currentState) {
     case SWITCHINGON:
       setState(State.SWITCHINGOFF);
       onOffEvent.addFurtherTasks(offTransition);
       onOffEvent.setNewState(State.OFF);
       break;
     case RUNNING:
       setState(State.SWITCHINGOFF);
       new Timed() {
         @Override
         public void tick(final long fires) {
           ResourceSpreader.FreqSyncer syncer = getSyncer();
           // Ensures that the switching off activities are only
           // started once all runtime activities complete for the
           // directConsumer
           if (syncer != null
               && syncer.isSubscribed()
               && (underProcessing.size() + toBeAdded.size() - toBeRemoved.size() > 0)) {
             updateFrequency(syncer.getNextEvent() - fires + 1);
           } else {
             unsubscribe();
             new PowerStateDelayer(offTransition, State.OFF);
           }
         }
       }.tick(Timed.getFireCount());
       break;
     case OFF:
     case SWITCHINGOFF:
       // Nothing to do
       System.err.println("WARNING: an already off PM was tasked to switch off!");
   }
 }
Пример #2
0
  /**
   * Turns on the physical machine so it allows energy and resource consumption and opens the
   * possibility to receive VM requests.
   */
  public void turnon() {
    switch (currentState) {
      case SWITCHINGOFF:
      case OFF:
        if (onOffEvent == null) {
          new PowerStateDelayer(onTransition, State.RUNNING);
        } else {
          onOffEvent.addFurtherTasks(onTransition);
          onOffEvent.setNewState(State.RUNNING);
        }

        setState(State.SWITCHINGON);
        break;
      case RUNNING:
      case SWITCHINGON:
        // Nothing to do
        System.err.println("WARNING: an already running PM was tasked to switch on!");
    }
  }