Class Task

    • Constructor Detail

      • Task

        public Task()
        Constructor
    • Method Detail

      • getTaskThreadGroup

        public static ThreadGroup getTaskThreadGroup()
        Access the Task thread group
      • getPercentComplete

        public Integer getPercentComplete()
        Determines how far through the task is is.
        Specified by:
        getPercentComplete in interface nzilbb.util.MonitorableTask
        Returns:
        An integer between 0 and 100 (inclusive), or null if progress can not be calculated.
      • cancel

        public void cancel()
        Cancels the task.
        Specified by:
        cancel in interface nzilbb.util.MonitorableTask
      • getRunning

        public boolean getRunning()
        Reveals whether the task is still running or not.
        Specified by:
        getRunning in interface nzilbb.util.MonitorableTask
        Returns:
        true if the task is currently running, false otherwise.
      • getStatus

        public String getStatus()
        The current status of the thread.
        Specified by:
        getStatus in interface nzilbb.util.MonitorableTask
        Returns:
        a description of the current status of the task.
      • setStatus

        public void setStatus​(String sMessage)
        Sets the thread status.
        Parameters:
        sMessage - a status message to display to anyone who's watching the thread.
      • getWho

        public String getWho()
        Gets the user associated with the task, if any.
        Returns:
        the username or hostname of the person who started the task, if available.
      • setWho

        public void setWho​(String who)
        Sets the user associated with the task.
        Parameters:
        who - the username or hostname of the person who started the task
      • getLastException

        public Throwable getLastException()
        Gets the last exception that occurred during the task.
        Returns:
        the last task exception, or null if no exception has occurred.
      • setLastException

        public void setLastException​(Throwable ex)
        Sets the last exception that occurred during the task.
        Parameters:
        ex - the last task exception, or null if no exception has occurred.
      • getResultUrl

        public String getResultUrl()
        ResultUrl accessor
        Returns:
        Full URL to the final results of the task, or null if the task isn't finished or has no URL for final results.
      • setResultUrl

        public void setResultUrl​(String sNewResultUrl)
        ResultUrl mutator
        Parameters:
        sNewResultUrl - Full URL to the final results of the task, or null if the task isn't finished or has no URL for final results. Instances of "+" in the string will be replaced with "%20".
      • getResultText

        public String getResultText()
        ResultText accessor
        Returns:
        Text to describe the link to the ResultUrl. This will be the contents of the <a> tag if ResultUrl is set.
      • setResultText

        public void setResultText​(String sNewResultText)
        ResultText mutator
        Parameters:
        sNewResultText - Text to describe the link to the ResultUrl. This will be the contents of the <a> tag if ResultUrl is set.
      • getResultTarget

        public String getResultTarget()
        Getter for sResultTarget: The target HTML frame/window for the results to open in.
        Returns:
        The target HTML frame/window for the results to open in.
      • setResultTarget

        public void setResultTarget​(String sNewResultTarget)
        Setter for sResultTarget: The target HTML frame/window for the results to open in.
        Parameters:
        sNewResultTarget - The target HTML frame/window for the results to open in.
      • getLastKeepAlive

        public Date getLastKeepAlive()
        LastKeepAlive accessor
        Returns:
        Last time keepAlive() was called.
      • setLastKeepAlive

        public void setLastKeepAlive​(Date dtNewLastKeepAlive)
        LastKeepAlive mutator
        Parameters:
        dtNewLastKeepAlive - Last time keepAlive() was called.
      • getWaitToDieMilliseconds

        public long getWaitToDieMilliseconds()
        Getter for waitToDieMilliseconds: Time to wait after finishing or the last keepalive, before dying.
        Returns:
        Time to wait after finishing or the last keepalive, before dying.
      • setWaitToDieMilliseconds

        public void setWaitToDieMilliseconds​(long newWaitToDieMilliseconds)
        Setter for waitToDieMilliseconds: Time to wait after finishing or the last keepalive, before dying.
        Parameters:
        newWaitToDieMilliseconds - Time to wait after finishing or the last keepalive, before dying.
      • getStore

        public SqlGraphStore getStore()
        Getter for store: Graph store.
        Returns:
        Graph store.
      • setStore

        public Task setStore​(SqlGraphStore newStore)
        Setter for store: Graph store.
        Parameters:
        newStore - Graph store.
      • getStoreCache

        public StoreCache getStoreCache()
        Getter for storeCache: A supplier/consumer of graph stores, so that a store can be obtained if necessary, and resources can be shared/closed when appropriate.
        Returns:
        A supplier/consumer of graph stores, so that a store can be obtained if necessary, and resources can be shared/closed when appropriate.
      • setStoreCache

        public Task setStoreCache​(StoreCache newStoreCache)
        Setter for storeCache: A supplier/consumer of graph stores, so that a store can be obtained if necessary, and resources can be shared/closed when appropriate.
        Parameters:
        newStoreCache - A supplier/consumer of graph stores, so that a store can be obtained if necessary, and resources can be shared/closed when appropriate.
      • getLog

        public String getLog()
        Provides a timestamped log of activity.
        Returns:
        a string containing all of the values that setStatus has had since the task started.
        Throws:
        Exception
      • getMaxLogSize

        public int getMaxLogSize()
        Getter for maxLogSize: Maximum size of the task's log, in characters.
        Returns:
        Maximum size of the task's log, in characters.
      • setMaxLogSize

        public Task setMaxLogSize​(int newMaxLogSize)
        Setter for maxLogSize: Maximum size of the task's log, in characters.
        Parameters:
        newMaxLogSize - Maximum size of the task's log, in characters.
      • getResources

        public ResourceBundle getResources()
        Getter for resources: Localization resource bundle.
        Returns:
        Localization resource bundle.
      • setResources

        public Task setResources​(ResourceBundle newResources)
        Setter for resources: Localization resource bundle.
        Parameters:
        newResources - Localization resource bundle.
      • defaultThreadName

        public String defaultThreadName()
        A default unique name for the thread. Implementors can use or add this this as they like.
      • release

        public void release()
        Allows the finished-and-waiting thread to exit.
      • findTask

        public static Task findTask​(String sName)
        Finds the named thread.
        Parameters:
        sName - the thread's name
        Returns:
        the named thread, or null if it can't be found.
      • findTask

        public static Task findTask​(long id)
        Finds the named task.
        Parameters:
        id - the thread's ID
        Returns:
        The identified thread, or null if it can't be found.
      • keepAlive

        public void keepAlive()
        Somebody is still interested in the thread, so keep it from dying.
      • waitToDie

        public void waitToDie()
        Called at the end of the task's run() method, this method blocks until there is nobody interested in the thread any more - i.e. there have been no recent calls to keepAlive(). The default delay is 120000ms, i.e. 2 minutes;
      • waitToDie

        public void waitToDie​(long lDelay)
        Called at the end of the task's run() method, this method blocks until there is nobody interested in the thread any more - i.e. there have been no recent calls to keepAlive()
        Parameters:
        lDelay - Delay time - i.e. the minimum amount of time to wait before dying.
      • getCreationTime

        public Date getCreationTime()
        The creation time of the task.
        Returns:
        the creation time of the task
      • getDuration

        public long getDuration()
        The duration of the tasks execution so far.
        Returns:
        the number of millisecond that the thread ran for if it is finished, or the amount of time the thread has been running for so far, if it is still executing.