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()
Session
getExecuteCallback
in interface Session
public LogCallback getLogCallback()
Session
getLogCallback
in interface Session
public long getSessionId()
Session
getSessionId
in interface Session
public java.util.Date getCreateTime()
Session
getCreateTime
in interface Session
public java.util.Date getStartTime()
Session
getStartTime
in interface Session
public java.util.Date getEndTime()
Session
getEndTime
in interface Session
public long getDuration()
Session
getDuration
in interface Session
public java.lang.String[] getArguments()
Session
getArguments
in interface Session
public java.lang.String getCommand()
Session
getCommand
in interface Session
public java.util.List<Log> getAllLogs(int waitTimeout)
Session
getAllLogs
in interface Session
waitTimeout
- wait timeout for asynchronous messages in millisecondspublic java.util.List<Log> getAllLogs()
DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT
expires.getAllLogs
in interface Session
public java.util.List<Log> getLogs()
Session
public java.lang.String getAllLogsAsString(int waitTimeout)
Session
getAllLogsAsString
in interface Session
waitTimeout
- wait timeout for asynchronous messages in millisecondspublic java.lang.String getAllLogsAsString()
DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT
expires.getAllLogsAsString
in interface Session
public java.lang.String getLogsAsString()
Session
getLogsAsString
in interface Session
public java.lang.String getOutput()
Session
public SessionState getState()
Session
public ReturnCode getReturnCode()
Session
getReturnCode
in interface Session
public java.lang.String getFailStackTrace()
Session
The 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 Session
public LogRedirectionStrategy getLogRedirectionStrategy()
Session
getLogRedirectionStrategy
in interface Session
public boolean thereAreAsynchronousMessagesInTransmit()
Session
thereAreAsynchronousMessagesInTransmit
in interface Session
public void addLog(Log log)
Session
public java.util.concurrent.Future<?> getFuture()
Session
public void cancel()
Session
protected void waitForAsynchronousMessagesInTransmit(int timeout)
timeout
- wait timeout in milliseconds