@Override public void shutdown() { timerService.shutdown(); }
public void dispose() { // for ( TimerInstance timer : timers.values() ) { // timerService.removeJob( timer.getJobHandle() ); // } if (timerService instanceof RegisteredTimerServiceDelegate) { timers.clear(); return; } for (Iterator<TimerInstance> it = timers.values().iterator(); it.hasNext();) { TimerInstance timer = it.next(); timerService.removeJob(timer.getJobHandle()); it.remove(); } timerService.shutdown(); }
public void close(boolean removeJobs) { cacheManager.dispose(); environment.close(); registry.remove(identifier); TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); if (timerService != null) { try { if (removeJobs && timerService instanceof GlobalTimerService) { ((GlobalTimerService) timerService).destroy(); } timerService.shutdown(); GlobalSchedulerService schedulerService = ((SchedulerProvider) environment).getSchedulerService(); if (schedulerService != null) { schedulerService.shutdown(); } } finally { TimerServiceRegistry.getInstance().remove(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); } } this.closed = true; }
@Override public void shutdown() { timerService.shutdown(); }
@Test public void testRepeatedExecutionJob() throws Exception { SessionConfiguration config = SessionConfiguration.newInstance(); config.setClockType(ClockType.REALTIME_CLOCK); TimerService timeService = TimerServiceFactory.getTimerService( config ); Trigger trigger = new DelayedTrigger( new long[] { 100, 100, 100} ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 500 ); timeService.shutdown(); assertEquals( 3, ctx.getList().size() ); }
@Test public void testSingleExecutionJob() throws Exception { SessionConfiguration config = SessionConfiguration.newInstance(); config.setClockType(ClockType.REALTIME_CLOCK); TimerService timeService = TimerServiceFactory.getTimerService( config ); Trigger trigger = new DelayedTrigger( 100 ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 500 ); timeService.shutdown(); assertEquals( 1, ctx.getList().size() ); }
@Test public void testRepeatedExecutionJobWithRemove() throws Exception { SessionConfiguration config = SessionConfiguration.newInstance(); config.setClockType(ClockType.REALTIME_CLOCK); TimerService timeService = TimerServiceFactory.getTimerService( config ); Trigger trigger = new DelayedTrigger( new long[] {100, 100, 100, 100, 100, 100, 100, 100} ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); ctx.setLimit( 3 ); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 1000 ); timeService.shutdown(); assertEquals( 5, ctx.getList().size() ); }
public void dispose() { // for ( TimerInstance timer : timers.values() ) { // timerService.removeJob( timer.getJobHandle() ); // } if (timerService instanceof RegisteredTimerServiceDelegate) { timers.clear(); return; } for (Iterator<TimerInstance> it = timers.values().iterator(); it.hasNext();) { TimerInstance timer = it.next(); timerService.removeJob(timer.getJobHandle()); it.remove(); } timerService.shutdown(); }
public void close(boolean removeJobs) { cacheManager.dispose(); environment.close(); registry.remove(identifier); TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); if (timerService != null) { try { if (removeJobs && timerService instanceof GlobalTimerService) { ((GlobalTimerService) timerService).destroy(); } timerService.shutdown(); GlobalSchedulerService schedulerService = ((SchedulerProvider) environment).getSchedulerService(); if (schedulerService != null) { schedulerService.shutdown(); } } finally { TimerServiceRegistry.getInstance().remove(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX); } } this.closed = true; }