use of org.apache.kafka.timeline.SnapshotRegistry in project kafka by apache.
the class AclControlManagerTest method testAddAndDelete.
@Test
public void testAddAndDelete() {
SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
AclControlManager manager = new AclControlManager(snapshotRegistry, Optional.empty());
MockClusterMetadataAuthorizer authorizer = new MockClusterMetadataAuthorizer();
authorizer.loadSnapshot(manager.idToAcl());
manager.replay(StandardAclWithIdTest.TEST_ACLS.get(0).toRecord(), Optional.empty());
assertEquals(new ApiMessageAndVersion(TEST_ACLS.get(0).toRecord(), (short) 0), manager.iterator(Long.MAX_VALUE).next().get(0));
manager.replay(new RemoveAccessControlEntryRecord().setId(TEST_ACLS.get(0).id()), Optional.empty());
assertFalse(manager.iterator(Long.MAX_VALUE).hasNext());
}
use of org.apache.kafka.timeline.SnapshotRegistry in project kafka by apache.
the class BrokersToIsrsTest method testIterator.
@Test
public void testIterator() {
SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
BrokersToIsrs brokersToIsrs = new BrokersToIsrs(snapshotRegistry);
assertEquals(toSet(), toSet(brokersToIsrs.iterator(1, false)));
brokersToIsrs.update(UUIDS[0], 0, null, new int[] { 1, 2, 3 }, -1, 1);
brokersToIsrs.update(UUIDS[1], 1, null, new int[] { 2, 3, 4 }, -1, 4);
assertEquals(toSet(new TopicIdPartition(UUIDS[0], 0)), toSet(brokersToIsrs.iterator(1, false)));
assertEquals(toSet(new TopicIdPartition(UUIDS[0], 0), new TopicIdPartition(UUIDS[1], 1)), toSet(brokersToIsrs.iterator(2, false)));
assertEquals(toSet(new TopicIdPartition(UUIDS[1], 1)), toSet(brokersToIsrs.iterator(4, false)));
assertEquals(toSet(), toSet(brokersToIsrs.iterator(5, false)));
brokersToIsrs.update(UUIDS[1], 2, null, new int[] { 3, 2, 1 }, -1, 3);
assertEquals(toSet(new TopicIdPartition(UUIDS[0], 0), new TopicIdPartition(UUIDS[1], 1), new TopicIdPartition(UUIDS[1], 2)), toSet(brokersToIsrs.iterator(2, false)));
}
use of org.apache.kafka.timeline.SnapshotRegistry in project kafka by apache.
the class BrokersToIsrsTest method testNoLeader.
@Test
public void testNoLeader() {
SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
BrokersToIsrs brokersToIsrs = new BrokersToIsrs(snapshotRegistry);
brokersToIsrs.update(UUIDS[0], 2, null, new int[] { 1, 2, 3 }, -1, 3);
assertEquals(toSet(new TopicIdPartition(UUIDS[0], 2)), toSet(brokersToIsrs.iterator(3, true)));
assertEquals(toSet(), toSet(brokersToIsrs.iterator(2, true)));
assertEquals(toSet(), toSet(brokersToIsrs.partitionsWithNoLeader()));
brokersToIsrs.update(UUIDS[0], 2, new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }, 3, -1);
assertEquals(toSet(new TopicIdPartition(UUIDS[0], 2)), toSet(brokersToIsrs.partitionsWithNoLeader()));
}
use of org.apache.kafka.timeline.SnapshotRegistry in project kafka by apache.
the class TimelineHashMapBenchmark method testAddEntriesInTimelineMap.
@Benchmark
public Map<Integer, String> testAddEntriesInTimelineMap() {
SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
TimelineHashMap<Integer, String> map = new TimelineHashMap<>(snapshotRegistry, NUM_ENTRIES);
for (int i = 0; i < NUM_ENTRIES; i++) {
int key = (int) (0xffffffff & ((i * 2862933555777941757L) + 3037000493L));
map.put(key, String.valueOf(key));
}
return map;
}
use of org.apache.kafka.timeline.SnapshotRegistry in project kafka by apache.
the class ProducerIdControlManagerTest method setUp.
@BeforeEach
public void setUp() {
final LogContext logContext = new LogContext();
String clusterId = Uuid.randomUuid().toString();
final MockTime time = new MockTime();
final Random random = new Random();
snapshotRegistry = new SnapshotRegistry(logContext);
clusterControl = new ClusterControlManager(logContext, clusterId, time, snapshotRegistry, 1000, new StripedReplicaPlacer(random), new MockControllerMetrics());
clusterControl.activate();
for (int i = 0; i < 4; i++) {
RegisterBrokerRecord brokerRecord = new RegisterBrokerRecord().setBrokerEpoch(100).setBrokerId(i);
brokerRecord.endPoints().add(new RegisterBrokerRecord.BrokerEndpoint().setSecurityProtocol(SecurityProtocol.PLAINTEXT.id).setPort((short) 9092).setName("PLAINTEXT").setHost(String.format("broker-%02d.example.org", i)));
clusterControl.replay(brokerRecord);
}
this.producerIdControlManager = new ProducerIdControlManager(clusterControl, snapshotRegistry);
}
Aggregations