Search in sources :

Example 1 with DelayedOperations

use of kafka.cluster.DelayedOperations in project kafka by apache.

the class UpdateFollowerFetchStateBenchmark method setUp.

@Setup(Level.Trial)
public void setUp() {
    scheduler.startup();
    LogConfig logConfig = createLogConfig();
    logManager = new LogManagerBuilder().setLogDirs(Collections.singletonList(logDir)).setInitialOfflineDirs(Collections.emptyList()).setConfigRepository(new MockConfigRepository()).setInitialDefaultConfig(logConfig).setCleanerConfig(new CleanerConfig(0, 0, 0, 0, 0, 0.0, 0, false, "MD5")).setRecoveryThreadsPerDataDir(1).setFlushCheckMs(1000L).setFlushRecoveryOffsetCheckpointMs(10000L).setFlushStartOffsetCheckpointMs(10000L).setRetentionCheckMs(1000L).setMaxPidExpirationMs(60000).setInterBrokerProtocolVersion(ApiVersion.latestVersion()).setScheduler(scheduler).setBrokerTopicStats(brokerTopicStats).setLogDirFailureChannel(logDirFailureChannel).setTime(Time.SYSTEM).setKeepPartitionMetadataFile(true).build();
    OffsetCheckpoints offsetCheckpoints = Mockito.mock(OffsetCheckpoints.class);
    Mockito.when(offsetCheckpoints.fetch(logDir.getAbsolutePath(), topicPartition)).thenReturn(Option.apply(0L));
    DelayedOperations delayedOperations = new DelayedOperationsMock();
    // one leader, plus two followers
    List<Integer> replicas = new ArrayList<>();
    replicas.add(0);
    replicas.add(1);
    replicas.add(2);
    LeaderAndIsrPartitionState partitionState = new LeaderAndIsrPartitionState().setControllerEpoch(0).setLeader(0).setLeaderEpoch(0).setIsr(replicas).setZkVersion(1).setReplicas(replicas).setIsNew(true);
    IsrChangeListener isrChangeListener = Mockito.mock(IsrChangeListener.class);
    AlterIsrManager alterIsrManager = Mockito.mock(AlterIsrManager.class);
    partition = new Partition(topicPartition, 100, ApiVersion$.MODULE$.latestVersion(), 0, Time.SYSTEM, isrChangeListener, delayedOperations, Mockito.mock(MetadataCache.class), logManager, alterIsrManager);
    partition.makeLeader(partitionState, offsetCheckpoints, topicId);
}
Also used : Partition(kafka.cluster.Partition) TopicPartition(org.apache.kafka.common.TopicPartition) IsrChangeListener(kafka.cluster.IsrChangeListener) ArrayList(java.util.ArrayList) LogManagerBuilder(kafka.server.builders.LogManagerBuilder) CleanerConfig(kafka.log.CleanerConfig) OffsetCheckpoints(kafka.server.checkpoints.OffsetCheckpoints) AlterIsrManager(kafka.server.AlterIsrManager) MockConfigRepository(kafka.server.metadata.MockConfigRepository) LogConfig(kafka.log.LogConfig) DelayedOperations(kafka.cluster.DelayedOperations) LeaderAndIsrPartitionState(org.apache.kafka.common.message.LeaderAndIsrRequestData.LeaderAndIsrPartitionState) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

ArrayList (java.util.ArrayList)1 DelayedOperations (kafka.cluster.DelayedOperations)1 IsrChangeListener (kafka.cluster.IsrChangeListener)1 Partition (kafka.cluster.Partition)1 CleanerConfig (kafka.log.CleanerConfig)1 LogConfig (kafka.log.LogConfig)1 AlterIsrManager (kafka.server.AlterIsrManager)1 LogManagerBuilder (kafka.server.builders.LogManagerBuilder)1 OffsetCheckpoints (kafka.server.checkpoints.OffsetCheckpoints)1 MockConfigRepository (kafka.server.metadata.MockConfigRepository)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 LeaderAndIsrPartitionState (org.apache.kafka.common.message.LeaderAndIsrRequestData.LeaderAndIsrPartitionState)1 Setup (org.openjdk.jmh.annotations.Setup)1