Skip to main content

Recording when startTime == now

2 replies [Last post]
howardteece
Offline
Joined: 2010-06-17
Points: 0

If we attempt to start a recording like this:

RecordingSpec recordingSpec = new ServiceRecordingSpec(service, new Date(System.currentTimeMillis()), duration, recordingProperties);
recordingRequest = recordingManager.record(recordingSpec);

Then occasionally we see:

20100909 15:26:31.640 INFO RI.Stack.StdOut- java.lang.IllegalArgumentException: Negative delay.
20100909 15:26:31.656 INFO RI.Stack.StdOut- at java.util.Timer.schedule(Timer.java:152)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.timer.TimerMgrJava2$TVTimerImpl.schedule(TimerMgrJava2.java:345)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.timer.TimerMgrJava2$TVTimerImpl.scheduleTimerSpec(TimerMgrJava2.java:235)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.timer.TimerMgrJava2$TVTimerImpl.scheduleTimerSpec(TimerMgrJava2.java:176)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.recording.Scheduler$StartSpec.schedule(Scheduler.java:1195)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.recording.Scheduler.scheduleRecording(Scheduler.java:236)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.recording.RecordingManagerImpl.recordByService(RecordingManagerImpl.java:2564)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.recording.RecordingManagerImpl.record(RecordingManagerImpl.java:2150)
20100909 15:26:31.656 INFO RI.Stack.StdOut- at org.cablelabs.impl.manager.recording.RecordingManagerImpl.record(RecordingManagerImpl.java:2043)
...

Which seems to be due to the clock rolling over from request to timer creation. And thus we attempt to create a negative timer for the start Alert.
This exception is not handled by the stack, other than to tidy up, and so the recording is not made.

My question is: Should we expect the stack to allow this recording [i.e. it's an immediate record] or is the exception vaild, and we should add, say, 10mSecs to the start time to allow for propagation delay?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
howardteece
Offline
Joined: 2010-06-17
Points: 0

I'll hang my head in shame.

Our changes to TvTimer caused this.

Sorry.

cpratt
Offline
Joined: 2008-12-18
Points: 0

Yeah - a java.util.Timer provided a Date object has a different contract than a delay timer - which the RI's RecordingManager depends upon when a recording's start time is in the past:

java.util.Timer.schedule(TimerTask task, Date time): Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution.

So if one were to attempt to simulate a Date-based timer using delays, you would need to floor the deltas to prevent negative durations.