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/11/22 20:46:34 UTC

svn commit: r1870194 - in /uima/uima-ducc/trunk: src/main/admin/ uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/ uima-ducc-transport/src/main/java/org/apache/uima/duc...

Author: burn
Date: Fri Nov 22 20:46:34 2019
New Revision: 1870194

URL: http://svn.apache.org/viewvc?rev=1870194&view=rev
Log:
UIMA-6130 Drop need for output_directory parameter in ducc_jed_submit

Modified:
    uima/uima-ducc/trunk/src/main/admin/stop_ducc
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJedSubmit.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/cli/JobSpecificationProperties.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccStandardInfo.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/IDuccStandardInfo.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsAbstract.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
    uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/$banner/c0-menu.jsp

Modified: uima/uima-ducc/trunk/src/main/admin/stop_ducc
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/admin/stop_ducc?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/admin/stop_ducc (original)
+++ uima/uima-ducc/trunk/src/main/admin/stop_ducc Fri Nov 22 20:46:34 2019
@@ -472,7 +472,7 @@ class StopDucc(DuccUtil):
     # Note - If this is called after submitting the stop request the autostart cron job may see
     # that the daemon is down before the DB is updated and restart it!
     def acct_stop(self,node,component):
-        print 'db_acct: Recording '+component+'@'+node+' in DB as Stopped'
+        print 'db_acct: Marking '+component+'@'+node+' as Stopped'
         self.db_acct_stop(node,component)
         
     # target=kill

Modified: uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java Fri Nov 22 20:46:34 2019
@@ -440,8 +440,6 @@ public abstract class CliBase implements
         workingDir = getWorkingDirectory();
       } else if (uiopt == UiOption.LogDirectory) {
         logDir = getDirectory(uiopt, workingDir);
-      } else if (uiopt == UiOption.OutputDirectory) {
-        getDirectory(uiopt, workingDir);
       } else if (uiopt == UiOption.Environment) {
         // If this request accepts the --environment option may need to augment it by
         // renaming LD_LIBRARY_PATH & propagating some user values

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=1870194&r1=1870193&r2=1870194&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 Fri Nov 22 20:46:34 2019
@@ -30,7 +30,7 @@ import org.apache.uima.ducc.transport.ev
 import org.apache.uima.ducc.transport.event.cli.ServiceRequestProperties;
 
 /**
- * Submit a DUCC Managed Reservation. A Managed Reservation is a single arbitray process running in a non-preemptable share.
+ * Submit a DUCC Managed Reservation that runs JED
  */
 
 public class DuccJedSubmit extends CliBase {
@@ -44,7 +44,6 @@ public class DuccJedSubmit extends CliBa
       UiOption.Description, 
       UiOption.WorkingDirectory, // Must precede LogDirecory
       UiOption.LogDirectory,     // Must precede Environment
-      UiOption.OutputDirectory,  // JED output directory
       UiOption.Environment, 
       UiOption.ProcessExecutableArgsRequired, 
       UiOption.ProcessMemorySize, 
@@ -163,13 +162,12 @@ public class DuccJedSubmit extends CliBa
             ducc_home + "/lib/uima-ducc-cli.jar " + 
             "com.ibm.watsonx.framework.jed.Driver ";
     String userArgs = serviceRequestProperties.getProperty(UiOption.ProcessExecutableArgsRequired.pname());
-    String outputDir = serviceRequestProperties.getProperty(UiOption.OutputDirectory.pname());
-    String args = jedArgs + userArgs + " --outputBaseDirectory=" + outputDir;
+    String args = jedArgs + userArgs;
     serviceRequestProperties.setProperty(UiOption.ProcessExecutableArgsRequired.pname(), args);
     
     // Add the environment variable that tells the OR this is a JED AP
     // Also add DUCC_HOME so the JED properties can reference it
-    String jedEnv = "DUCC_HOME="+ducc_home + " DUCC_JED_DIR="+outputDir + " ";
+    String jedEnv = "DUCC_HOME="+ducc_home + " ";
     String userEnv = serviceRequestProperties.getProperty(UiOption.Environment.pname());
     if (userEnv != null) {
       jedEnv += userEnv;
@@ -179,7 +177,7 @@ public class DuccJedSubmit extends CliBa
     // Create a description if none provided
     String desc = serviceRequestProperties.getProperty(UiOption.Description.pname());
     if (desc == null || desc.equals(UiOption.Description.deflt())) {
-      serviceRequestProperties.setProperty(UiOption.Description.pname(), "JED -- " + outputDir);
+      serviceRequestProperties.setProperty(UiOption.Description.pname(), "JED: " + userArgs);
     }
 
     // Keep list of user provided properties for WS display: user vs. system

Modified: uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java Fri Nov 22 20:46:34 2019
@@ -682,13 +682,7 @@ public interface IUiOptions
             public String description() { return "The working directory set in each process. Default to current directory."; }
             public String deflt()       { return "."; }
         },
-        
-        OutputDirectory { 
-            public String pname()       { return JobSpecificationProperties.key_output_directory; }
-            public String argname()     { return "path"; }
-            public String description() { return "The output directory for the experiment."; }
-            public boolean required()   { return true; }
-        },
+
         ;
 
         public String  argname()   { return null; }  // the type of argument, if any

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/factory/JobFactory.java Fri Nov 22 20:46:34 2019
@@ -674,12 +674,6 @@ public class JobFactory implements IJobF
 			List<String> process_executable_arguments = QuotedOptions.tokenizeList(
 			        jobRequestProperties.getProperty(JobSpecificationProperties.key_process_executable_args), true);
 			executableProcessCommandLine.getArguments().addAll(process_executable_arguments);
-			
-			// JED check
-			String jedDir = executableProcessCommandLine.getEnvVar("DUCC_JED_DIR");
-			if (jedDir != null) {
-			  standardInfo.setExperimentDirectory(jedDir);
-			}
 		}
 		// process_initialization_failures_cap
 		// ?? These are not set for APs or SPs ??

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/cli/JobSpecificationProperties.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/cli/JobSpecificationProperties.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/cli/JobSpecificationProperties.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/cli/JobSpecificationProperties.java Fri Nov 22 20:46:34 2019
@@ -32,7 +32,6 @@ public class JobSpecificationProperties
 	public static String key_notifications = "notifications";
 	public static String key_log_directory = "log_directory";
 	public static String key_working_directory = "working_directory";
-	public static String key_output_directory = "output_directory";
 	
 	public static String key_scheduling_priority = "scheduling_priority";
 	
@@ -94,7 +93,6 @@ public class JobSpecificationProperties
 		key_notifications,
 		key_log_directory,
 		key_working_directory,
-		key_output_directory,
 		key_scheduling_priority,
 		key_jvm,
 		key_driver_jvm_args,

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccStandardInfo.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccStandardInfo.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccStandardInfo.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccStandardInfo.java Fri Nov 22 20:46:34 2019
@@ -299,16 +299,6 @@ public class DuccStandardInfo implements
 		return true;
 	}
 
