You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2019/10/31 21:07:33 UTC

svn commit: r1869228 - in /uima/uima-ducc/trunk: uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/ uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/

Author: burn
Date: Thu Oct 31 21:07:33 2019
New Revision: 1869228

URL: http://svn.apache.org/viewvc?rev=1869228&view=rev
Log:
UIMA-6130 Add link to the JED AP; simplify restarting logic

Modified:
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsServlets.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Experiment.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryManager.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryUtilities.java

Modified: uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java?rev=1869228&r1=1869227&r2=1869228&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java Thu Oct 31 21:07:33 2019
@@ -150,6 +150,9 @@ public class DuccJedSubmit extends CliBa
     serviceRequestProperties.setProperty(UiOption.ServiceTypeOther.pname(), "");
     
     // Create the AP properties for the JED call
+    // Specify java, classpath, JED class, users's args
+    // Explictly override any internal setting of the outputBaseDirectory
+    // Augment the environment ... the OR checks for env-var DUCC_JED_DIR
     String javaHome = System.getProperty("java.home");
     serviceRequestProperties.setProperty(UiOption.ProcessExecutable.pname(), javaHome + "/bin/java");
     

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsServlets.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsServlets.java?rev=1869228&r1=1869227&r2=1869228&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsServlets.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsServlets.java Thu Oct 31 21:07:33 2019
@@ -439,14 +439,14 @@ public class HandlerExperimentsServlets
     String dir = request.getParameter("dir");
     Experiment experiment = experimentsRegistryManager.getExperiment(dir);
     if (experiment != null) {
-      // If restart requested update the tasks to be rerun
+      // If restart requested update the tasks to be rerun & set restarting flag
       restart = request.getParameter("restart") != null;
       if (restart) {
         experiment.updateStatus();
       }
       // Check if the experiment can be restarted, i.e.
       // launched by DUCC as a JED AP, stopped, and owned by the logged-in user
-      boolean isRestartable = experiment.getJedDuccId() != null  
+      boolean isRestartable = experiment.getJedId() > 0  
               && !experiment.isActive()
               && HandlersHelper.getAuthorizationStatus(request, experiment.getUser()) == AuthorizationStatus.LoggedInOwner;
       
@@ -501,7 +501,7 @@ public class HandlerExperimentsServlets
       boolean ok = ExperimentsRegistryUtilities.launchJed(experiment);
       if (!ok) {
         WsLog.warn(cName, mName, "Failed to relaunch JED - reset the is-rerunning state");
-        experiment.setRerunJedId(null);
+        experiment.setRestart(false);
       }
     }
     
