use of org.apache.kafka.clients.Metadata in project kafka by apache.
the class AbstractCoordinatorTest method setupCoordinator.
@Before
public void setupCoordinator() {
this.mockTime = new MockTime();
this.mockClient = new MockClient(mockTime);
Metadata metadata = new Metadata();
this.consumerClient = new ConsumerNetworkClient(mockClient, metadata, mockTime, RETRY_BACKOFF_MS, REQUEST_TIMEOUT_MS);
Metrics metrics = new Metrics();
Cluster cluster = TestUtils.singletonCluster("topic", 1);
metadata.update(cluster, Collections.<String>emptySet(), mockTime.milliseconds());
this.node = cluster.nodes().get(0);
mockClient.setNode(node);
this.coordinatorNode = new Node(Integer.MAX_VALUE - node.id(), node.host(), node.port());
this.coordinator = new DummyCoordinator(consumerClient, metrics, mockTime);
}
use of org.apache.kafka.clients.Metadata in project kafka by apache.
the class StreamsKafkaClient method getAnyReadyBrokerId.
/**
* @return the Id of any broker that is ready, or an exception if no broker is ready.
*/
private String getAnyReadyBrokerId() {
final Metadata metadata = new Metadata(streamsConfig.getLong(StreamsConfig.RETRY_BACKOFF_MS_CONFIG), streamsConfig.getLong(StreamsConfig.METADATA_MAX_AGE_CONFIG));
final List<InetSocketAddress> addresses = ClientUtils.parseAndValidateAddresses(streamsConfig.getList(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
metadata.update(Cluster.bootstrap(addresses), Collections.<String>emptySet(), Time.SYSTEM.milliseconds());
final List<Node> nodes = metadata.fetch().nodes();
return ensureOneNodeIsReady(nodes);
}
Aggregations