use of org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata in project kafka by apache.
the class ConsumerCoordinatorTest method testProtocolMetadataOrder.
@Test
public void testProtocolMetadataOrder() {
RoundRobinAssignor roundRobin = new RoundRobinAssignor();
RangeAssignor range = new RangeAssignor();
try (Metrics metrics = new Metrics(time)) {
ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(roundRobin, range), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
List<ProtocolMetadata> metadata = coordinator.metadata();
assertEquals(2, metadata.size());
assertEquals(roundRobin.name(), metadata.get(0).name());
assertEquals(range.name(), metadata.get(1).name());
}
try (Metrics metrics = new Metrics(time)) {
ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(range, roundRobin), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
List<ProtocolMetadata> metadata = coordinator.metadata();
assertEquals(2, metadata.size());
assertEquals(range.name(), metadata.get(0).name());
assertEquals(roundRobin.name(), metadata.get(1).name());
}
}
use of org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata in project kafka by apache.
the class WorkerCoordinator method metadata.
@Override
public List<ProtocolMetadata> metadata() {
configSnapshot = configStorage.snapshot();
ConnectProtocol.WorkerState workerState = new ConnectProtocol.WorkerState(restUrl, configSnapshot.offset());
ByteBuffer metadata = ConnectProtocol.serializeMetadata(workerState);
return Collections.singletonList(new ProtocolMetadata(DEFAULT_SUBPROTOCOL, metadata));
}
use of org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata in project kafka by apache.
the class ConsumerCoordinator method metadata.
@Override
public List<ProtocolMetadata> metadata() {
this.joinedSubscription = subscriptions.subscription();
List<ProtocolMetadata> metadataList = new ArrayList<>();
for (PartitionAssignor assignor : assignors) {
Subscription subscription = assignor.subscription(joinedSubscription);
ByteBuffer metadata = ConsumerProtocol.serializeSubscription(subscription);
metadataList.add(new ProtocolMetadata(assignor.name(), metadata));
}
return metadataList;
}
use of org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata in project kafka by apache.
the class WorkerCoordinatorTest method testMetadata.
// We only test functionality unique to WorkerCoordinator. Most functionality is already well tested via the tests
// that cover AbstractCoordinator & ConsumerCoordinator.
@Test
public void testMetadata() {
EasyMock.expect(configStorage.snapshot()).andReturn(configState1);
PowerMock.replayAll();
List<ProtocolMetadata> serialized = coordinator.metadata();
assertEquals(1, serialized.size());
ProtocolMetadata defaultMetadata = serialized.get(0);
assertEquals(WorkerCoordinator.DEFAULT_SUBPROTOCOL, defaultMetadata.name());
ConnectProtocol.WorkerState state = ConnectProtocol.deserializeMetadata(defaultMetadata.metadata());
assertEquals(1, state.offset());
PowerMock.verifyAll();
}
Aggregations