use of org.apache.kafka.common.requests.FindCoordinatorRequest.NoBatchedFindCoordinatorsException in project kafka by apache.
the class AdminApiDriverTest method testRetryLookupAndDisableBatchAfterNoBatchedFindCoordinatorsException.
@Test
public void testRetryLookupAndDisableBatchAfterNoBatchedFindCoordinatorsException() {
MockTime time = new MockTime();
LogContext lc = new LogContext();
Set<String> groupIds = new HashSet<>(Arrays.asList("g1", "g2"));
DeleteConsumerGroupsHandler handler = new DeleteConsumerGroupsHandler(lc);
AdminApiFuture<CoordinatorKey, Void> future = AdminApiFuture.forKeys(groupIds.stream().map(g -> CoordinatorKey.byGroupId(g)).collect(Collectors.toSet()));
AdminApiDriver<CoordinatorKey, Void> driver = new AdminApiDriver<>(handler, future, time.milliseconds() + API_TIMEOUT_MS, RETRY_BACKOFF_MS, new LogContext());
assertTrue(((CoordinatorStrategy) handler.lookupStrategy()).batch);
List<RequestSpec<CoordinatorKey>> requestSpecs = driver.poll();
// Expect CoordinatorStrategy to try resolving all coordinators in a single request
assertEquals(1, requestSpecs.size());
RequestSpec<CoordinatorKey> requestSpec = requestSpecs.get(0);
driver.onFailure(time.milliseconds(), requestSpec, new NoBatchedFindCoordinatorsException("message"));
assertFalse(((CoordinatorStrategy) handler.lookupStrategy()).batch);
// Batching is now disabled, so we now have a request per groupId
List<RequestSpec<CoordinatorKey>> retryLookupSpecs = driver.poll();
assertEquals(groupIds.size(), retryLookupSpecs.size());
// These new requests are treated a new requests and not retries
for (RequestSpec<CoordinatorKey> retryLookupSpec : retryLookupSpecs) {
assertEquals(0, retryLookupSpec.nextAllowedTryMs);
assertEquals(0, retryLookupSpec.tries);
}
}
Aggregations