def createCSSClientObjects(cmdParser): """\ Create the client objects needed to engage in the CSS-WC and CSS-TS protocols. :param cmdParser the command line parser object """ args = cmdParser.args sysclock=SysClock() wallClock=TunableClock(sysclock,tickRate=1000000000) # nanos # measure precision of wall clock empirically wcPrecisionNanos = measurePrecision(wallClock) * 1000000000 algorithm = LowestDispersionCandidate(wallClock,repeatSecs=0.3,timeoutSecs=0.3) wcClient=WallClockClient(cmdParser.wcBind, args.wcUrl[0], wallClock, algorithm) timelineClock = CorrelatedClock(wallClock, args.timelineClockFrequency) # start recording dispersion of the wall clock dispRecorder=DispersionRecorder(algorithm) dispRecorder.start() print "Connecting, requesting timeline for:" print " Any contentId beginning with:", args.contentIdStem print " and using timeline selector: ", args.timelineSelector print ts = TSClientClockController(args.tsUrl[0], args.contentIdStem, args.timelineSelector, timelineClock, correlationChangeThresholdSecs=0.0) return (ts, timelineClock, args.timelineClockFrequency, wcClient, wallClock, wcPrecisionNanos, dispRecorder)
def test_errorIfToEarly(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted(1000, 0, 0, 100, 2) self.assertRaises(ValueError, recorder.dispersionAt, 999)
def test_recordsSimple(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted(1000, 0, 0, 100, 2) self.assertEquals(102, recorder.dispersionAt(1001))
def test_errorIfToEarly(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted( 1000, 0, 0, 100, 2 ) self.assertRaises(ValueError, recorder.dispersionAt, 999)
def test_recordsSimple(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted( 1000, 0, 0, 100, 2 ) self.assertEquals(102, recorder.dispersionAt(1001))
def test_multipleHistoryEntries(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted(1000, 0, 0, 100, 2) algorithm.onClockAdjusted(2000, 3, 1994, 110, 2) algorithm.onClockAdjusted(3000, -2, 2114, 90, 3) self.assertEquals(100 + 2, recorder.dispersionAt(1001)) self.assertEquals(100 + 100, recorder.dispersionAt(1050)) self.assertEquals(110 + 12, recorder.dispersionAt(2006)) self.assertEquals(90 + 9, recorder.dispersionAt(3003))
def test_multipleHistoryEntries(self): algorithm = Mock_Algorithm() recorder = DispersionRecorder(algorithm) recorder.start() algorithm.onClockAdjusted( 1000, 0, 0, 100, 2 ) algorithm.onClockAdjusted( 2000, 3, 1994, 110, 2 ) algorithm.onClockAdjusted( 3000, -2, 2114, 90, 3 ) self.assertEquals( 100+ 2, recorder.dispersionAt(1001)) self.assertEquals( 100+100, recorder.dispersionAt(1050)) self.assertEquals( 110+ 12, recorder.dispersionAt(2006)) self.assertEquals( 90+ 9, recorder.dispersionAt(3003))