Search in sources :

Example 1 with BrokerEndpointCollection

use of org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpointCollection in project kafka by apache.

the class ClusterControlManagerTest method testIterator.

@Test
public void testIterator() throws Exception {
    MockTime time = new MockTime(0, 0, 0);
    SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
    ClusterControlManager clusterControl = new ClusterControlManager(new LogContext(), Uuid.randomUuid().toString(), time, snapshotRegistry, 1000, new StripedReplicaPlacer(new Random()), new MockControllerMetrics());
    clusterControl.activate();
    assertFalse(clusterControl.unfenced(0));
    for (int i = 0; i < 3; i++) {
        RegisterBrokerRecord brokerRecord = new RegisterBrokerRecord().setBrokerEpoch(100).setBrokerId(i).setRack(null);
        brokerRecord.endPoints().add(new BrokerEndpoint().setSecurityProtocol(SecurityProtocol.PLAINTEXT.id).setPort((short) 9092 + i).setName("PLAINTEXT").setHost("example.com"));
        clusterControl.replay(brokerRecord);
    }
    for (int i = 0; i < 2; i++) {
        UnfenceBrokerRecord unfenceBrokerRecord = new UnfenceBrokerRecord().setId(i).setEpoch(100);
        clusterControl.replay(unfenceBrokerRecord);
    }
    RecordTestUtils.assertBatchIteratorContains(Arrays.asList(Arrays.asList(new ApiMessageAndVersion(new RegisterBrokerRecord().setBrokerEpoch(100).setBrokerId(0).setRack(null).setEndPoints(new BrokerEndpointCollection(Collections.singleton(new BrokerEndpoint().setSecurityProtocol(SecurityProtocol.PLAINTEXT.id).setPort((short) 9092).setName("PLAINTEXT").setHost("example.com")).iterator())).setFenced(false), (short) 0)), Arrays.asList(new ApiMessageAndVersion(new RegisterBrokerRecord().setBrokerEpoch(100).setBrokerId(1).setRack(null).setEndPoints(new BrokerEndpointCollection(Collections.singleton(new BrokerEndpoint().setSecurityProtocol(SecurityProtocol.PLAINTEXT.id).setPort((short) 9093).setName("PLAINTEXT").setHost("example.com")).iterator())).setFenced(false), (short) 0)), Arrays.asList(new ApiMessageAndVersion(new RegisterBrokerRecord().setBrokerEpoch(100).setBrokerId(2).setRack(null).setEndPoints(new BrokerEndpointCollection(Collections.singleton(new BrokerEndpoint().setSecurityProtocol(SecurityProtocol.PLAINTEXT.id).setPort((short) 9094).setName("PLAINTEXT").setHost("example.com")).iterator())).setFenced(true), (short) 0))), clusterControl.iterator(Long.MAX_VALUE));
}
Also used : BrokerEndpointCollection(org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpointCollection) LogContext(org.apache.kafka.common.utils.LogContext) Endpoint(org.apache.kafka.common.Endpoint) BrokerEndpoint(org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpoint) SnapshotRegistry(org.apache.kafka.timeline.SnapshotRegistry) Random(java.util.Random) RegisterBrokerRecord(org.apache.kafka.common.metadata.RegisterBrokerRecord) BrokerEndpoint(org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpoint) ApiMessageAndVersion(org.apache.kafka.server.common.ApiMessageAndVersion) UnfenceBrokerRecord(org.apache.kafka.common.metadata.UnfenceBrokerRecord) MockTime(org.apache.kafka.common.utils.MockTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Random (java.util.Random)1 Endpoint (org.apache.kafka.common.Endpoint)1 RegisterBrokerRecord (org.apache.kafka.common.metadata.RegisterBrokerRecord)1 BrokerEndpoint (org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpoint)1 BrokerEndpointCollection (org.apache.kafka.common.metadata.RegisterBrokerRecord.BrokerEndpointCollection)1 UnfenceBrokerRecord (org.apache.kafka.common.metadata.UnfenceBrokerRecord)1 LogContext (org.apache.kafka.common.utils.LogContext)1 MockTime (org.apache.kafka.common.utils.MockTime)1 ApiMessageAndVersion (org.apache.kafka.server.common.ApiMessageAndVersion)1 SnapshotRegistry (org.apache.kafka.timeline.SnapshotRegistry)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1