-  @Override
-  public String getExperimentDirectory() {
-    return experimentDirectory;
-  }
-
-  @Override
-  public void setExperimentDirectory(String experimentDirectory) {
-    this.experimentDirectory = experimentDirectory;
-  }
-
 	// **********
 
 //

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/IDuccStandardInfo.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/IDuccStandardInfo.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/IDuccStandardInfo.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/IDuccStandardInfo.java Fri Nov 22 20:46:34 2019
@@ -64,9 +64,6 @@ public interface IDuccStandardInfo exten
 	public String getWorkingDirectory();
 	public void setWorkingDirectory(String workingDirectory);
 	
-  public String getExperimentDirectory();
-  public void setExperimentDirectory(String experimentDirectory);
-
 	public String[] getNotifications();
 	public void setNotifications(String[] notifications);
 

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsAbstract.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsAbstract.java?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsAbstract.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/handlers/experiments/HandlerExperimentsAbstract.java Fri Nov 22 20:46:34 2019
@@ -119,7 +119,7 @@ public abstract class HandlerExperiments
     try {
       String v2 = dw.getStandardInfo().getDateOfCompletion();
       String v1 = dw.getStandardInfo().getDateOfSubmission();
-      WsLog.trace(cName, mName, "v2:" + v2 + " v1:" + v1);
+      //WsLog.trace(cName, mName, "v2:" + v2 + " v1:" + v1);
       retVal = getDuration(dw.getDuccId(), v2, v1);
     } catch (Exception e) {
       //

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=1870194&r1=1870193&r2=1870194&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 Fri Nov 22 20:46:34 2019
@@ -474,6 +474,10 @@ public class HandlerExperimentsServlets
               && HandlersHelper.getAuthorizationStatus(request, experiment.getUser()) == AuthorizationStatus.LoggedInOwner;
       
       boolean isCanceled = experiment.getStatus() == Jed.Status.Canceled;
+      
+      //if (cName.isTrace()) WsLog.trace(cName, mName, experiment.getDirectory() + " AP: "+experiment.getJedId()
+      //        + " canrestart: "+isRestartable + " active: "+experiment.isActive() + " canceled: "+isCanceled
+      //        + " loggedin: "+HandlersHelper.getAuthorizationStatus(request, experiment.getUser()));
 
       ArrayList<Task> tasks = experiment.getTasks();
       if (tasks != null) {
@@ -569,8 +573,11 @@ public class HandlerExperimentsServlets
     if (experiment != null && !dh.is_ducc_head_backup()) {
       // Display Terminate/Restart button if DUCC-launched && the owner logged in
       String button = null;
+      //if (cName.isTrace()) WsLog.trace(cName, mName, experiment.getDirectory() + " AP: " + experiment.getJedId() + 
+      //                                 " loggedin: " + HandlersHelper.getAuthorizationStatus(request, experiment.getUser()));
       if (experiment.getJedId() > 0 &&
         HandlersHelper.getAuthorizationStatus(request, experiment.getUser()) == AuthorizationStatus.LoggedInOwner) {
+        
         restart = request.getParameter("restart") != null;
         if (restart) {           // Mark as "restarting" ... so getStatus will reflect that
           experiment.setRestart(true);
@@ -658,8 +665,8 @@ public class HandlerExperimentsServlets
 
   private boolean handleDuccRequest(String target, Request baseRequest, HttpServletRequest request,
           HttpServletResponse response) throws Exception {
-    String mName = "handleDuccRequest";
-    WsLog.enter(cName, mName);
+    //String mName = "handleDuccRequest";
+    //WsLog.enter(cName, mName);
     String reqURI = request.getRequestURI();
     boolean handled = false;
     //if (reqURI.contains("experiment")) WsLog.info(cName, mName, "!! start "+reqURI);
@@ -684,23 +691,22 @@ public class HandlerExperimentsServlets
     }
     //if (reqURI.contains("experiment")) WsLog.info(cName, mName, "!! end   "+reqURI);
     
-    WsLog.exit(cName, mName);
+    //WsLog.exit(cName, mName);
     return handled;
   }
 
   public void handle(String target, Request baseRequest, HttpServletRequest request,
           HttpServletResponse response) throws IOException, ServletException {
     String mName = "handle";
-    WsLog.enter(cName, mName);
+    //WsLog.enter(cName, mName);
     try {
-      WsLog.debug(cName, mName, request.toString());
-      // WsLog.debug(cName, mName, "getRequestURI():"+request.getRequestURI());
       boolean handled = handleDuccRequest(target, baseRequest, request, response);
       if (handled) {
         response.setContentType("text/html;charset=utf-8");
         response.setStatus(HttpServletResponse.SC_OK);
         baseRequest.setHandled(true);
         DuccWebUtil.noCache(response);
+        WsLog.debug(cName, mName, "handled "+request.toString());
       }
     } catch (Throwable t) {
       if (isIgnorable(t)) {
@@ -710,7 +716,7 @@ public class HandlerExperimentsServlets
         WsLog.error(cName, mName, t);
       }
     }
-    WsLog.exit(cName, mName);
+    //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=1870194&r1=1870193&r2=1870194&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 Fri Nov 22 20:46:34 2019
@@ -46,19 +46,22 @@ public class Experiment implements Compa
 
   private long fileDate = 0;
 
-  private long jedId = 0;   // ID of JED task that launched this experiment (0 => not DUCC launched)
+  private long jedId = 0;   // ID of JED AP that launched this experiment (0 => not DUCC launched)
 
+  private IDuccWork jedWork = null;  // DUCC managed reservation running JED 
+  
   private boolean restarting = false;
 
     
-  public Experiment(String user, String directory, long fileDate, ArrayList<Task> tasks, IDuccWork work) {
+  public Experiment(String user, String directory, long fileDate, ArrayList<Task> tasks, IDuccWork jedWork) {
     this.user = user;
     this.directory = directory;
     this.fileDate = fileDate;
     this.tasks = tasks;
     tasks.sort(null);        // Sort tasks in taskId order for display
-    if (work != null) {
-      this.jedId = work.getDuccId().getFriendly();
+    if (jedWork != null) {
+      this.jedWork = jedWork;
+      this.jedId = jedWork.getDuccId().getFriendly();
     }
   }
 
@@ -86,12 +89,19 @@ public class Experiment implements Compa
     jedId = duccId;
   }
   
-  // Update the duccId for the JED AP if given a newer one
+  public IDuccWork getJedWork() {
+    return jedWork;
+  }
+  
+  // Update the AP & 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) {
+  public void updateJedWork(IDuccWork work) {
+    if (work == null) return;
+    long duccId = work.getDuccId().getFriendly();
     if (duccId > jedId) {
       jedId = duccId;
+      jedWork = work;
     }
   }
   
@@ -186,7 +196,12 @@ public class Experiment implements Compa
     restarting = true;      // Will be cleared when the restarted AP updates the state file and replaces this object
   }
   
+  /*
+   * Update state file before re-launching JED
+   * Experiment has stopped but state file will be updated when JED starts
+   */
   public boolean writeStateFile(String umask) {
+    String mName = "writeStateFile";
     int version = 1;
     File tempFile = null;
     Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();
@@ -199,7 +214,7 @@ public class Experiment implements Compa
       out.write(text);
       out.close();
     } catch (IOException e) {
-      WsLog.error(logger, "writeExperiment", "Failed to write experiment state as " + tempFile + " - " + e);
+      WsLog.error(logger, mName, "Failed to write experiment state as " + tempFile + " - " + e);
       return false;
     }
 
@@ -207,14 +222,14 @@ public class Experiment implements Compa
     HashMap<String, String> environment = new HashMap<String, String>();
     environment.put("DUCC_UMASK", umask);
     // Synchronize with the check for a newer state file in ExperimentsRegistryManager to ensure that
-    // the file does not look newer that the in-memory Experiment
+    // the file time in memory matches the actual file time
     synchronized (this) {
       String sysout = DuccAsUser.execute(user, environment, "/bin/cp", tempFile.getAbsolutePath(), stateFile.getAbsolutePath());
       if (sysout.length() > 0) {
-        WsLog.error(logger, "writeExperiment", "Failed to copy experiment state file\n" + sysout);
+        WsLog.error(logger, mName, "Failed to copy experiment state file\n" + sysout);
         return false;
       }
-      fileDate = System.currentTimeMillis();   // Will be > actual filetime
+      fileDate = ExperimentsRegistryUtilities.getFileTime(user, stateFile);
       tempFile.delete();
       return true;
     }
@@ -272,6 +287,11 @@ public class Experiment implements Compa
         }
       }
     }
+    // Check if DUCC thinks JED is still running
+    // (the JED process may have ended but the updated state file may not yet be visible to DUCC)
+    if (jedWork != null) {
+      return jedWork.isCompleted();
+    }
     return true;
   }
 

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=1870194&r1=1870193&r2=1870194&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 Fri Nov 22 20:46:34 2019
@@ -34,7 +34,9 @@ import org.apache.uima.ducc.common.utils
 import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.transport.event.common.IDuccStandardInfo;
 import org.apache.uima.ducc.transport.event.common.IDuccWork;
+import org.apache.uima.ducc.transport.event.common.IDuccWorkJob;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkMap;
+import org.apache.uima.ducc.transport.event.common.IDuccWorkService;
 import org.apache.uima.ducc.ws.log.WsLog;
 
 import com.google.gson.Gson;
@@ -66,28 +68,20 @@ public class ExperimentsRegistryManager
     return experimentsByDir.get(directory);
   }
   
