Package com.illumon.iris.db.v2.replay
Class Replayer
java.lang.Object
com.illumon.iris.db.v2.replay.Replayer
- All Implemented Interfaces:
LiveTable
,ReplayerInterface
- Direct Known Subclasses:
DataDrivenReplayer
,FixedStepReplayer
public class Replayer extends Object implements ReplayerInterface, LiveTable
Replay historical data as simulated real-time data.
-
Field Summary
Fields Modifier and Type Field Description protected DBDateTime
endTime
protected DBDateTime
startTime
-
Constructor Summary
Constructors Constructor Description Replayer(DBDateTime startTime, DBDateTime endTime)
Creates a new replayer. -
Method Summary
Modifier and Type Method Description DBDateTime
currentTime()
Simulated time.long
currentTimeNanos()
Simulated time in nanoseconds.ReplayerHandle
getHandle()
Gets a handle to the replayer.static TimeProvider
getTimeProvider(ReplayerInterface replayer)
Gets a time provider for the replayer.boolean
isDone()
Has the replayer finished replaying all data.void
refresh()
Refresh the simulated live tables.void
registerTimeSource(Index index, ColumnSource<DBDateTime> timestampSource)
Register the time column and index from a new table to replay.DynamicTable
replay(Table dataSource, String timeColumn)
Prepares a historical table for replaying.DynamicTable
replayGrouped(Table dataSource, String timeColumn, String groupingColumn)
Prepares a grouped historical table for replaying.DynamicTable
replayGroupedLastBy(Table dataSource, String timeColumn, String... groupingColumns)
Prepares a grouped historical table for replaying as a last-by table.void
schedule(TimerTask task, long delay, long period)
Schedule a task to execute.void
setTime(long updatedTime)
Sets the current replay time.void
shutdown()
Shuts down the replayer.void
start()
Starts replaying data.void
waitDone(long maxTimeMillis)
Wait a specified interval for the replayer to complete.
-
Field Details
-
Constructor Details
-
Replayer
Creates a new replayer.- Parameters:
startTime
- start timeendTime
- end time
-
-
Method Details
-
start
public void start()Starts replaying data.- Specified by:
start
in interfaceReplayerInterface
-
isDone
public boolean isDone()Has the replayer finished replaying all data.- Specified by:
isDone
in interfaceReplayerInterface
- Returns:
- true if the replayer has finished replaying all data; false otherwise.
-
shutdown
Shuts down the replayer.- Specified by:
shutdown
in interfaceReplayerInterface
- Throws:
IOException
- problem shutting down the replayer.
-
waitDone
public void waitDone(long maxTimeMillis)Wait a specified interval for the replayer to complete. If the replayer has not completed by the end of the interval, the method returns.- Specified by:
waitDone
in interfaceReplayerInterface
- Parameters:
maxTimeMillis
- maximum number of milliseconds to wait.- Throws:
QueryCancellationException
- thread was interrupted.
-
schedule
Schedule a task to execute.- Specified by:
schedule
in interfaceReplayerInterface
- Parameters:
task
- task to executedelay
- delay in milliseconds before first executing the taskperiod
- frequency in milliseconds to execute the task.
-
getTimeProvider
Gets a time provider for the replayer. The time provider returns the current replay time.- Parameters:
replayer
- replayer- Returns:
- time provider that returns the current replay time.
-
currentTimeNanos
public long currentTimeNanos()Simulated time in nanoseconds.- Returns:
- simulated time in nanoseconds.
-
currentTime
Simulated time.- Specified by:
currentTime
in interfaceReplayerInterface
- Returns:
- simulated time.
-
setTime
public void setTime(long updatedTime)Sets the current replay time.- Specified by:
setTime
in interfaceReplayerInterface
- Parameters:
updatedTime
- new replay time.
-
replay
Prepares a historical table for replaying.- Specified by:
replay
in interfaceReplayerInterface
- Parameters:
dataSource
- historical table to replaytimeColumn
- column in the table containing timestamps- Returns:
- dynamic, replayed version of the table.
-
replayGrouped
Prepares a grouped historical table for replaying. This method can be faster than the ungrouped replay, but the performance increase comes with a cost. Within a group, the data ordering is maintained. Between groups, data ordering is not maintained for a time interval.- Specified by:
replayGrouped
in interfaceReplayerInterface
- Parameters:
dataSource
- historical table to replaytimeColumn
- column in the table containing timestamps- Returns:
- dynamic, replayed version of the table.
-
replayGroupedLastBy
public DynamicTable replayGroupedLastBy(Table dataSource, String timeColumn, String... groupingColumns)Prepares a grouped historical table for replaying as a last-by table.- Specified by:
replayGroupedLastBy
in interfaceReplayerInterface
- Parameters:
dataSource
- historical table to replaytimeColumn
- column in the table containing timestampsgroupingColumns
- columns used as the key in computing last-by- Returns:
- dynamic, replayed version of the last-by table.
-
registerTimeSource
Register the time column and index from a new table to replay. Most users will usereplay
,replayGrouped
, orreplayGroupedLastBy
instead of this function.- Parameters:
index
- table indextimestampSource
- column source containing time information.
-
refresh
public void refresh()Refresh the simulated live tables. -
getHandle
Gets a handle to the replayer.- Specified by:
getHandle
in interfaceReplayerInterface
- Returns:
- handle to the replayer.
-