/** * Instructs the processor to release the segment with given {@code segmentId}. This will also blacklist this * segment for twice the {@link TrackingEventProcessorConfiguration#getTokenClaimInterval() token claim interval}, * to ensure it is not immediately reclaimed. * * @param segmentId the id of the segment to be blacklisted */ public void releaseSegment(int segmentId) { releaseSegment(segmentId, tokenClaimInterval * 2, MILLISECONDS); }
public void releaseSegment(String processor, int segmentId){ EventProcessor eventProcessor = getEventProcessor(processor); if (eventProcessor instanceof TrackingEventProcessor){ ((TrackingEventProcessor) eventProcessor).releaseSegment(segmentId); } }
} catch (UnableToClaimTokenException e) { logger.info("Segment is owned by another node. Releasing thread to process another segment..."); releaseSegment(segment.getSegmentId()); } catch (Exception e) {
@Test public void testBlacklistingSegmentWillHaveProcessorClaimAnotherOne() { tokenStore.storeToken(new GlobalSequenceTrackingToken(1L), "test", 0); tokenStore.storeToken(new GlobalSequenceTrackingToken(2L), "test", 1); tokenStore.storeToken(new GlobalSequenceTrackingToken(2L), "test", 2); testSubject.start(); assertWithin(1, SECONDS, () -> assertEquals(0, testSubject.availableProcessorThreads())); assertEquals(new HashSet<>(asList(0, 1)), testSubject.processingStatus().keySet()); testSubject.releaseSegment(0); assertWithin(5, SECONDS, () -> assertTrue(testSubject.processingStatus().containsKey(2))); assertEquals(new HashSet<>(asList(2, 1)), testSubject.processingStatus().keySet()); assertWithin(2, SECONDS, () -> assertEquals(0, testSubject.availableProcessorThreads())); }
@Test public void testHasAvailableSegments() { assertEquals(1, testSubject.availableProcessorThreads()); testSubject.start(); assertWithin(1, TimeUnit.SECONDS, () -> assertEquals(0, testSubject.availableProcessorThreads())); testSubject.releaseSegment(0); assertWithin(2, TimeUnit.SECONDS, () -> assertEquals(1, testSubject.availableProcessorThreads())); }
@Test public void testReleaseSegment() { testSubject.start(); assertWithin(1, TimeUnit.SECONDS, () -> assertEquals(1, testSubject.activeProcessorThreads())); testSubject.releaseSegment(0); assertWithin(2, TimeUnit.SECONDS, () -> assertEquals(0, testSubject.activeProcessorThreads())); assertWithin(15, TimeUnit.SECONDS, () -> assertEquals(1, testSubject.activeProcessorThreads())); }
/** * Instructs the processor to release the segment with given {@code segmentId}. This will also blacklist this * segment for twice the {@link TrackingEventProcessorConfiguration#getTokenClaimInterval() token claim interval}, * to ensure it is not immediately reclaimed. * * @param segmentId the id of the segment to be blacklisted */ public void releaseSegment(int segmentId) { releaseSegment(segmentId, tokenClaimInterval * 2, MILLISECONDS); }
/** * Instructs the processor to release the segment with given {@code segmentId}. This will also blacklist this * segment for twice the {@link TrackingEventProcessorConfiguration#getTokenClaimInterval() token claim interval}, * to ensure it is not immediately reclaimed. * * @param segmentId the id of the segment to be blacklisted */ public void releaseSegment(int segmentId) { releaseSegment(segmentId, tokenClaimInterval * 2, MILLISECONDS); }
public void releaseSegment(String processor, int segmentId){ EventProcessor eventProcessor = getEventProcessor(processor); if (eventProcessor instanceof TrackingEventProcessor){ ((TrackingEventProcessor) eventProcessor).releaseSegment(segmentId); } }
} catch (UnableToClaimTokenException e) { logger.info("Segment is owned by another node. Releasing thread to process another segment..."); releaseSegment(segment.getSegmentId()); } catch (Exception e) {
} catch (UnableToClaimTokenException e) { logger.info("Segment is owned by another node. Releasing thread to process another segment..."); releaseSegment(segment.getSegmentId()); } catch (Exception e) {