コード例 #1
0
 // This can be called after any step
 @Override
 protected void sequenceFailed(SocietyCompletionEvent<ExperimentStep, R> evt) {
   StringBuffer msg = new StringBuffer();
   msg.append("Experiment ").append(suiteName).append(" FAILED at step ").append(evt.getStep());
   Map<String, Set<R>> reportsMap = evt.getReports();
   if (!reportsMap.isEmpty()) {
     String seperator = " ";
     msg.append(" because");
     for (Map.Entry<String, Set<R>> entry : reportsMap.entrySet()) {
       String nodeId = entry.getKey();
       for (R report : entry.getValue()) {
         if (!report.isSuccessful()) {
           msg.append(seperator).append("worker ").append(report.getWorker());
           msg.append(" on node ").append(nodeId);
           msg.append(" said: \"").append(report.getReason()).append("\"");
           seperator = ", ";
         }
       }
     }
   }
   log.shout(msg.toString());
   // Submit a request to perform the Shutdown step....
   // All bets are off if this will actually complete, because there is some
   // failure out there
   // but we do not know what it is.
   if (hasAttemptedToShutdown) {
     log.warn("Already Attempted to Shutdown, so doing nothing more");
   } else {
     log.warn("Attempting to shutdown the experiment society by skipping to Shutdown step");
     hasAttemptedToShutdown = true;
     publishNodeRequestStep(ExperimentSteps.SHUTDOWN);
   }
 }
コード例 #2
0
 @Override
 @Cougaar.Execute(on = Subscribe.ModType.ADD)
 public void executeSocietyCompletion(SocietyCompletionEvent<ExperimentStep, R> event) {
   // Sanity check
   ExperimentStep eventStep = event.getStep();
   ExperimentStep descriptorStep = experimentDescriptor.getStep();
   if (!eventStep.equals(descriptorStep)) {
     log.error("Event has step " + eventStep + " but descriptor has step " + descriptorStep);
     sequenceFailed(event);
     return;
   }
   if (!event.isSuccessful()) {
     sequenceFailed(event);
     return;
   }
   experimentDescriptor.doWork(event);
   long deferMillis = experimentDescriptor.getDeferMillis();
   if (deferMillis > 0) {
     deferSocietyCompletion(event, deferMillis);
   } else {
     resumeSocietyCompletion(event);
   }
 }