public int getWindowPeriodMillis() { if (StringUtils.isNotBlank(windowPeriod)) { return TimePeriodUtils.getMillisecondsOfPeriod(Period.parse(windowPeriod)); } else { return 0; } }
long windowPeriod = TimePeriodUtils.getMillisecondsOfPeriod(Period.parse(segments[0])); distinctWindow = new DistinctValuesInTimeBatchWindow(this, windowPeriod, wisbValues);
long windowPeriod = TimePeriodUtils.getMillisecondsOfPeriod(Period.parse(segments[0])); distinctWindow = new DistinctValuesInTimeWindow(windowPeriod); this.wisbType = NoDataWisbType.valueOf(segments[1]);
@Override public StreamWindow addNewWindow(long initialTime) { synchronized (windowBuckets) { if (!reject(initialTime)) { Long windowStartTime = TimePeriodUtils.formatMillisecondsByPeriod(initialTime, windowPeriod); Long windowEndTime = windowStartTime + TimePeriodUtils.getMillisecondsOfPeriod(windowPeriod); StreamWindow window = StreamWindowRepository.getSingletonInstance().createWindow(windowStartTime, windowEndTime, windowMargin); window.register(collector); addWindow(window); return window; } else { throw new IllegalStateException("Failed to create new window, as " + DateTimeUtil.millisecondsToHumanDateWithMilliseconds(initialTime) + " is too late, only allow timestamp after " + DateTimeUtil.millisecondsToHumanDateWithMilliseconds(rejectTime)); } } }
@Test public void testPeriod() { Assert.assertEquals(30 * 60 * 1000, TimePeriodUtils.getMillisecondsOfPeriod(Period.parse("PT30m"))); Assert.assertEquals(30 * 60 * 1000, TimePeriodUtils.getMillisecondsOfPeriod(Period.millis(30 * 60 * 1000))); Assert.assertEquals("PT1800S", Period.millis(30 * 60 * 1000).toString()); } }