java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_eval.ExecutorSeals

public class ExecutorSeals extends Object
This executor can run SEALS matchers. Please note that as of 2020, SEALS Client 7.0.5 requires JDK 1.8! If you have a newer JDK installed and you run into trouble, you can install an additional JDK and use
Author:
Jan Portisch
  • Field Details

    • OS_NAME

      private static final String OS_NAME
    • isLinux

      private static final boolean isLinux
    • sealsClientJar

      private File sealsClientJar
      Path to the JAR of the SEALS client.
    • sealsHome

      private File sealsHome
      Path to the SEALS home directory.
    • LOGGER

      private static final org.slf4j.Logger LOGGER
      Default logger.
    • timeout

      private long timeout
      Time out for the external seals process. The timeout is applied for each testcase and not track.
    • timeoutTimeUnit

      private TimeUnit timeoutTimeUnit
      Time unit for the process time out.
    • javaRuntimeParameters

      private List<String> javaRuntimeParameters
      The parameters that appear between java [parameters] -jar. Example: ("-Xmx25g", "-Xms15g").
    • resultsDirectory

      private File resultsDirectory
      The directory where the results shall be written to.
    • deleteTempFiles

      private boolean deleteTempFiles
      If true, deletes files in tmp folder which starts with "alignment" before running a matcher
    • javaCommand

      private String javaCommand
      The command to start java in the terminal. Typically, this is "java"
    • matcherNamePattern

      private static final Pattern matcherNamePattern
      Regex pattern to get the matcher name from the SEALS descriptor.xml file.
  • Constructor Details

    • ExecutorSeals

      public ExecutorSeals(File sealsClientJar, File sealsHome, File resultsDirectory, List<String> javaRuntimeParameters, long timeout, TimeUnit timeoutTimeUnit, boolean deleteTempFiles)
      Constructor
      Parameters:
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      resultsDirectory - Results folder where the SEALS results will be copied to
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
      timeout - Timeout for one testcase as long.
      timeoutTimeUnit - The unit of the timeout.
      deleteTempFiles - If true, deletes files in tmp folder which starts with "alignment" before running a matcher
    • ExecutorSeals

      public ExecutorSeals(String javaCommand, File sealsClientJar, File sealsHome, File resultsDirectory, List<String> javaRuntimeParameters, long timeout, TimeUnit timeoutTimeUnit, boolean deleteTempFiles)
      Constructor
      Parameters:
      javaCommand - Command to start java.
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      resultsDirectory - Results folder where the SEALS results will be copied to
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
      timeout - Timeout for one testcase as long.
      timeoutTimeUnit - The unit of the timeout.
      deleteTempFiles - If true, deletes files in tmp folder which starts with "alignment" before running a matcher
    • ExecutorSeals

      public ExecutorSeals(File sealsClientJar, File sealsHome, List<String> javaRuntimeParameters, long timeout, TimeUnit timeoutTimeUnit)
      Constructor
      Parameters:
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
      timeout - Timeout for one testcase as long.
      timeoutTimeUnit - The unit of the timeout.
    • ExecutorSeals

      public ExecutorSeals(String javaCommand, File sealsClientJar, File sealsHome, List<String> javaRuntimeParameters, long timeout, TimeUnit timeoutTimeUnit)
      Constructor
      Parameters:
      javaCommand - Command to start java.
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
      timeout - Timeout for one testcase as long.
      timeoutTimeUnit - The unit of the timeout.
    • ExecutorSeals

      public ExecutorSeals(File sealsClientJar, File sealsHome, List<String> javaRuntimeParameters)
      Constructor The default timeout of 12 hours will be used.
      Parameters:
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
    • ExecutorSeals

      public ExecutorSeals(String javaCommand, File sealsClientJar, File sealsHome, List<String> javaRuntimeParameters)
      Constructor The default timeout of 12 hours will be used.
      Parameters:
      javaCommand - Command to start java.
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      javaRuntimeParameters - Runtime parameters such as ("-Xmx25g", "-Xms15g").
    • ExecutorSeals

      public ExecutorSeals(File sealsClientJar, File sealsHome)
      Constructor The default timeout of 12 hours will be used.
      Parameters:
      sealsClientJar - The file to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
    • ExecutorSeals

      public ExecutorSeals(String javaCommand, File sealsClientJar, File sealsHome)
      Constructor The default timeout of 12 hours will be used.
      Parameters:
      javaCommand - Command to start java.
      sealsClientJar - The file to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
    • ExecutorSeals

      public ExecutorSeals(String sealsClientJarPath, String sealsHomePath)
      Constructor
      Parameters:
      sealsClientJarPath - The path to the local SEALS client JAR file.
      sealsHomePath - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
    • ExecutorSeals

      public ExecutorSeals(String javaCommand, String sealsClientJarPath, String sealsHomePath)
      Constructor
      Parameters:
      javaCommand - Command to start java.
      sealsClientJarPath - The path to the local SEALS client JAR file.
      sealsHomePath - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
    • ExecutorSeals

      public ExecutorSeals(File sealsClientJar, File sealsHome, long timeout, TimeUnit timeoutTimeUnit)
      Constructor
      Parameters:
      sealsClientJar - The path to the local SEALS client JAR file.
      sealsHome - SEALS Home directory. ALL files in this directory will be removed (this is SEALS default behaviour).
      timeout - Timeout as long.
      timeoutTimeUnit - The unit of the timeout.
  • Method Details

    • run

      public ExecutionResultSet run(Track track, String matcher)
      Evaluate matcher(s) using the local SEALS client. The file parameter can be a zip file or a directory. If it is a directory and the directory represents a matcher, it will be executed. Otherwise the directory will be scanned for matcher subdirectories and/or zip files (which are unzipped). The unzipping happens with every execution to ensure that the matcher is executed as submitted (in case some files are not closed corrected due to a previous run).
      Parameters:
      track - The track on which the matcher shall be run.
      matcher - The directory containing the matcher(s).
      Returns:
      Execution Result Set instance for the matcher on the track.
    • run

      public ExecutionResultSet run(TestCase testcase, String matcher)
      Evaluate matcher(s) using the local SEALS client. The file parameter can be a zip file or a directory. If it is a directory and the directory represents a matcher, it will be executed. Otherwise the directory will be scaned for matcher subdirectories and/or zip files (which are unzipped). The unzipping happens with every execution to ensure that the matcher is executed as submitted (in case some files are not closed corrected due to a previous run).
      Parameters:
      testcase - The testcase on which the matcher shall be run.
      matcher - The directory containing the matcher(s).
      Returns:
      Execution Result Set instance for the matcher on the track.
    • run

      public ExecutionResultSet run(Track track, File matcherDirectory)
      Evaluate matcher(s) using the local SEALS client. The file parameter can be a zip file or a directory. If it is a directory and the directory represents a matcher, it will be executed. Otherwise the directory will be scaned for matcher subdirectories and/or zip files (which are unzipped). The unzipping happens with every execution to ensure that the matcher is executed as submitted (in case some files are not closed corrected due to a previous run).
      Parameters:
      track - The track on which the matcher shall be run.
      matcherDirectory - The directory containing the matcher(s).
      Returns:
      Execution Result Set instance for the matcher on the track.
    • run

      public ExecutionResultSet run(List<TestCase> testCases, File matcherDirectory)
      Evaluate matcher(s) using the local SEALS client. The file parameter can be a zip file or a directory. If it is a directory and the directory represents a matcher, it will be executed. Otherwise the directory will be scaned for matcher subdirectories and/or zip files (which are unzipped). The unzipping happens with every execution to ensure that the matcher is executed as submitted (in case some files are not closed corrected due to a previous run).
      Parameters:
      testCases - The testcases on which the matcher shall be run.
      matcherDirectory - The directory containing the matcher(s).
      Returns:
      Execution Result Set instance for the matcher on the track.
    • run

      public ExecutionResultSet run(TestCase testCase, File matcher)
      Evaluate matcher(s) using the local SEALS client. The file parameter can be a zip file or a directory. If it is a directory and the directory represents a matcher, it will be executed. Otherwise the directory will be scaned for matcher subdirectories and/or zip files (which are unzipped). The unzipping happens with every execution to ensure that the matcher is executed as submitted (in case some files are not closed corrected due to a previous run).
      Parameters:
      testCase - The testcase on which the matcher shall be run.
      matcher - The directory containing the matcher(s).
      Returns:
      Execution Result Set instance for the matcher on the track.
    • getMatcherDirectories

      protected Map<File,String> getMatcherDirectories(File matcher)
      Returns all possible matcher directories for a given file or directory. If it is a file with zip extension, it will unzip it. If it is a directory, it will check if this directory is a matcher. If not, it will inspect the whole directory for matchers.
      Parameters:
      matcher - the directoroy or file which represents a matcher or a directory of matchers.
      Returns:
      a map of the matcher directory and corresponding matcher name(file name)
    • runUnzippedMatcher

      protected ExecutionResult runUnzippedMatcher(TestCase testCase, File matcherDirectory)
      Evaluate a single matcher using the local SEALS client.
      Parameters:
      matcherDirectory - The directory containing the matcher
      testCase - The testCase on which the matcher shall be run.
      Returns:
      ExecutionResult
    • runUnzippedMatcher

      protected ExecutionResult runUnzippedMatcher(TestCase testCase, File matcherDirectory, String matcherName)
      Evaluate a single matcher using the local SEALS client.
      Parameters:
      matcherDirectory - The directory containing the matcher
      testCase - The testCase on which the matcher shall be run.
      matcherName - Matcher name
      Returns:
      ExecutionResult
    • terminateProcess

      private static void terminateProcess(Process process)
    • killProcessWithJava

      private static void killProcessWithJava(Process p)
    • killAllProcessesWithSameSessionId

      private static void killAllProcessesWithSameSessionId(Long pid)
    • getPid

      private static Long getPid(Process process)
      Obtains the process ID given a process.
      Parameters:
      process - The process for which the ID shall be determined.
      Returns:
      Process ID as Long of a given process.
    • getMatcherNameFromSealsDescriptor

      public static String getMatcherNameFromSealsDescriptor(File file)
      Returns the matcher name in the seals descriptor.
      Parameters:
      file - File instance which points to a descriptor file or a matcher directory.
      Returns:
      name of the matcher or empty string if not available.
    • getMatcherNameFromSealsDescriptor

      public static String getMatcherNameFromSealsDescriptor(String file)
    • unzip

      private static File unzip(File fileToBeUnzipped)
      Unzips a zip-file in the directory where the zip file resides. A new directory will be created with the name of the zip file (without .zip ending) and the zipped contents will be found therein.
      Parameters:
      fileToBeUnzipped - The file that shall be unzipped.
      Returns:
      The path to the extracted file.
    • getFirstSubDirectoryRunnableInSeals

      public static File getFirstSubDirectoryRunnableInSeals(File rootDir)
      This method visits all folders below the starting directory and returns the first directory which is runnable in seals. The traversing strategy is breadth first search.
      Parameters:
      rootDir - Path to the starting directory.
      Returns:
      The first directory which is runnable in seals or null if such a folder does not exist
    • isDirectoryRunnableInSeals

      public static boolean isDirectoryRunnableInSeals(File directory)
      Determines whether the specified directory is runnable in seals.
      Parameters:
      directory - Path to the directory.
      Returns:
      True if runnable, else false.
    • isDirectoryRunnableInSeals

      public static boolean isDirectoryRunnableInSeals(String directory)
      Determines whether the specified directory is runnable in seals.
      Parameters:
      directory - Path to the directory.
      Returns:
      True if runnable, else false.
    • setTimeout

      public void setTimeout(long timeout, TimeUnit timeoutTimeUnit)
    • getTimeout

      public long getTimeout()
    • getTimeoutTimeUnit

      public TimeUnit getTimeoutTimeUnit()
    • getTimeoutAsText

      public String getTimeoutAsText()
    • getSealsClientJar

      public File getSealsClientJar()
    • setSealsClientJar

      public void setSealsClientJar(File sealsClientJar)
    • getSealsHome

      public File getSealsHome()
    • setSealsHome

      public void setSealsHome(File sealsHome)
    • getJavaRuntimeParameters

      public List<String> getJavaRuntimeParameters()
    • setJavaRuntimeParameters

      public void setJavaRuntimeParameters(List<String> javaRuntimeParameters)
    • getJavaCommand

      public String getJavaCommand()
    • setJavaCommand

      public void setJavaCommand(String javaCommand)
      If in your system, the "java" command links to a jdk > 8, issues might occur. Therefore, you can use this command to point to a jdk 8 executable.
      Parameters:
      javaCommand - The command to start the desired java version such as a file path to the executable.