use of kafka.admin.AdminClient in project kafka by apache.
the class StreamsResetter method run.
public int run(final String[] args, final Properties config) {
consumerConfig.clear();
consumerConfig.putAll(config);
int exitCode = EXIT_CODE_SUCCESS;
AdminClient adminClient = null;
ZkUtils zkUtils = null;
try {
parseArguments(args);
adminClient = AdminClient.createSimplePlaintext(options.valueOf(bootstrapServerOption));
final String groupId = options.valueOf(applicationIdOption);
if (!adminClient.describeConsumerGroup(groupId, 0).consumers().get().isEmpty()) {
throw new IllegalStateException("Consumer group '" + groupId + "' is still active. " + "Make sure to stop all running application instances before running the reset tool.");
}
zkUtils = ZkUtils.apply(options.valueOf(zookeeperOption), 30000, 30000, JaasUtils.isZkSecurityEnabled());
allTopics.clear();
allTopics.addAll(scala.collection.JavaConversions.seqAsJavaList(zkUtils.getAllTopics()));
resetInputAndInternalAndSeekToEndIntermediateTopicOffsets();
deleteInternalTopics(zkUtils);
} catch (final Throwable e) {
exitCode = EXIT_CODE_ERROR;
System.err.println("ERROR: " + e.getMessage());
} finally {
if (adminClient != null) {
adminClient.close();
}
if (zkUtils != null) {
zkUtils.close();
}
}
return exitCode;
}
Aggregations