コード例 #1
0
ファイル: PilotSet.java プロジェクト: vdhelm/amuse
 public PilotManager getSuitablePilot(AmuseJob job) {
   for (PilotManager pilot : getPilots()) {
     if (pilot.canRun(job)) {
       return pilot;
     }
   }
   return null;
 }
コード例 #2
0
ファイル: PilotSet.java プロジェクト: vdhelm/amuse
 public synchronized PilotManager getPilot(int id) throws DistributedAmuseException {
   for (PilotManager reservation : pilots) {
     if (reservation.getID() == id) {
       return reservation;
     }
   }
   throw new DistributedAmuseException("Reservation with ID " + id + " not found");
 }
コード例 #3
0
ファイル: PilotSet.java プロジェクト: vdhelm/amuse
 public synchronized void end() {
   for (PilotManager pilot : pilots) {
     try {
       pilot.stop();
     } catch (DistributedAmuseException e) {
       logger.error("Failed to stop pilot: " + pilot, e);
     }
   }
 }
コード例 #4
0
ファイル: PilotSet.java プロジェクト: vdhelm/amuse
  public synchronized void deletePilot(int pilotID) throws DistributedAmuseException {
    logger.debug("deleting reservation " + pilotID);

    for (int i = 0; i < pilots.size(); i++) {
      PilotManager pilot = pilots.get(i);
      if (pilotID == pilot.getID()) {
        pilots.remove(i);
        pilot.stop();
        return;
      }
    }
    throw new DistributedAmuseException("Pilot " + pilotID + " not found");
  }
コード例 #5
0
ファイル: PilotSet.java プロジェクト: vdhelm/amuse
  // check if all pilots are running. will throw an error if any pilots are done/failed
  private boolean allPilotsRunning() throws DistributedAmuseException {
    PilotManager[] pilots = getPilots();
    int running = 0;

    boolean result = true;

    for (PilotManager pilot : pilots) {
      if (pilot.hasException()) {
        throw new DistributedAmuseException(
            "Pilot " + pilot + " failed while waiting for it to start", pilot.getException());
      }
      if (pilot.isDone()) {
        throw new DistributedAmuseException(
            "Pilot " + pilot + " done while waiting for it to start");
      }
      if (pilot.isRunning()) {
        running++;
      } else {
        result = false;
      }
    }
    logger.debug("Now {} out of {} pilots running.", running, pilots.length);
    return result;
  }