@@ -546,11 +546,11 @@ public class HandlerExperimentsServlets
     if (experiment != null) {
       // Display Terminate/Restart button if DUCC-launched && the owner logged in
       String button = null;
-      if (experiment.getJedDuccId() != null &&
+      if (experiment.getJedId() > 0 &&
         HandlersHelper.getAuthorizationStatus(request, experiment.getUser()) == AuthorizationStatus.LoggedInOwner) {
         restart = request.getParameter("restart") != null;
-        if (restart) {           // Mark as "restarting" ... correct ID will be set later
-          experiment.setRerunJedId("");
+        if (restart) {           // Mark as "restarting" ... so getStatus will reflect that
+          experiment.setRestart(true);
         }
         Status status = experiment.getStatus();
         // TODO - If still restarting should check if the restartJedId AP is actually running
@@ -561,7 +561,7 @@ public class HandlerExperimentsServlets
                   + "disabled"
                   + " title='experiment is restarting'>Restarting...</button>";
         } else if (status == Jed.Status.Running) {
-          button = "<button style='background-color:LightPink;font-size:16px' "
+          button = "<button style='background-color:Khaki;font-size:16px' "
                   + "onclick=\"ducc_confirm_terminate_experiment('" + directory + "')\""
                   + " title='click to terminate experiment'>TERMINATE</button>";
         } else {
@@ -576,12 +576,14 @@ public class HandlerExperimentsServlets
       sb.append(" ");
       sb.append(directory);
       if (button != null) {
-        sb.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+        sb.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
         sb.append(button);
+        sb.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+        long jedId = experiment.getJedId();
+        sb.append(" <a href='reservation.details.html?id=" + jedId + "' title='click to view the JED Managed Reservation'>" + jedId + "</a>");
       }
       sb.append("</b>");
     }
-
     response.getWriter().println(sb);
     
     WsLog.exit(cName, mName);

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Experiment.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Experiment.java?rev=1869228&r1=1869227&r2=1869228&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Experiment.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Experiment.java Thu Oct 31 21:07:33 2019
@@ -27,7 +27,6 @@ import java.util.Date;
 import java.util.HashMap;
 
 import org.apache.uima.ducc.common.utils.DuccLogger;
-import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.transport.event.common.IDuccWork;
 import org.apache.uima.ducc.ws.authentication.DuccAsUser;
 import org.apache.uima.ducc.ws.log.WsLog;
@@ -47,9 +46,9 @@ public class Experiment implements Compa
 
   private long fileDate = 0;
 
-  private DuccId jedDuccId;   // ID of JED task that last launched this experiment
+  private long jedId = 0;   // ID of JED task that launched this experiment (0 => not DUCC launched)
 
-  private String rerunJedId = null;  // ID of re-launched JED
+  private boolean restarting = false;
 
     
   public Experiment(String user, String directory, long fileDate, ArrayList<Task> tasks, IDuccWork work) {
@@ -59,7 +58,7 @@ public class Experiment implements Compa
     this.tasks = tasks;
     tasks.sort(null);        // Sort tasks in taskId order for display
     if (work != null) {
-      this.jedDuccId = work.getDuccId();
+      this.jedId = work.getDuccId().getFriendly();
     }
   }
 
@@ -79,17 +78,32 @@ public class Experiment implements Compa
     return tasks;
   }
   
-  public DuccId getJedDuccId() {
-    return jedDuccId;
+  public long getJedId() {
+    return jedId;
   }
   
-  // Update the duccId for the JED AP if missing or is older
-  public void updateJedId(DuccId duccId) {
-    if (jedDuccId == null || jedDuccId.getFriendly() < duccId.getFriendly()) {
-      jedDuccId = duccId;
+  public void setJedId(long duccId) {
+    jedId = duccId;
+  }
+  
+  // Update the duccId for the JED AP if given a newer one
+  // Called when replacing an existing Experiment with an updated one or when only the JED ID needs updating
+  // Also may indicate that a restarted JED has checked in
+  public void updateJedId(long duccId) {
+    if (duccId > jedId) {
+      jedId = duccId;
     }
   }
   
+  // Unused
+  //  public boolean isRestarting() {
+  //    return restarting;
+  //  }
+  
+  public void setRestart(boolean restart) {
+    restarting = restart;
+  }
+  
   public boolean isActive() {
     boolean retVal = false;
     switch (getStatus()) {
@@ -107,7 +121,7 @@ public class Experiment implements Compa
   // The restarting state is NOT saved in the Experiment.state file
   public Jed.Status getStatus() {
     Jed.Status retVal = Jed.Status.Unknown;
-    if (rerunJedId != null) {
+    if (restarting) {
       return Jed.Status.Restarting;
     }
     if (tasks != null) {
@@ -169,28 +183,15 @@ public class Experiment implements Compa
         }
       }
     }
-    setRerunJedId("");  // Mark as "restarting" ... correct ID will be set later
+    restarting = true;      // Will be cleared when the restarted AP updates the state file and replaces this object
   }
   
-  public void setRerunJedId(String rerunJedId) {
-    String mName = "setRerunJedId";
-    if (rerunJedId != null && this.rerunJedId != null && this.rerunJedId.length() > 0) {
-      WsLog.warn(logger, mName, "JED ID was " + this.rerunJedId + " but is now " + rerunJedId);
-    }
-    this.rerunJedId  = rerunJedId;
-  }
-  
-  /*
-   * Write the state as a temporary file (starting with the version number)
-   * as the user copy it to the output directory,
-   * delete the temp file.
-   */
   public boolean writeStateFile(String umask) {
     int version = 1;
     File tempFile = null;
     Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();
     try {
-      tempFile = File.createTempFile("experiment", jedDuccId.toString());
+      tempFile = File.createTempFile("experiment", String.valueOf(jedId));
       FileWriter out = new FileWriter(tempFile);
       out.write(String.valueOf(version));
       out.write('\n');

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryManager.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryManager.java?rev=1869228&r1=1869227&r2=1869228&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryManager.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryManager.java Thu Oct 31 21:07:33 2019
@@ -169,9 +169,9 @@ public class ExperimentsRegistryManager
       synchronized (existingExperiment) {
         existingFileTime = existingExperiment.getFileDate();
       }
-      if (fileTime <= existingFileTime) {
+      if (fileTime <= existingFileTime) {    // No need to reload, but update the jED ID if newer
         if (work != null) {
-          existingExperiment.updateJedId(work.getDuccId());
+          existingExperiment.updateJedId(work.getDuccId().getFriendly());
         }
         return;
       }
@@ -196,7 +196,7 @@ public class ExperimentsRegistryManager
       Experiment experiment = new Experiment(user, directory, fileTime, taskArray, work);
       Experiment oldExperiment = experimentsByDir.put(directory, experiment);
       if (oldExperiment != null) {
-        experiment.updateJedId(oldExperiment.getJedDuccId());    // Ensure the new instance has the latest DuccId
+        experiment.updateJedId(oldExperiment.getJedId());    // Ensure the new instance has the latest DuccId
       }
     } catch (JsonParseException e) {
       WsLog.warn(cName, mName, "Ignoring " + stateFile + " as has Json syntax error " + e.getMessage());

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryUtilities.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryUtilities.java?rev=1869228&r1=1869227&r2=1869228&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryUtilities.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentsRegistryUtilities.java Thu Oct 31 21:07:33 2019
@@ -89,18 +89,18 @@ public class ExperimentsRegistryUtilitie
     IHistoryPersistenceManager hpm = HistoryFactory.getInstance(ExperimentsRegistryUtilities.class.getName());
     IDuccWorkService service = null;
     try {
-      service = hpm.restoreArbitraryProcess(experiment.getJedDuccId().getFriendly());
+      service = hpm.restoreArbitraryProcess(experiment.getJedId());
       if (service == null) {
         // If relaunch is too quick DB may not have been updated so wait 10 secs and try again
         Thread.sleep(10000);
-        service = hpm.restoreArbitraryProcess(experiment.getJedDuccId().getFriendly());
+        service = hpm.restoreArbitraryProcess(experiment.getJedId());
         if (service == null) {
-          WsLog.error(cName, mName, "No entry found in DB for JED AP "+experiment.getJedDuccId());
+          WsLog.error(cName, mName, "No entry found in DB for JED AP "+experiment.getJedId());
           return false;
         }
       }
     } catch (Exception e) {
-      WsLog.error(cName, mName, "Failed to access DB for JED AP "+experiment.getJedDuccId());
+      WsLog.error(cName, mName, "Failed to access DB for JED AP "+experiment.getJedId());
       WsLog.error(cName, mName, e);
       return false;
     }
@@ -112,7 +112,7 @@ public class ExperimentsRegistryUtilitie
     IDuccWorkJob dwj = (IDuccWorkJob) service;
     ICommandLine cmd = dwj.getCommandLine();
     if (cmd == null) {
-      WsLog.info(cName, mName, "No cmdline for JED AP " + experiment.getJedDuccId());
+      WsLog.info(cName, mName, "No cmdline for JED AP " + experiment.getJedId());
       return false;
     }
 
@@ -145,9 +145,9 @@ public class ExperimentsRegistryUtilitie
         "--environment",             envs.toString(),
         "--log_directory",           dwj.getStandardInfo().getLogDirectory(),
         "--working_directory",       dwj.getStandardInfo().getWorkingDirectory(),
+        "--description",             dwj.getStandardInfo().getDescription(),
         "--scheduling_class",        dwj.getSchedulingInfo().getSchedulingClass(),
         "--process_memory_size",     dwj.getSchedulingInfo().getMemorySizeRequested(),
-        "--description",             "JED---" + dwj.getStandardInfo().getLogDirectory()
     };
     
     // Write the state file with the user's umask AFTER successfully restoring the JED AP from the DB
@@ -162,13 +162,14 @@ public class ExperimentsRegistryUtilitie
     WsLog.info(cName, mName, sysout);
     
     // Should report: "Managed Reservation ### submitted."
-    // If successful save the ID of JED
-    // If it fails return false and the status will be reset by the caller
+    // If successful save the ID of the JED AP
+    // If it fails return false and the restarting status will be reset by the caller
     boolean launched = sysout.startsWith("Managed Reservation");
     if (launched) {
       String[] toks = sysout.split("\\s+");
       if (toks.length >= 3) {
-        experiment.setRerunJedId(toks[2]);
+        long duccId = Long.parseLong(toks[2]);
+        experiment.setJedId(duccId);
       }
     }