-  // Called by DuccPlugins with work restored from the DB when web-server boots
-  public void initialize(IDuccWork dw) {
-    //String mName = "initialize";
-    IDuccStandardInfo stdInfo = dw.getStandardInfo();
-    if (stdInfo != null) {
-      String experimentDirectory = stdInfo.getExperimentDirectory();
-      if (experimentDirectory != null) {
-        // Is a JED AP so check that we have the duccId of the latest AP even if not the first seen
-        seenDirs.add(experimentDirectory);
-        update(stdInfo.getUser(), experimentDirectory, dw);
-      } else {
-        // May be one of the tasks from a local or ducc-launched JED so process only the first
-        String logDirectory = stdInfo.getLogDirectory();
-        String parent = new File(logDirectory).getParent();
-        if (seenDirs.add(parent)) {
-          update(stdInfo.getUser(), parent, null);
-        }
-      }
-    }
+  /*
+   *  Called by DuccPlugins with work restored from the DB when web-server boots
+   */
+  public void initialize(IDuccWorkJob job) {
+    update(job);
   }
 
-  // Called by DuccPlugins for each OR publication
+  public void initialize(IDuccWorkService service) {
+    update(service);
+  }
+  
+  /*
+   * Called by DuccPlugins for each OR publication
+   */
   public void update(IDuccWorkMap dwm) {
     String mName = "update";
     if (dwm == null) {
@@ -98,41 +92,17 @@ public class ExperimentsRegistryManager
     try {
       // Inspect all jobs
       for (DuccId duccId : dwm.getJobKeySet()) {
-        IDuccWork job = dwm.findDuccWork(duccId);
+        IDuccWorkJob job = (IDuccWorkJob) dwm.findDuccWork(duccId);
         if (job != null) {
-          IDuccStandardInfo stdInfo = job.getStandardInfo();
-          if (stdInfo != null) {
-            String user = stdInfo.getUser();
-            String logDirectory = stdInfo.getLogDirectory();
-            String parent = new File(logDirectory).getParent();
-            if (seenDirs.add(parent)) {  // Process the first job with this parent dir
-              update(user, parent, null);
-            }
-          }
+          update(job);
         }
       }
 
-      // Inspect managed reservations ... check if a JED AP
+      // Inspect managed reservations ... internally are called services
       for (DuccId duccId : dwm.getManagedReservationKeySet()) {
-        IDuccWork work = dwm.findDuccWork(duccId);
-        if (work != null) {
-          IDuccStandardInfo stdInfo = work.getStandardInfo();
-          if (stdInfo != null) {
-            String user = stdInfo.getUser();
-            String experimentDirectory = stdInfo.getExperimentDirectory();
-            if (experimentDirectory != null) {
-              // Even if have seen this dir earlier we must check that we have the duccId of the latest AP
-              // JED tasks usually have a log dir 1 level below the exp dir
-              seenDirs.add(experimentDirectory);  // This prevents processing of any of its child jobs
-              update(user, experimentDirectory, work);
-            } else {
-              String logDirectory = stdInfo.getLogDirectory();
-              String parent = new File(logDirectory).getParent();
-              if (seenDirs.add(parent)) {    // Process the first AP with this parent dir
-                update(user, parent, null);  // (unless already seen as a JED exp dir)
-              }
-            }
-          }
+        IDuccWorkService service = (IDuccWorkService) dwm.findDuccWork(duccId);
+        if (service != null) {
+          update(service);
         }
       }
       prune();  // if list too large
@@ -141,8 +111,44 @@ public class ExperimentsRegistryManager
     }
   }
   
+  private void update(IDuccWorkJob job) {
+    IDuccStandardInfo stdInfo = job.getStandardInfo();
+    if (stdInfo != null) {
+      String user = stdInfo.getUser();
+      String logDirectory = stdInfo.getLogDirectory();
+      String parent = new File(logDirectory).getParent();
+      if (seenDirs.add(parent)) {  // Process the first job with this parent dir
+        update(user, parent, null);
+      }
+    }
+  }
+  
+  // Check if the managed reservation is a DUCC-launched AP
+  private void update(IDuccWorkService managedReservation) {
+    IDuccStandardInfo stdInfo = managedReservation.getStandardInfo();
+    if (stdInfo != null) {
+      String user = stdInfo.getUser();
+      String logDirectory = stdInfo.getLogDirectory();
+      File logDir = new File(logDirectory, managedReservation.getId());
+      File link = new File(logDir, "outputDirectoryLink");
+      String experimentDirectory = ExperimentsRegistryUtilities.readLink(user, link);
+      if (experimentDirectory != null) {
+        // Even if have seen this dir earlier we must check that we have the duccId of the latest AP
+        // JED tasks usually have a log dir 1 level below the exp dir
+        seenDirs.add(experimentDirectory); // This prevents processing of any of its child jobs
+        update(user, experimentDirectory, managedReservation);
+      } else {
+        String parent = new File(logDirectory).getParent();
+        if (seenDirs.add(parent)) { // Process the first AP with this parent dir
+          update(user, parent, null); // (unless already seen as a JED exp dir)
+        }
+      }
+    }
+  }
+  
   // Load or refresh the experiment
-  private void update(String user, String directory, IDuccWork work) {
+  // May need to run as the user if DUCC cannot read the user's files
+  private void update(String user, String directory, IDuccWork jedProcess) {
     String mName = "update";
     
     // "normalize" directory name
@@ -156,13 +162,15 @@ public class ExperimentsRegistryManager
     File stateFile = new File(directory, stateFileName);
     long fileTime = ExperimentsRegistryUtilities.getFileTime(user, stateFile);
     if (fileTime == 0) {
+	  //WsLog.trace(cName, mName, "Failed to find "+stateFile.getAbsolutePath());
       return;           // File not found
     }
     
     // Check if state file is newer than any existing one
     // If newer refresh it, otherwise just update the JED duccId in case it is a newer AP
+    // But if the experiment is running refresh the details as getFileDate may not reflect the latest changes
     Experiment existingExperiment = experimentsByDir.get(directory);
-    if (existingExperiment != null) {
+    if (existingExperiment != null && !existingExperiment.isActive()) {
       // Synchronize the check for a newer state file with the rewrite of the file in Experiment.writeStateFile
       // to ensure that the rewritten file does does not look newer that the in-memory Experiment
       long existingFileTime;
@@ -170,14 +178,14 @@ public class ExperimentsRegistryManager
         existingFileTime = existingExperiment.getFileDate();
       }
       if (fileTime <= existingFileTime) {    // No need to reload, but update the jED ID if newer
-        if (work != null) {
-          existingExperiment.updateJedId(work.getDuccId().getFriendly());
+        if (jedProcess != null) {
+          existingExperiment.updateJedWork(jedProcess);
         }
         return;
       }
-    }
+    } 
 
-    // Load or reload changed state file
+    // Load or reload changed state file (fileTime could be older than what is read here)
     String contents = ExperimentsRegistryUtilities.readFile(user, stateFile);
     if (contents == null) {
       WsLog.warn(cName, mName, "State file not found " + stateFile.getAbsolutePath());
@@ -193,10 +201,10 @@ public class ExperimentsRegistryManager
     Type typeOfTaskList = new TypeToken<ArrayList<Task>>(){}.getType();
     try {
       ArrayList<Task> taskArray = gson.fromJson(sr, typeOfTaskList);
-      Experiment experiment = new Experiment(user, directory, fileTime, taskArray, work);
+      Experiment experiment = new Experiment(user, directory, fileTime, taskArray, jedProcess);
       Experiment oldExperiment = experimentsByDir.put(directory, experiment);
       if (oldExperiment != null) {
-        experiment.updateJedId(oldExperiment.getJedId());    // Ensure the new instance has the latest DuccId
+        experiment.updateJedWork(oldExperiment.getJedWork());    // 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=1870194&r1=1870193&r2=1870194&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 Fri Nov 22 20:46:34 2019
@@ -83,6 +83,23 @@ public class ExperimentsRegistryUtilitie
     }
   }
 
+  public static String readLink(String user, File link) {
+    String mName = "readLink";
+    try {
+      File file = link.getCanonicalFile();
+      if (file.exists()) {
+        return file.getAbsolutePath();
+      }
+    } catch (Exception e) {
+      WsLog.error(cName,  mName,  e);
+    }
+    // May be unreadable by DUCC or may not exist!
+    // Use duccling to get time in "date" style seconds
+    String[] cmd = { "/usr/bin/readlink", link.getAbsolutePath() };
+    String result = DuccAsUser.execute(user, null, cmd).trim();
+    return result.length()==0 ? null : result;
+  }
+  
   public static boolean launchJed(Experiment experiment) {
     String mName = "launchJed";
     
@@ -162,7 +179,7 @@ public class ExperimentsRegistryUtilitie
     WsLog.info(cName, mName, sysout);
     
     // Should report: "Managed Reservation ### submitted."
-    // If successful save the ID of the JED AP
+    // If successful save the ID of the JED AP (the JED "work" object for this AP should be in the next OR publication)
     // If it fails return false and the restarting status will be reset by the caller
     boolean launched = sysout.startsWith("Managed Reservation");
     if (launched) {

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/$banner/c0-menu.jsp
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/%24banner/c0-menu.jsp?rev=1870194&r1=1870193&r2=1870194&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/$banner/c0-menu.jsp (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/$banner/c0-menu.jsp Fri Nov 22 20:46:34 2019
@@ -18,6 +18,7 @@ under the License.
 -->
 <div>
 <ul id="accordion">
+<%@ include file="../$experiments.jsp" %>
 <li><a href="jobs.html">Jobs</a></li>
 <ul></ul>
 <li><a href="reservations.html">Reservations</a></li>
@@ -34,6 +35,5 @@ under the License.
 <li><a href="system.machines.html">Machines</a></li>
 </ul>
 <li><a href="viz.html">Viz</a></li>
-<%@ include file="../$experiments.jsp" %>
 </ul>
 </div>