private synchronized void startScheduledExecutor() { if ( running.get() ) { return; } getScheduledExecutorService().scheduleWithFixedDelay( new CommitTask(), delay, delay, TimeUnit.MILLISECONDS ); running.set( true ); }
private synchronized void startScheduledExecutor() { if ( running.get() ) { return; } getScheduledExecutorService().scheduleWithFixedDelay( new CommitTask(), delay, delay, TimeUnit.MILLISECONDS ); running.set( true ); }
@Test public void testScheduledCommits() throws Exception { writeData( NUMBER_ENTITIES ); AbstractWorkspaceImpl workspace = sfAsyncExclusiveIndex.extractWorkspace( testType ); CommitPolicy commitPolicy = workspace.getCommitPolicy(); assertTrue( commitPolicy instanceof ScheduledCommitPolicy ); ScheduledCommitPolicy scheduledCommitPolicy = (ScheduledCommitPolicy) commitPolicy; ScheduledThreadPoolExecutor scheduledExecutor = (ScheduledThreadPoolExecutor) scheduledCommitPolicy.getScheduledExecutorService(); POLLER.pollAssertion( () -> assertTaskExecuted( scheduledExecutor, 1 ) ); }