public abstract class AbstractSession extends java.lang.Object implements Session
FFmpeg
and FFprobe sessions.| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String[] |
arguments
Command arguments as an array.
|
protected java.util.Date |
createTime
Date and time the session was created.
|
static int |
DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT
Defines how long default "getAll" methods wait, in milliseconds.
|
protected java.util.Date |
endTime
Date and time the session has ended.
|
protected ExecuteCallback |
executeCallback
Session specific execute callback function.
|
protected java.lang.String |
failStackTrace
Stack trace of the error received while trying to execute this session.
|
protected java.util.concurrent.Future<?> |
future
Future created for sessions executed asynchronously.
|
protected LogCallback |
logCallback
Session specific log callback function.
|
protected LogRedirectionStrategy |
logRedirectionStrategy
Session specific log redirection strategy.
|
protected java.util.List<Log> |
logs
Log entries received for this session.
|
protected java.lang.Object |
logsLock
Log entry lock.
|
protected ReturnCode |
returnCode
Return code for the completed sessions.
|
protected long |
sessionId
Session identifier.
|
protected static java.util.concurrent.atomic.AtomicLong |
sessionIdGenerator
Generates unique ids for sessions.
|
protected java.util.Date |
startTime
Date and time the session was started.
|
protected SessionState |
state
State of the session.
|
| Constructor and Description |
|---|
AbstractSession(java.lang.String[] arguments,
ExecuteCallback executeCallback,
LogCallback logCallback,
LogRedirectionStrategy logRedirectionStrategy)
Creates a new abstract session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLog(Log log)
Adds a new log entry for this session.
|
void |
cancel()
Cancels running the session.
|
java.util.List<Log> |
getAllLogs()
Returns all log entries generated for this session.
|
java.util.List<Log> |
getAllLogs(int waitTimeout)
Returns all log entries generated for this session.
|
java.lang.String |
getAllLogsAsString()
Returns all log entries generated for this session as a concatenated string.
|
java.lang.String |
getAllLogsAsString(int waitTimeout)
Returns all log entries generated for this session as a concatenated string.
|
java.lang.String[] |
getArguments()
Returns command arguments as an array.
|
java.lang.String |
getCommand()
Returns command arguments as a concatenated string.
|
java.util.Date |
getCreateTime()
Returns session create time.
|
long |
getDuration()
Returns the time taken to execute this session.
|
java.util.Date |
getEndTime()
Returns session end time.
|
ExecuteCallback |
getExecuteCallback()
Returns the session specific execute callback function.
|
java.lang.String |
getFailStackTrace()
Returns the stack trace of the exception received while executing this session.
|
java.util.concurrent.Future<?> |
getFuture()
Returns the future created for this session, if it is executed asynchronously.
|
LogCallback |
getLogCallback()
Returns the session specific log callback function.
|
LogRedirectionStrategy |
getLogRedirectionStrategy()
Returns session specific log redirection strategy.
|
java.util.List<Log> |
getLogs()
Returns all log entries delivered for this session.
|
java.lang.String |
getLogsAsString()
Returns all log entries delivered for this session as a concatenated string.
|
java.lang.String |
getOutput()
Returns the log output generated while running the session.
|
ReturnCode |
getReturnCode()
Returns the return code for this session.
|
long |
getSessionId()
Returns the session identifier.
|
java.util.Date |
getStartTime()
Returns session start time.
|
SessionState |
getState()
Returns the state of the session.
|
boolean |
thereAreAsynchronousMessagesInTransmit()
Returns whether there are still asynchronous messages being transmitted for this
session or not.
|
protected void |
waitForAsynchronousMessagesInTransmit(int timeout)
Waits for all asynchronous messages to be transmitted until the given timeout.
|
protected static final java.util.concurrent.atomic.AtomicLong sessionIdGenerator
public static final int DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT
protected final long sessionId
protected final ExecuteCallback executeCallback
protected final LogCallback logCallback
protected final java.util.Date createTime
protected java.util.Date startTime
protected java.util.Date endTime
protected final java.lang.String[] arguments
protected final java.util.List<Log> logs
protected final java.lang.Object logsLock
protected java.util.concurrent.Future<?> future
protected SessionState state
protected ReturnCode returnCode
protected java.lang.String failStackTrace
protected final LogRedirectionStrategy logRedirectionStrategy
public AbstractSession(java.lang.String[] arguments,
ExecuteCallback executeCallback,
LogCallback logCallback,
LogRedirectionStrategy logRedirectionStrategy)
arguments - command argumentsexecuteCallback - session specific execute callback functionlogCallback - session specific log callback functionlogRedirectionStrategy - session specific log redirection strategypublic ExecuteCallback getExecuteCallback()
SessiongetExecuteCallback in interface Sessionpublic LogCallback getLogCallback()
SessiongetLogCallback in interface Sessionpublic long getSessionId()
SessiongetSessionId in interface Sessionpublic java.util.Date getCreateTime()
SessiongetCreateTime in interface Sessionpublic java.util.Date getStartTime()
SessiongetStartTime in interface Sessionpublic java.util.Date getEndTime()
SessiongetEndTime in interface Sessionpublic long getDuration()
SessiongetDuration in interface Sessionpublic java.lang.String[] getArguments()
SessiongetArguments in interface Sessionpublic java.lang.String getCommand()
SessiongetCommand in interface Sessionpublic java.util.List<Log> getAllLogs(int waitTimeout)
SessiongetAllLogs in interface SessionwaitTimeout - wait timeout for asynchronous messages in millisecondspublic java.util.List<Log> getAllLogs()
DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT expires.getAllLogs in interface Sessionpublic java.util.List<Log> getLogs()
Sessionpublic java.lang.String getAllLogsAsString(int waitTimeout)
SessiongetAllLogsAsString in interface SessionwaitTimeout - wait timeout for asynchronous messages in millisecondspublic java.lang.String getAllLogsAsString()
DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT expires.getAllLogsAsString in interface Sessionpublic java.lang.String getLogsAsString()
SessiongetLogsAsString in interface Sessionpublic java.lang.String getOutput()
Sessionpublic SessionState getState()
Sessionpublic ReturnCode getReturnCode()
SessiongetReturnCode in interface Sessionpublic java.lang.String getFailStackTrace()
SessionThe stack trace is only set for sessions that end with FAILED state. For sessions that has COMPLETED state this method returns null.
getFailStackTrace in interface Sessionpublic LogRedirectionStrategy getLogRedirectionStrategy()
SessiongetLogRedirectionStrategy in interface Sessionpublic boolean thereAreAsynchronousMessagesInTransmit()
SessionthereAreAsynchronousMessagesInTransmit in interface Sessionpublic void addLog(Log log)
Sessionpublic java.util.concurrent.Future<?> getFuture()
Sessionpublic void cancel()
Sessionprotected void waitForAsynchronousMessagesInTransmit(int timeout)
timeout - wait timeout in milliseconds