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/08/15 18:51:20 UTC
svn commit: r1865251 [3/3] - in
/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws:
./ handlers/experiments/ handlers/utilities/ log/ server/ xd/
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/log/WsLog.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/log/WsLog.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/log/WsLog.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/log/WsLog.java Thu Aug 15 18:51:19 2019
@@ -25,67 +25,65 @@ import org.apache.uima.ducc.common.utils
public class WsLog {
- private static DuccId duccId = null;
-
- public static void enter(DuccLogger logger, String mName) {
- logger.trace(mName, duccId, "enter");
- }
-
- public static void exit(DuccLogger logger, String mName) {
- logger.trace(mName, duccId, "exit");
- }
-
- public static void info(DuccLogger logger, String mName, String text) {
- logger.info(mName, duccId, text);
- }
-
- public static void info(DuccLogger logger, String mName, DuccId duccId, String text) {
- logger.info(mName, duccId, text);
- }
-
- public static void debug(DuccLogger logger, String mName, DuccId duccid, String text) {
- logger.debug(mName, duccid, text);
- }
-
- public static void debug(DuccLogger logger, String mName, String text) {
- logger.debug(mName, duccId, text);
- }
-
- public static void debug(DuccLogger logger, String mName, Exception e) {
- logger.debug(mName, duccId, e);
- }
-
- public static void debug(DuccLogger logger, String mName, Throwable t) {
- logger.debug(mName, duccId, t);
- }
-
- public static void trace(DuccLogger logger, String mName, String text) {
- logger.trace(mName, duccId, text);
- }
-
- public static void trace(DuccLogger logger, String mName, Exception e) {
- logger.trace(mName, duccId, e);
- }
-
- public static void trace(DuccLogger logger, String mName, Throwable t) {
- logger.trace(mName, duccId, t);
- }
-
- public static void error(DuccLogger logger, String mName, Exception e) {
- logger.error(mName, duccId, e);
- }
-
- public static void error(DuccLogger logger, String mName, Throwable t) {
- logger.error(mName, duccId, t);
- }
-
- public static void error(DuccLogger logger, String mName, String text) {
- logger.error(mName, duccId, text);
- }
-
- public static void warn(DuccLogger logger, String mName, String text) {
- logger.warn(mName, duccId, text);
- }
-}
+ private static DuccId duccId = null;
+
+ public static void enter(DuccLogger logger, String mName) {
+ logger.trace(mName, duccId, "enter");
+ }
+
+ public static void exit(DuccLogger logger, String mName) {
+ logger.trace(mName, duccId, "exit");
+ }
+
+ public static void info(DuccLogger logger, String mName, String text) {
+ logger.info(mName, duccId, text);
+ }
+
+ public static void info(DuccLogger logger, String mName, DuccId duccId, String text) {
+ logger.info(mName, duccId, text);
+ }
+
+ public static void debug(DuccLogger logger, String mName, DuccId duccid, String text) {
+ logger.debug(mName, duccid, text);
+ }
+
+ public static void debug(DuccLogger logger, String mName, String text) {
+ logger.debug(mName, duccId, text);
+ }
+
+ public static void debug(DuccLogger logger, String mName, Exception e) {
+ logger.debug(mName, duccId, e);
+ }
+ public static void debug(DuccLogger logger, String mName, Throwable t) {
+ logger.debug(mName, duccId, t);
+ }
+ public static void trace(DuccLogger logger, String mName, String text) {
+ logger.trace(mName, duccId, text);
+ }
+
+ public static void trace(DuccLogger logger, String mName, Exception e) {
+ logger.trace(mName, duccId, e);
+ }
+
+ public static void trace(DuccLogger logger, String mName, Throwable t) {
+ logger.trace(mName, duccId, t);
+ }
+
+ public static void error(DuccLogger logger, String mName, Exception e) {
+ logger.error(mName, duccId, e);
+ }
+
+ public static void error(DuccLogger logger, String mName, Throwable t) {
+ logger.error(mName, duccId, t);
+ }
+
+ public static void error(DuccLogger logger, String mName, String text) {
+ logger.error(mName, duccId, text);
+ }
+
+ public static void warn(DuccLogger logger, String mName, String text) {
+ logger.warn(mName, duccId, text);
+ }
+}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalConstants.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalConstants.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalConstants.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalConstants.java Thu Aug 15 18:51:19 2019
@@ -19,20 +19,26 @@
package org.apache.uima.ducc.ws.server;
public class DuccLocalConstants {
-
- public static final String duccContext = "/ducc-servlet";
-
- public static final String duccContextExperimentCancelRequest = duccContext+"/experiment-cancel-request";
-
- public static final String duccContextExperiments = duccContext+"/experiments-data";
- public static final String duccContextExperimentDetails = duccContext+"/experiment-details-data";
- public static final String duccContextExperimentDetailsDirectory = duccContext+"/experiment-details-directory";
- public static final String duccContextExperimentDetailsJobs = duccContext+"/experiment-details-jobs-data";
-
- public static final String duccContextJsonExperiments = duccContext+"/json-format-aaData-experiments";
- public static final String duccContextJsonExperimentDetails = duccContext+"/json-format-aaData-experiment-details";
- public static final String duccContextJsonExperimentDetailsJobs = duccContext+"/json-format-aaData-experiment-details-jobs";
-
- public static final int maximumRecordsExperiments = 4096;
- public static final int defaultRecordsExperiments = 16;
+
+ public static final String duccContext = "/ducc-servlet";
+
+ public static final String duccContextExperimentCancelRequest = duccContext + "/experiment-cancel-request";
+
+ public static final String duccContextExperiments = duccContext + "/experiments-data";
+
+ public static final String duccContextExperimentDetails = duccContext + "/experiment-details-data";
+
+ public static final String duccContextExperimentDetailsDirectory = duccContext + "/experiment-details-directory";
+
+ public static final String duccContextExperimentDetailsJobs = duccContext + "/experiment-details-jobs-data";
+
+ public static final String duccContextJsonExperiments = duccContext + "/json-format-aaData-experiments";
+
+ public static final String duccContextJsonExperimentDetails = duccContext + "/json-format-aaData-experiment-details";
+
+ public static final String duccContextJsonExperimentDetailsJobs = duccContext + "/json-format-aaData-experiment-details-jobs";
+
+ public static final int maximumRecordsExperiments = 4096;
+
+ public static final int defaultRecordsExperiments = 16;
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalCookies.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalCookies.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalCookies.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccLocalCookies.java Thu Aug 15 18:51:19 2019
@@ -19,15 +19,19 @@
package org.apache.uima.ducc.ws.server;
public class DuccLocalCookies {
-
- private static final String application = DuccCookies.duccCookiePrefix;
- private static final String max = DuccCookies.max;
- private static final String users = DuccCookies.users;
-
- private static final String experiments = "experiments";
-
- public static final String cookieExperimentsMax = application+experiments+max;
- public static final String cookieExperimentsUsers = application+experiments+users;
- //public static final String cookieExperimentsUsersQualifier = application+join+experiments+users+qualifier;
-
+
+ private static final String application = DuccCookies.duccCookiePrefix;
+
+ private static final String max = DuccCookies.max;
+
+ private static final String users = DuccCookies.users;
+
+ private static final String experiments = "experiments";
+
+ public static final String cookieExperimentsMax = application + experiments + max;
+
+ public static final String cookieExperimentsUsers = application + experiments + users;
+ // public static final String cookieExperimentsUsersQualifier =
+ // application+join+experiments+users+qualifier;
+
}
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=1865251&r1=1865250&r2=1865251&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 Aug 15 18:51:19 2019
@@ -24,98 +24,103 @@ import java.util.Date;
import java.util.UUID;
public class Experiment implements IExperiment {
-
- private String user = null;
- private String directory = null;
- private ArrayList<Task> tasks = null;
- private long fileDate = 0;
-
- private String id = UUID.randomUUID().toString();
- private int version;
-
- public Experiment(String user, String directory, long date, int version, ArrayList<Task> tasks) throws Exception {
- initialize(user, directory, date, version, tasks);
- }
-
- private void initialize(String user, String directory, long fileDate, int version, ArrayList<Task> tasks) throws Exception {
- if(user == null) {
- throw new ExperimentException("missing user");
- }
- if(directory == null) {
- throw new ExperimentException("missing directory");
- }
- if(tasks == null) {
- throw new ExperimentException("missing tasks");
- }
- this.user = user;
- this.directory = directory;
- this.fileDate = fileDate;
- this.version = version;
- this.tasks = tasks;
- }
-
- @Override
- public void setId(String value) {
- id = value;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public String getUser() {
- return user;
- }
-
- @Override
- public String getDirectory() {
- return directory;
- }
-
- @Override
- public ArrayList<Task> getTasks() {
- return tasks;
- }
-
- @Override
- public ArrayList<String> getJobIds() {
- ArrayList<String> jobIds = new ArrayList<String>();
- if(tasks != null) {
- for(Task task : tasks) {
- if(task.type != null) {
- Jed.Type jedType = Jed.Type.getEnum(task.type);
- switch(jedType) {
- case DuccJob:
- case Java:
- case Trainer:
- long[] duccIdList = task.duccId;
- for(long duccId : duccIdList) {
- if(duccId < 0) {
- // reservation
- }
- else {
- // job
- String jobId = ""+(0+duccId);
- jobIds.add(jobId);
- }
- }
- break;
- default:
- break;
- }
- }
- }
- }
- return jobIds;
- }
-
- @Override
- public int getVersion() {
- return version;
+
+ private String user = null;
+
+ private String directory = null;
+
+ private ArrayList<Task> tasks = null;
+
+ private long fileDate = 0;
+
+ private String id = UUID.randomUUID().toString();
+
+ private int version;
+
+ public Experiment(String user, String directory, long date, int version, ArrayList<Task> tasks)
+ throws Exception {
+ initialize(user, directory, date, version, tasks);
+ }
+
+ private void initialize(String user, String directory, long fileDate, int version,
+ ArrayList<Task> tasks) throws Exception {
+ if (user == null) {
+ throw new ExperimentException("missing user");
+ }
+ if (directory == null) {
+ throw new ExperimentException("missing directory");
+ }
+ if (tasks == null) {
+ throw new ExperimentException("missing tasks");
+ }
+ this.user = user;
+ this.directory = directory;
+ this.fileDate = fileDate;
+ this.version = version;
+ this.tasks = tasks;
+ }
+
+ @Override
+ public void setId(String value) {
+ id = value;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getUser() {
+ return user;
+ }
+
+ @Override
+ public String getDirectory() {
+ return directory;
+ }
+
+ @Override
+ public ArrayList<Task> getTasks() {
+ return tasks;
+ }
+
+ @Override
+ public ArrayList<String> getJobIds() {
+ ArrayList<String> jobIds = new ArrayList<String>();
+ if (tasks != null) {
+ for (Task task : tasks) {
+ if (task.type != null) {
+ Jed.Type jedType = Jed.Type.getEnum(task.type);
+ switch (jedType) {
+ case DuccJob:
+ case Java:
+ case Trainer:
+ long[] duccIdList = task.duccId;
+ for (long duccId : duccIdList) {
+ if (duccId < 0) {
+ // reservation
+ } else {
+ // job
+ String jobId = "" + (0 + duccId);
+ jobIds.add(jobId);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
-
+ return jobIds;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
@Override
public boolean isActive() {
boolean retVal = false;
@@ -128,217 +133,213 @@ public class Experiment implements IExpe
}
return retVal;
}
-
- @Override
- public Jed.Status getStatus() {
- Jed.Status retVal = Jed.Status.Unknown;
- ArrayList<Task> tasks = getTasks();
- if(tasks != null) {
- boolean canceled = false;
- boolean failed = false;
- boolean running = false;
- boolean done = false;
- for (Task task : tasks) {
- if (task.parentId == 0 && task.status != null) {
- Jed.Status status = Jed.Status.getEnum(task.status);
- switch (status) {
- case Canceled:
- canceled = true;
- break;
- case Running:
- running = true;
- break;
- case Failed:
- case DependencyFailed:
- failed = true;
- break;
- case Done:
- case Completed:
- done = true;
- break;
- default:
- break;
- }
- }
- }
- // If more than 1 parent task use the most "important" state
- // Running > Failed/DependencyFailed > Canceled > Done/Completed
- // But if JED appears to have been killed while running change state to Unknown
- if(running) {
- retVal = isStale() ? Jed.Status.Unknown : Jed.Status.Running;
- }
- else if(failed) {
- retVal = Jed.Status.Failed;
- }
- else if(canceled) {
- retVal = Jed.Status.Canceled;
- }
- else if(done) {
- retVal = Jed.Status.Done;
- }
- else {
- retVal = Jed.Status.Unknown;
- }
- }
- return retVal;
- }
-
- private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss");
-
- private static long getMillis(String dateString) {
- long retVal = 0;
- try {
- if(dateString != null) {
- Date date = sdf.parse(dateString);
- retVal = date.getTime();
- }
- }
- catch(Exception e) {
- }
- return retVal;
- }
-
- @Override
- public long getStartTime() {
- return getMillis(getStartDate());
- }
-
- @Override
- public String getStartDate() {
- String retVal = "";
- long experimentStartMillis = Long.MAX_VALUE;
- if(tasks != null) {
- for(Task task : tasks) {
- String dateString = task.startTime;
- if(dateString != null) {
- long taskStartMillis = getMillis(dateString);
- if(taskStartMillis < experimentStartMillis) {
- experimentStartMillis = taskStartMillis;
- retVal = dateString;
- }
- }
- }
- }
- return retVal;
- }
-
- @Override
- public void setFileDate(long value) {
- fileDate = value;
- }
-
- @Override
- public long getFileDate() {
- return fileDate;
- }
-
- private long staleTime = 1000 * 60 * 6;
- private long staleTimeOld = 1000 * 60 * 60 * 24;
-
- @Override
- public boolean isStale() {
- // If the log file has been removed then the driver has stopped.
- // If the lock file is still present the driver may have been killed, so check the age of the state file.
- // If an old version-less file then may have a long job running so wait 24 hrs - new ones are touched every 5 mins
- // Check that the lock-file exists by reading it as the user if necessary,
- boolean logLocked = null != ExperimentsRegistryUtilities.getFileContents(user, directory + "/DRIVER.log.lck");
- if (logLocked) {
- long now = System.currentTimeMillis();
- long fileDate = ExperimentsRegistryUtilities.getFileDate(this);
- if (fileDate > 0) {
- if (fileDate < now) {
- long elapsed = now - fileDate;
- long tStale = (version == 0) ? staleTimeOld : staleTime;
- if (elapsed < tStale) {
- return false;
- }
- }
- }
+
+ @Override
+ public Jed.Status getStatus() {
+ Jed.Status retVal = Jed.Status.Unknown;
+ ArrayList<Task> tasks = getTasks();
+ if (tasks != null) {
+ boolean canceled = false;
+ boolean failed = false;
+ boolean running = false;
+ boolean done = false;
+ for (Task task : tasks) {
+ if (task.parentId == 0 && task.status != null) {
+ Jed.Status status = Jed.Status.getEnum(task.status);
+ switch (status) {
+ case Canceled:
+ canceled = true;
+ break;
+ case Running:
+ running = true;
+ break;
+ case Failed:
+ case DependencyFailed:
+ failed = true;
+ break;
+ case Done:
+ case Completed:
+ done = true;
+ break;
+ default:
+ break;
+ }
}
- return true;
- }
-
- @Override
- public int hashCode() {
- return directory.hashCode();
- }
-
- @Override
- public int compareTo(Object object) {
- int retVal = 0;
- if(object != null) {
- if(object instanceof Experiment) {
- Experiment that = (Experiment)object;
- if(retVal == 0) {
- retVal = compareState(that);
- }
- if(retVal == 0) {
- retVal = compareStartDate(that);
- }
- if(retVal == 0) {
- retVal = compareDirectory(that);
- }
- if(retVal == 0) {
- retVal = compareUser(that);
- }
- }
- }
- return retVal;
- }
-
- private int compareState(Experiment that) {
- int retVal = 0;
- if(this.isActive()) {
- if(that.isActive()) {
- //retVal = 0;
- }
- else {
- retVal = -1;
- }
- }
- else {
- if(that.isActive()) {
- retVal = 1;
- }
- else {
- //retVal = 0;
- }
- }
- return retVal;
- }
-
- private int compareStrings(String s0, String s1) {
- int retVal = 0;
- if(s0 != null) {
- if(s1 != null) {
- retVal = s1.compareTo(s0);
- }
- }
- return retVal;
- }
-
- private int compareStartDate(Experiment that) {
- int retVal = 0;
- if(that != null) {
- retVal = compareStrings(this.getStartDate(), that.getStartDate());
- }
- return retVal;
- }
-
- private int compareDirectory(Experiment that) {
- int retVal = 0;
- if(that != null) {
- retVal = compareStrings(this.getDirectory(), that.getDirectory());
- }
- return retVal;
- }
-
- private int compareUser(Experiment that) {
- int retVal = 0;
- if(that != null) {
- retVal = compareStrings(this.getUser(), that.getUser());
- }
- return retVal;
- }
+ }
+ // If more than 1 parent task use the most "important" state
+ // Running > Failed/DependencyFailed > Canceled > Done/Completed
+ // But if JED appears to have been killed while running change state to Unknown
+ if (running) {
+ retVal = isStale() ? Jed.Status.Unknown : Jed.Status.Running;
+ } else if (failed) {
+ retVal = Jed.Status.Failed;
+ } else if (canceled) {
+ retVal = Jed.Status.Canceled;
+ } else if (done) {
+ retVal = Jed.Status.Done;
+ } else {
+ retVal = Jed.Status.Unknown;
+ }
+ }
+ return retVal;
+ }
+
+ private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss");
+
+ private static long getMillis(String dateString) {
+ long retVal = 0;
+ try {
+ if (dateString != null) {
+ Date date = sdf.parse(dateString);
+ retVal = date.getTime();
+ }
+ } catch (Exception e) {
+ }
+ return retVal;
+ }
+
+ @Override
+ public long getStartTime() {
+ return getMillis(getStartDate());
+ }
+
+ @Override
+ public String getStartDate() {
+ String retVal = "";
+ long experimentStartMillis = Long.MAX_VALUE;
+ if (tasks != null) {
+ for (Task task : tasks) {
+ String dateString = task.startTime;
+ if (dateString != null) {
+ long taskStartMillis = getMillis(dateString);
+ if (taskStartMillis < experimentStartMillis) {
+ experimentStartMillis = taskStartMillis;
+ retVal = dateString;
+ }
+ }
+ }
+ }
+ return retVal;
+ }
+
+ @Override
+ public void setFileDate(long value) {
+ fileDate = value;
+ }
+
+ @Override
+ public long getFileDate() {
+ return fileDate;
+ }
+
+ private long staleTime = 1000 * 60 * 6;
+
+ private long staleTimeOld = 1000 * 60 * 60 * 24;
+
+ @Override
+ public boolean isStale() {
+ // If the log file has been removed then the driver has stopped.
+ // If the lock file is still present the driver may have been killed, so check the age of the
+ // state file.
+ // If an old version-less file then may have a long job running so wait 24 hrs - new ones are
+ // touched every 5 mins
+ // Check that the lock-file exists by reading it as the user if necessary,
+ boolean logLocked = null != ExperimentsRegistryUtilities.getFileContents(user,
+ directory + "/DRIVER.log.lck");
+ if (logLocked) {
+ long now = System.currentTimeMillis();
+ long fileDate = ExperimentsRegistryUtilities.getFileDate(this);
+ if (fileDate > 0) {
+ if (fileDate < now) {
+ long elapsed = now - fileDate;
+ long tStale = (version == 0) ? staleTimeOld : staleTime;
+ if (elapsed < tStale) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return directory.hashCode();
+ }
+
+ @Override
+ public int compareTo(Object object) {
+ int retVal = 0;
+ if (object != null) {
+ if (object instanceof Experiment) {
+ Experiment that = (Experiment) object;
+ if (retVal == 0) {
+ retVal = compareState(that);
+ }
+ if (retVal == 0) {
+ retVal = compareStartDate(that);
+ }
+ if (retVal == 0) {
+ retVal = compareDirectory(that);
+ }
+ if (retVal == 0) {
+ retVal = compareUser(that);
+ }
+ }
+ }
+ return retVal;
+ }
+
+ private int compareState(Experiment that) {
+ int retVal = 0;
+ if (this.isActive()) {
+ if (that.isActive()) {
+ // retVal = 0;
+ } else {
+ retVal = -1;
+ }
+ } else {
+ if (that.isActive()) {
+ retVal = 1;
+ } else {
+ // retVal = 0;
+ }
+ }
+ return retVal;
+ }
+
+ private int compareStrings(String s0, String s1) {
+ int retVal = 0;
+ if (s0 != null) {
+ if (s1 != null) {
+ retVal = s1.compareTo(s0);
+ }
+ }
+ return retVal;
+ }
+
+ private int compareStartDate(Experiment that) {
+ int retVal = 0;
+ if (that != null) {
+ retVal = compareStrings(this.getStartDate(), that.getStartDate());
+ }
+ return retVal;
+ }
+
+ private int compareDirectory(Experiment that) {
+ int retVal = 0;
+ if (that != null) {
+ retVal = compareStrings(this.getDirectory(), that.getDirectory());
+ }
+ return retVal;
+ }
+
+ private int compareUser(Experiment that) {
+ int retVal = 0;
+ if (that != null) {
+ retVal = compareStrings(this.getUser(), that.getUser());
+ }
+ return retVal;
+ }
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentException.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentException.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentException.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/ExperimentException.java Thu Aug 15 18:51:19 2019
@@ -19,10 +19,10 @@
package org.apache.uima.ducc.ws.xd;
public class ExperimentException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public ExperimentException(String text) {
- super(text);
- }
+
+ private static final long serialVersionUID = 1L;
+
+ public ExperimentException(String text) {
+ super(text);
+ }
}
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=1865251&r1=1865250&r2=1865251&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 Aug 15 18:51:19 2019
@@ -40,298 +40,287 @@ import com.google.gson.reflect.TypeToken
public class ExperimentsRegistryManager {
// NOTE - this variable used to hold the class name before WsLog was simplified
- private static DuccLogger cName = DuccLogger.getLogger(ExperimentsRegistryManager.class);
-
- private static Gson gson = new Gson();
- private static ExperimentsRegistryManager instance = new ExperimentsRegistryManager();
-
- private int MAX_CACHE_SIZE = 4096;
-
- private TreeMap<String,IExperiment> map = new TreeMap<String,IExperiment>();
-
- private AtomicLong updateCounter = new AtomicLong(0);
-
- public static ExperimentsRegistryManager getInstance() {
- return instance;
- }
-
- public TreeMap<IExperiment,String> getMapByStatus() {
- TreeMap<IExperiment,String> mapInverse = new TreeMap<IExperiment,String>();
- synchronized(map) {
- for(Entry<String, IExperiment> entry : map.entrySet()) {
- mapInverse.put(entry.getValue(), entry.getKey());
- }
- }
- return mapInverse;
- }
-
- private TreeMap<Long, String> getMapByDate() {
- TreeMap<Long, String> mapByDate = new TreeMap<Long, String>();
- synchronized(map) {
- for(Entry<String, IExperiment> entry : map.entrySet()) {
- IExperiment experiment = entry.getValue();
- Long key = new Long(experiment.getStartTime());
- String value = experiment.getId();
- mapByDate.put(key, value);
- }
- }
- return mapByDate;
- }
-
- public IExperiment getById(String id) {
- IExperiment retVal = null;
- if(id != null) {
- synchronized(map) {
- for(Entry<String, IExperiment> entry : map.entrySet()) {
- IExperiment experiment = entry.getValue();
- if(id.equals(experiment.getId())) {
- retVal = experiment;
- break;
- }
- }
- }
- }
- return retVal;
- }
-
- private void replace(String directory, Experiment experiment) {
- String mName = "replace";
- String id = map.get(directory).getId();
- experiment.setId(id);
- map.put(directory, experiment);
- WsLog.debug(cName, mName, directory);
- }
-
- private void add(String directory, Experiment experiment) {
- String mName = "add";
- map.put(directory, experiment);
- WsLog.debug(cName, mName, directory);
- }
-
- private void put(String directory, Experiment experiment) {
- synchronized(map) {
- if(map.containsKey(directory)) {
- replace(directory, experiment);
- }
- else {
- add(directory, experiment);
- }
- }
- }
-
- private void remove(String directory) {
- String mName = "remove";
- synchronized(map) {
- map.remove(directory);
-
- }
- WsLog.debug(cName, mName, directory);
- }
-
- private boolean containsKey(String directory) {
- synchronized(map) {
- return map.containsKey(directory);
- }
- }
-
- public void initialize(String user, String directory) {
- String mName = "initialize";
- if(user == null) {
- WsLog.warn(cName, mName, "missing user");
- }
- else if(directory == null) {
- WsLog.warn(cName, mName, "missing directory");
- }
- else {
- String parent = ExperimentsRegistryUtilities.upOne(directory);
- update(user, parent, false);
- }
- }
-
- private void update(String user, String directory) {
- String mName = "update";
- try {
- String fileName = ExperimentsRegistryUtilities.getStateFilePath(directory);
- long date = ExperimentsRegistryUtilities.getFileDate(user, fileName);
- WsLog.info(cName, mName, "Reading " + fileName + " date: " + date);
- String contents = ExperimentsRegistryUtilities.getFileContents(user, fileName);
- if(contents != null) {
- // Version may precede the initial '[' and may be on a separate line
- int version = 0;
- int offset = contents.indexOf('[');
- if (offset > 0) {
- String s = contents.substring(0, offset).trim();
- try {
- version = Integer.parseInt(s);
- } catch (NumberFormatException e) {
- WsLog.warn(cName, mName, "Invalid version '" + s + "' in state file : " + fileName);
- return;
- }
- contents = contents.substring(offset);
- }
- if (offset < 0) {
- WsLog.warn(cName, mName, "Invalid syntax (missing '[') in state file : " + fileName);
- return;
- }
- StringReader sr = new StringReader(contents);
- Type tasksType = new TypeToken<ArrayList<Task>>(){}.getType();
- try {
- ArrayList<Task> taskArray = gson.fromJson(sr, tasksType);
- Experiment experiment = new Experiment(user, directory, date, version, taskArray);
- put(directory, experiment);
- } catch (JsonParseException e) {
- WsLog.warn(cName, mName,"Ignoring " + fileName + " as has Json syntax error " + e.getMessage());
- }
- }
- else {
- WsLog.trace(cName, mName,"state file missing or inaccessible in "+directory);
- remove(directory);
- }
- }
- catch(Exception e) {
- WsLog.error(cName, mName, e);
- }
- }
-
- private void update(String user, String directory, boolean overwrite) {
- String mName = "update";
- WsLog.enter(cName, mName);
- try {
- if(overwrite) {
- update(user, directory);
- }
- else {
- if(!containsKey(directory)) {
- update(user, directory);
- }
- else {
- WsLog.trace(cName, mName, "duplicate directory: "+directory);
- }
- }
-
- }
- catch(Exception e) {
- WsLog.error(cName, mName, e);
- }
- //WsLog.exit(cName, mName);
- }
-
- private void check() {
- String mName = "check";
- try {
- ArrayList<IExperiment> list = new ArrayList<IExperiment>();
- synchronized(map) {
- for(Entry<String, IExperiment> entry : map.entrySet()) {
- IExperiment experiment = entry.getValue();
- if(experiment.isActive()) {
- list.add(experiment);
- }
- }
- }
- for(IExperiment experiment : list) {
- String user = experiment.getUser();
- String directory = experiment.getDirectory();
- WsLog.debug(cName, mName, "user: "+user+" "+"dirextory: "+directory);
- update(experiment.getUser(), experiment.getDirectory(), true);
- }
- }
- catch(Exception e) {
- WsLog.error(cName, mName, e);
- }
- }
-
- private boolean timeToPrune() {
- boolean retVal = false;
- TreeMap<Long, String> mapByDate = getMapByDate();
- int size = mapByDate.size();
- if(size > MAX_CACHE_SIZE) {
- retVal = true;
- }
- if((updateCounter.get() % 3) == 0) {
- retVal = true;
- }
- return retVal;
- }
-
- private void prune() {
- String mName = "prune";
- WsLog.enter(cName, mName);
- try {
- TreeMap<Long, String> mapByDate = getMapByDate();
- if(timeToPrune()) {
- int cacheCount = 0;
- for(Entry<Long, String> entry : mapByDate.entrySet()) {
- String key = entry.getValue();
- IExperiment experiment = getById(key);
- if(experiment != null) {
- if(experiment.isActive()) {
- cacheCount++;
- }
- else {
- if(cacheCount < MAX_CACHE_SIZE) {
- cacheCount++;
- }
- else {
- String directory = experiment.getDirectory();
- remove(directory);
- }
- }
- }
- }
- }
- }
- catch(Exception e) {
- WsLog.error(cName, mName, e);
- }
- //WsLog.exit(cName, mName);
- }
-
- public void update(IDuccWorkMap dwm) {
- String mName = "update";
- WsLog.enter(cName, mName);
- try {
- if(dwm == null) {
- WsLog.warn(cName, mName, "missing map");
- }
- else {
- updateCounter.incrementAndGet();
- Iterator<DuccId> iterator = dwm.getJobKeySet().iterator();
- while(iterator.hasNext()) {
- DuccId duccId = iterator.next();
- IDuccWork job = dwm.findDuccWork(duccId);
- if(job != null) {
- IDuccStandardInfo stdInfo = job.getStandardInfo();
- if(stdInfo != null) {
- String user = stdInfo.getUser();
- String directory = stdInfo.getLogDirectory();
- String parent = ExperimentsRegistryUtilities.upOne(directory);
- update(user, parent, true);
- }
- }
- }
-
- // Also process managed reservations in case the experiment has only these.
- iterator = dwm.getManagedReservationKeySet().iterator();
- while(iterator.hasNext()) {
- DuccId duccId = iterator.next();
- IDuccWork job = dwm.findDuccWork(duccId);
- if(job != null) {
- IDuccStandardInfo stdInfo = job.getStandardInfo();
- if(stdInfo != null) {
- String user = stdInfo.getUser();
- String directory = stdInfo.getLogDirectory();
- String parent = ExperimentsRegistryUtilities.upOne(directory);
- update(user, parent, true);
- }
- }
- }
- }
- check();
- prune();
- }
- catch(Exception e) {
- WsLog.error(cName, mName, e);
- }
- //WsLog.exit(cName, mName);
- }
+ private static DuccLogger cName = DuccLogger.getLogger(ExperimentsRegistryManager.class);
+
+ private static Gson gson = new Gson();
+
+ private static ExperimentsRegistryManager instance = new ExperimentsRegistryManager();
+
+ private int MAX_CACHE_SIZE = 4096;
+
+ private TreeMap<String, IExperiment> map = new TreeMap<String, IExperiment>();
+
+ private AtomicLong updateCounter = new AtomicLong(0);
+
+ public static ExperimentsRegistryManager getInstance() {
+ return instance;
+ }
+
+ public TreeMap<IExperiment, String> getMapByStatus() {
+ TreeMap<IExperiment, String> mapInverse = new TreeMap<IExperiment, String>();
+ synchronized (map) {
+ for (Entry<String, IExperiment> entry : map.entrySet()) {
+ mapInverse.put(entry.getValue(), entry.getKey());
+ }
+ }
+ return mapInverse;
+ }
+
+ private TreeMap<Long, String> getMapByDate() {
+ TreeMap<Long, String> mapByDate = new TreeMap<Long, String>();
+ synchronized (map) {
+ for (Entry<String, IExperiment> entry : map.entrySet()) {
+ IExperiment experiment = entry.getValue();
+ Long key = new Long(experiment.getStartTime());
+ String value = experiment.getId();
+ mapByDate.put(key, value);
+ }
+ }
+ return mapByDate;
+ }
+
+ public IExperiment getById(String id) {
+ IExperiment retVal = null;
+ if (id != null) {
+ synchronized (map) {
+ for (Entry<String, IExperiment> entry : map.entrySet()) {
+ IExperiment experiment = entry.getValue();
+ if (id.equals(experiment.getId())) {
+ retVal = experiment;
+ break;
+ }
+ }
+ }
+ }
+ return retVal;
+ }
+
+ private void replace(String directory, Experiment experiment) {
+ String mName = "replace";
+ String id = map.get(directory).getId();
+ experiment.setId(id);
+ map.put(directory, experiment);
+ WsLog.debug(cName, mName, directory);
+ }
+
+ private void add(String directory, Experiment experiment) {
+ String mName = "add";
+ map.put(directory, experiment);
+ WsLog.debug(cName, mName, directory);
+ }
+
+ private void put(String directory, Experiment experiment) {
+ synchronized (map) {
+ if (map.containsKey(directory)) {
+ replace(directory, experiment);
+ } else {
+ add(directory, experiment);
+ }
+ }
+ }
+
+ private void remove(String directory) {
+ String mName = "remove";
+ synchronized (map) {
+ map.remove(directory);
+
+ }
+ WsLog.debug(cName, mName, directory);
+ }
+
+ private boolean containsKey(String directory) {
+ synchronized (map) {
+ return map.containsKey(directory);
+ }
+ }
+
+ public void initialize(String user, String directory) {
+ String mName = "initialize";
+ if (user == null) {
+ WsLog.warn(cName, mName, "missing user");
+ } else if (directory == null) {
+ WsLog.warn(cName, mName, "missing directory");
+ } else {
+ String parent = ExperimentsRegistryUtilities.upOne(directory);
+ update(user, parent, false);
+ }
+ }
+
+ private void update(String user, String directory) {
+ String mName = "update";
+ try {
+ String fileName = ExperimentsRegistryUtilities.getStateFilePath(directory);
+ long date = ExperimentsRegistryUtilities.getFileDate(user, fileName);
+ WsLog.info(cName, mName, "Reading " + fileName + " date: " + date);
+ String contents = ExperimentsRegistryUtilities.getFileContents(user, fileName);
+ if (contents != null) {
+ // Version may precede the initial '[' and may be on a separate line
+ int version = 0;
+ int offset = contents.indexOf('[');
+ if (offset > 0) {
+ String s = contents.substring(0, offset).trim();
+ try {
+ version = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ WsLog.warn(cName, mName, "Invalid version '" + s + "' in state file : " + fileName);
+ return;
+ }
+ contents = contents.substring(offset);
+ }
+ if (offset < 0) {
+ WsLog.warn(cName, mName, "Invalid syntax (missing '[') in state file : " + fileName);
+ return;
+ }
+ StringReader sr = new StringReader(contents);
+ Type tasksType = new TypeToken<ArrayList<Task>>() {
+ }.getType();
+ try {
+ ArrayList<Task> taskArray = gson.fromJson(sr, tasksType);
+ Experiment experiment = new Experiment(user, directory, date, version, taskArray);
+ put(directory, experiment);
+ } catch (JsonParseException e) {
+ WsLog.warn(cName, mName,
+ "Ignoring " + fileName + " as has Json syntax error " + e.getMessage());
+ }
+ } else {
+ WsLog.trace(cName, mName, "state file missing or inaccessible in " + directory);
+ remove(directory);
+ }
+ } catch (Exception e) {
+ WsLog.error(cName, mName, e);
+ }
+ }
+
+ private void update(String user, String directory, boolean overwrite) {
+ String mName = "update";
+ WsLog.enter(cName, mName);
+ try {
+ if (overwrite) {
+ update(user, directory);
+ } else {
+ if (!containsKey(directory)) {
+ update(user, directory);
+ } else {
+ WsLog.trace(cName, mName, "duplicate directory: " + directory);
+ }
+ }
+
+ } catch (Exception e) {
+ WsLog.error(cName, mName, e);
+ }
+ // WsLog.exit(cName, mName);
+ }
+
+ private void check() {
+ String mName = "check";
+ try {
+ ArrayList<IExperiment> list = new ArrayList<IExperiment>();
+ synchronized (map) {
+ for (Entry<String, IExperiment> entry : map.entrySet()) {
+ IExperiment experiment = entry.getValue();
+ if (experiment.isActive()) {
+ list.add(experiment);
+ }
+ }
+ }
+ for (IExperiment experiment : list) {
+ String user = experiment.getUser();
+ String directory = experiment.getDirectory();
+ WsLog.debug(cName, mName, "user: " + user + " " + "dirextory: " + directory);
+ update(experiment.getUser(), experiment.getDirectory(), true);
+ }
+ } catch (Exception e) {
+ WsLog.error(cName, mName, e);
+ }
+ }
+
+ private boolean timeToPrune() {
+ boolean retVal = false;
+ TreeMap<Long, String> mapByDate = getMapByDate();
+ int size = mapByDate.size();
+ if (size > MAX_CACHE_SIZE) {
+ retVal = true;
+ }
+ if ((updateCounter.get() % 3) == 0) {
+ retVal = true;
+ }
+ return retVal;
+ }
+
+ private void prune() {
+ String mName = "prune";
+ WsLog.enter(cName, mName);
+ try {
+ TreeMap<Long, String> mapByDate = getMapByDate();
+ if (timeToPrune()) {
+ int cacheCount = 0;
+ for (Entry<Long, String> entry : mapByDate.entrySet()) {
+ String key = entry.getValue();
+ IExperiment experiment = getById(key);
+ if (experiment != null) {
+ if (experiment.isActive()) {
+ cacheCount++;
+ } else {
+ if (cacheCount < MAX_CACHE_SIZE) {
+ cacheCount++;
+ } else {
+ String directory = experiment.getDirectory();
+ remove(directory);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ WsLog.error(cName, mName, e);
+ }
+ // WsLog.exit(cName, mName);
+ }
+
+ public void update(IDuccWorkMap dwm) {
+ String mName = "update";
+ WsLog.enter(cName, mName);
+ try {
+ if (dwm == null) {
+ WsLog.warn(cName, mName, "missing map");
+ } else {
+ updateCounter.incrementAndGet();
+ Iterator<DuccId> iterator = dwm.getJobKeySet().iterator();
+ while (iterator.hasNext()) {
+ DuccId duccId = iterator.next();
+ IDuccWork job = dwm.findDuccWork(duccId);
+ if (job != null) {
+ IDuccStandardInfo stdInfo = job.getStandardInfo();
+ if (stdInfo != null) {
+ String user = stdInfo.getUser();
+ String directory = stdInfo.getLogDirectory();
+ String parent = ExperimentsRegistryUtilities.upOne(directory);
+ update(user, parent, true);
+ }
+ }
+ }
+
+ // Also process managed reservations in case the experiment has only these.
+ iterator = dwm.getManagedReservationKeySet().iterator();
+ while (iterator.hasNext()) {
+ DuccId duccId = iterator.next();
+ IDuccWork job = dwm.findDuccWork(duccId);
+ if (job != null) {
+ IDuccStandardInfo stdInfo = job.getStandardInfo();
+ if (stdInfo != null) {
+ String user = stdInfo.getUser();
+ String directory = stdInfo.getLogDirectory();
+ String parent = ExperimentsRegistryUtilities.upOne(directory);
+ update(user, parent, true);
+ }
+ }
+ }
+ }
+ check();
+ prune();
+ } catch (Exception e) {
+ WsLog.error(cName, mName, e);
+ }
+ // WsLog.exit(cName, mName);
+ }
}
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=1865251&r1=1865250&r2=1865251&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 Aug 15 18:51:19 2019
@@ -29,150 +29,147 @@ import org.apache.uima.ducc.common.utils
import org.apache.uima.ducc.ws.log.WsLog;
public class ExperimentsRegistryUtilities {
-
+
// NOTE - this variable used to hold the class name before WsLog was simplified
- private static DuccLogger cName = DuccLogger.getLogger(ExperimentsRegistryUtilities.class);
-
- private static String stateFileName = "Experiment.state";
-
- public static String upOne(String directory) {
- String retVal = directory;
- if(directory != null) {
- retVal = new File(directory).getParent();
- }
- return retVal;
- }
-
- public static String getStateFilePath(String directory) {
- String retVal = new File(directory, stateFileName).getAbsolutePath();
- return retVal;
- }
-
- private static void closer(Closeable object) {
- String mName = "closer";
- try {
- object.close();
- }
- catch(Exception e) {
- WsLog.debug(cName, mName, e);
- }
- }
-
- public static long getFileDate(IExperiment experiment) {
- String mName = "getFileDate";
- WsLog.enter(cName, mName);
- String user = experiment.getUser();
- String filename = getStateFilePath(experiment.getDirectory());
- long retVal = getFileDate(user, filename);
- return retVal;
- }
-
- public static long getFileDate(String user, String filename) {
- String mName = "getFileDate";
- WsLog.enter(cName, mName);
- long retVal = getDomesticFileDate(user, filename);
- if(retVal == 0) {
- retVal = getAlienFileDate(user, filename);
- }
- WsLog.exit(cName, mName);
- return retVal;
- }
-
- private static long getAlienFileDate(String user, String filename) {
- String mName = "getAlienFileDate";
- WsLog.enter(cName, mName);
- long retVal = 0;
- AlienFile alienFile = new AlienFile(user, filename);
- // NOTE - should not need the "--" ... or this could be moved to AlienFile
- String[] lines = alienFile.getResult(false, "--", "/bin/ls", "-l", "--time-style=+%s", filename );
- // Should have 1 line with secs-since-epoch in 6th token
- if (lines.length == 1) {
- String[] toks = lines[0].split("\\s+");
- if (toks.length >= 6) {
- retVal = Long.valueOf(toks[5]) * 1000;
- }
- }
- WsLog.exit(cName, mName);
- return retVal;
- }
-
- private static long getDomesticFileDate(String user, String filename) {
- String mName = "getDomesticFileDate";
- WsLog.enter(cName, mName);
- long retVal =0;
- try {
- File file = new File(filename);
- retVal = file.lastModified();
- }
- catch(Exception e) {
- WsLog.trace(cName, mName, e);
- }
- WsLog.exit(cName, mName);
- return retVal;
- }
-
- /*
- * Returns null if file is missing or can't be read
- */
- public static String getFileContents(String user, String filename) {
- String mName = "getFileContents";
- WsLog.enter(cName, mName);
- boolean canRead = ((new File(filename)).canRead());
- String retVal = canRead ? getDomesticFileContents(user, filename) : getAlienFileContents(user, filename);
- WsLog.exit(cName, mName);
- return retVal;
- }
-
- private static String getAlienFileContents(String user, String filename) {
- String mName = "getAlienFileContents";
- WsLog.enter(cName, mName);
- String retVal = null;
- try {
- AlienFile alienFile = new AlienFile(user, filename);
- retVal = alienFile.getString();
- }
- catch(Throwable t) {
- WsLog.trace(cName, mName, t);
- }
-
- WsLog.exit(cName, mName);
- return retVal;
- }
-
- private static String getDomesticFileContents(String user, String filename) {
- String mName = "getDomesticFileContents";
- WsLog.enter(cName, mName);
- String retVal = null;
- FileReader fr = null;
- BufferedReader br = null;
- StringReader sr = null;
- try {
- fr = new FileReader(filename);
- br = new BufferedReader(fr);
- StringBuffer sb = new StringBuffer();
- String line = br.readLine();
- while(line != null) {
- sb.append(line);
- line = br.readLine();
- }
- retVal = sb.toString();
- }
- catch(Exception e) {
- WsLog.debug(cName, mName, e);
- }
- finally {
- if(br != null) {
- closer(br);
- }
- if(fr != null) {
- closer(fr);
- }
- if(sr != null) {
- closer(sr);
- }
- }
- WsLog.exit(cName, mName);
- return retVal;
- }
+ private static DuccLogger cName = DuccLogger.getLogger(ExperimentsRegistryUtilities.class);
+
+ private static String stateFileName = "Experiment.state";
+
+ public static String upOne(String directory) {
+ String retVal = directory;
+ if (directory != null) {
+ retVal = new File(directory).getParent();
+ }
+ return retVal;
+ }
+
+ public static String getStateFilePath(String directory) {
+ String retVal = new File(directory, stateFileName).getAbsolutePath();
+ return retVal;
+ }
+
+ private static void closer(Closeable object) {
+ String mName = "closer";
+ try {
+ object.close();
+ } catch (Exception e) {
+ WsLog.debug(cName, mName, e);
+ }
+ }
+
+ public static long getFileDate(IExperiment experiment) {
+ String mName = "getFileDate";
+ WsLog.enter(cName, mName);
+ String user = experiment.getUser();
+ String filename = getStateFilePath(experiment.getDirectory());
+ long retVal = getFileDate(user, filename);
+ return retVal;
+ }
+
+ public static long getFileDate(String user, String filename) {
+ String mName = "getFileDate";
+ WsLog.enter(cName, mName);
+ long retVal = getDomesticFileDate(user, filename);
+ if (retVal == 0) {
+ retVal = getAlienFileDate(user, filename);
+ }
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
+
+ private static long getAlienFileDate(String user, String filename) {
+ String mName = "getAlienFileDate";
+ WsLog.enter(cName, mName);
+ long retVal = 0;
+ AlienFile alienFile = new AlienFile(user, filename);
+ // NOTE - should not need the "--" ... or this could be moved to AlienFile
+ String[] lines = alienFile.getResult(false, "--", "/bin/ls", "-l", "--time-style=+%s",
+ filename);
+ // Should have 1 line with secs-since-epoch in 6th token
+ if (lines.length == 1) {
+ String[] toks = lines[0].split("\\s+");
+ if (toks.length >= 6) {
+ retVal = Long.valueOf(toks[5]) * 1000;
+ }
+ }
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
+
+ private static long getDomesticFileDate(String user, String filename) {
+ String mName = "getDomesticFileDate";
+ WsLog.enter(cName, mName);
+ long retVal = 0;
+ try {
+ File file = new File(filename);
+ retVal = file.lastModified();
+ } catch (Exception e) {
+ WsLog.trace(cName, mName, e);
+ }
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
+
+ /*
+ * Returns null if file is missing or can't be read
+ */
+ public static String getFileContents(String user, String filename) {
+ String mName = "getFileContents";
+ WsLog.enter(cName, mName);
+ boolean canRead = ((new File(filename)).canRead());
+ String retVal = canRead ? getDomesticFileContents(user, filename)
+ : getAlienFileContents(user, filename);
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
+
+ private static String getAlienFileContents(String user, String filename) {
+ String mName = "getAlienFileContents";
+ WsLog.enter(cName, mName);
+ String retVal = null;
+ try {
+ AlienFile alienFile = new AlienFile(user, filename);
+ retVal = alienFile.getString();
+ } catch (Throwable t) {
+ WsLog.trace(cName, mName, t);
+ }
+
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
+
+ private static String getDomesticFileContents(String user, String filename) {
+ String mName = "getDomesticFileContents";
+ WsLog.enter(cName, mName);
+ String retVal = null;
+ FileReader fr = null;
+ BufferedReader br = null;
+ StringReader sr = null;
+ try {
+ fr = new FileReader(filename);
+ br = new BufferedReader(fr);
+ StringBuffer sb = new StringBuffer();
+ String line = br.readLine();
+ while (line != null) {
+ sb.append(line);
+ line = br.readLine();
+ }
+ retVal = sb.toString();
+ } catch (Exception e) {
+ WsLog.debug(cName, mName, e);
+ } finally {
+ if (br != null) {
+ closer(br);
+ }
+ if (fr != null) {
+ closer(fr);
+ }
+ if (sr != null) {
+ closer(sr);
+ }
+ }
+ WsLog.exit(cName, mName);
+ return retVal;
+ }
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/IExperiment.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/IExperiment.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/IExperiment.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/IExperiment.java Thu Aug 15 18:51:19 2019
@@ -21,18 +21,31 @@ package org.apache.uima.ducc.ws.xd;
import java.util.ArrayList;
public interface IExperiment extends Comparable<Object> {
- public void setId(String value);
- public String getId();
- public String getUser();
- public String getDirectory();
- public ArrayList<Task> getTasks();
- public ArrayList<String> getJobIds();
- public String getStartDate();
- public long getStartTime();
- public boolean isActive();
- public Jed.Status getStatus();
- public void setFileDate(long value);
- public long getFileDate();
- public int getVersion();
- public boolean isStale();
+ public void setId(String value);
+
+ public String getId();
+
+ public String getUser();
+
+ public String getDirectory();
+
+ public ArrayList<Task> getTasks();
+
+ public ArrayList<String> getJobIds();
+
+ public String getStartDate();
+
+ public long getStartTime();
+
+ public boolean isActive();
+
+ public Jed.Status getStatus();
+
+ public void setFileDate(long value);
+
+ public long getFileDate();
+
+ public int getVersion();
+
+ public boolean isStale();
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Jed.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Jed.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Jed.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Jed.java Thu Aug 15 18:51:19 2019
@@ -20,122 +20,103 @@ package org.apache.uima.ducc.ws.xd;
public class Jed {
- public enum Type {
+ public enum Type {
- DuccJob, Java, File, Exec, Trainer, Sequential, Parallel, ParallelData, SetPhase, Other;
+ DuccJob, Java, File, Exec, Trainer, Sequential, Parallel, ParallelData, SetPhase, Other;
- private static String DUCC_JOB = "DUCC_JOB";
- private static String PARALLEL_DATA = "PARALLEL_DATA";
- private static String SET_PHASE = "SET_PHASE";
-
- public static Type getEnum(String value) {
- Type retVal = Other;
- if(value == null) {
- }
- else if(DUCC_JOB.equalsIgnoreCase(value)) {
- retVal = DuccJob;
- }
- else if(PARALLEL_DATA.equalsIgnoreCase(value)) {
- retVal = ParallelData;
- }
- else if(SET_PHASE.equalsIgnoreCase(value)) {
- retVal = SetPhase;
- }
- else if(DuccJob.name().equalsIgnoreCase(value)) {
- retVal = DuccJob;
- }
- else if(Java.name().equalsIgnoreCase(value)) {
- retVal = Java;
- }
- else if(File.name().equalsIgnoreCase(value)) {
- retVal = File;
- }
- else if(Exec.name().equalsIgnoreCase(value)) {
- retVal = Exec;
- }
- else if(Trainer.name().equalsIgnoreCase(value)) {
- retVal = Trainer;
- }
- else if(Sequential.name().equalsIgnoreCase(value)) {
- retVal = Sequential;
- }
- else if(ParallelData.name().equalsIgnoreCase(value)) {
- retVal = ParallelData;
- }
- else if(Parallel.name().equalsIgnoreCase(value)) {
- retVal = Parallel;
- }
- else if(SetPhase.name().equalsIgnoreCase(value)) {
- retVal = SetPhase;
- }
- return retVal;
- }
-
- public static boolean isLeaf(Type value) {
- boolean retVal = true;
- if(value != null) {
- switch(value) {
- case Parallel:
- case ParallelData:
- case Sequential:
- retVal = false;
- break;
- default:
- break;
- }
- }
- return retVal;
- }
-
- public static boolean isLeaf(String value){
- boolean retVal = isLeaf(getEnum(value));
- return retVal;
- }
- }
-
- public enum Status {
-
- Running, Completed, Done, Canceled, Failed, DependencyFailed, Ignored, Unknown, Other;
-
- private static String Dependency_Failed = "Dependency-Failed";
- private static String Cancelled = "Cancelled";
-
- public static Status getEnum(String value) {
- Status retVal = Other;
- if(value == null) {
- }
- else if(Cancelled.equalsIgnoreCase(value)) {
- retVal = Canceled;
- }
- else if(Dependency_Failed.equalsIgnoreCase(value)) {
- retVal = DependencyFailed;
- }
- else if(Running.name().equalsIgnoreCase(value)) {
- retVal = Running;
- }
- else if(Completed.name().equalsIgnoreCase(value)) {
- retVal = Completed;
- }
- else if(Done.name().equalsIgnoreCase(value)) {
- retVal = Done;
- }
- else if(Canceled.name().equalsIgnoreCase(value)) {
- retVal = Canceled;
- }
- else if(Failed.name().equalsIgnoreCase(value)) {
- retVal = Failed;
- }
- else if(DependencyFailed.name().equalsIgnoreCase(value)) {
- retVal = DependencyFailed;
- }
- else if(Ignored.name().equalsIgnoreCase(value)) {
- retVal = Ignored;
- }
- else if(Unknown.name().equalsIgnoreCase(value)) {
- retVal = Unknown;
- }
- return retVal;
- }
- }
+ private static String DUCC_JOB = "DUCC_JOB";
+
+ private static String PARALLEL_DATA = "PARALLEL_DATA";
+
+ private static String SET_PHASE = "SET_PHASE";
+
+ public static Type getEnum(String value) {
+ Type retVal = Other;
+ if (value == null) {
+ } else if (DUCC_JOB.equalsIgnoreCase(value)) {
+ retVal = DuccJob;
+ } else if (PARALLEL_DATA.equalsIgnoreCase(value)) {
+ retVal = ParallelData;
+ } else if (SET_PHASE.equalsIgnoreCase(value)) {
+ retVal = SetPhase;
+ } else if (DuccJob.name().equalsIgnoreCase(value)) {
+ retVal = DuccJob;
+ } else if (Java.name().equalsIgnoreCase(value)) {
+ retVal = Java;
+ } else if (File.name().equalsIgnoreCase(value)) {
+ retVal = File;
+ } else if (Exec.name().equalsIgnoreCase(value)) {
+ retVal = Exec;
+ } else if (Trainer.name().equalsIgnoreCase(value)) {
+ retVal = Trainer;
+ } else if (Sequential.name().equalsIgnoreCase(value)) {
+ retVal = Sequential;
+ } else if (ParallelData.name().equalsIgnoreCase(value)) {
+ retVal = ParallelData;
+ } else if (Parallel.name().equalsIgnoreCase(value)) {
+ retVal = Parallel;
+ } else if (SetPhase.name().equalsIgnoreCase(value)) {
+ retVal = SetPhase;
+ }
+ return retVal;
+ }
+
+ public static boolean isLeaf(Type value) {
+ boolean retVal = true;
+ if (value != null) {
+ switch (value) {
+ case Parallel:
+ case ParallelData:
+ case Sequential:
+ retVal = false;
+ break;
+ default:
+ break;
+ }
+ }
+ return retVal;
+ }
+
+ public static boolean isLeaf(String value) {
+ boolean retVal = isLeaf(getEnum(value));
+ return retVal;
+ }
+ }
+
+ public enum Status {
+
+ Running, Completed, Done, Canceled, Failed, DependencyFailed, Ignored, Unknown, Other;
+
+ private static String Dependency_Failed = "Dependency-Failed";
+
+ private static String Cancelled = "Cancelled";
+
+ public static Status getEnum(String value) {
+ Status retVal = Other;
+ if (value == null) {
+ } else if (Cancelled.equalsIgnoreCase(value)) {
+ retVal = Canceled;
+ } else if (Dependency_Failed.equalsIgnoreCase(value)) {
+ retVal = DependencyFailed;
+ } else if (Running.name().equalsIgnoreCase(value)) {
+ retVal = Running;
+ } else if (Completed.name().equalsIgnoreCase(value)) {
+ retVal = Completed;
+ } else if (Done.name().equalsIgnoreCase(value)) {
+ retVal = Done;
+ } else if (Canceled.name().equalsIgnoreCase(value)) {
+ retVal = Canceled;
+ } else if (Failed.name().equalsIgnoreCase(value)) {
+ retVal = Failed;
+ } else if (DependencyFailed.name().equalsIgnoreCase(value)) {
+ retVal = DependencyFailed;
+ } else if (Ignored.name().equalsIgnoreCase(value)) {
+ retVal = Ignored;
+ } else if (Unknown.name().equalsIgnoreCase(value)) {
+ retVal = Unknown;
+ }
+ return retVal;
+ }
+ }
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Task.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Task.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Task.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/Task.java Thu Aug 15 18:51:19 2019
@@ -23,13 +23,21 @@ package org.apache.uima.ducc.ws.xd;
* See com.ibm.bluej.system.driver/src/com/ibm/bluej/system/driver/TaskState.java
*/
public class Task {
- public int taskId = 0;
- public int parentId = 0;
- public String name = null;
- public String type = null;
- public String status = null;
- public String startTime = null;
- public long runTime = 0;
- public int[] subTasks = new int[0];
- public long[] duccId = new long[0];
+ public int taskId = 0;
+
+ public int parentId = 0;
+
+ public String name = null;
+
+ public String type = null;
+
+ public String status = null;
+
+ public String startTime = null;
+
+ public long runTime = 0;
+
+ public int[] subTasks = new int[0];
+
+ public long[] duccId = new long[0];
}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/TaskArray.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/TaskArray.java?rev=1865251&r1=1865250&r2=1865251&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/TaskArray.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/xd/TaskArray.java Thu Aug 15 18:51:19 2019
@@ -21,5 +21,5 @@ package org.apache.uima.ducc.ws.xd;
import java.util.ArrayList;
public class TaskArray {
- public ArrayList<Task> tasks = new ArrayList<Task>();
+ public ArrayList<Task> tasks = new ArrayList<Task>();
}