use of org.apache.kafka.common.TopicPartitionInfo in project ksql by confluentinc.
the class JoinNodeTest method setupTopicClientExpectations.
private void setupTopicClientExpectations(int streamPartitions, int tablePartitions) {
Node node = new Node(0, "localhost", 9091);
List<TopicPartitionInfo> streamPartitionInfoList = IntStream.range(0, streamPartitions).mapToObj(p -> new TopicPartitionInfo(p, node, Collections.emptyList(), Collections.emptyList())).collect(Collectors.toList());
EasyMock.expect(topicClient.describeTopics(Arrays.asList("test1"))).andReturn(Collections.singletonMap("test1", new TopicDescription("test1", false, streamPartitionInfoList)));
List<TopicPartitionInfo> tablePartitionInfoList = IntStream.range(0, tablePartitions).mapToObj(p -> new TopicPartitionInfo(p, node, Collections.emptyList(), Collections.emptyList())).collect(Collectors.toList());
EasyMock.expect(topicClient.describeTopics(Arrays.asList("test2"))).andReturn(Collections.singletonMap("test2", new TopicDescription("test2", false, tablePartitionInfoList)));
EasyMock.replay(topicClient);
}
use of org.apache.kafka.common.TopicPartitionInfo in project apache-kafka-on-k8s by banzaicloud.
the class WorkerUtilsTest method testExistingTopicsNotCreated.
@Test
public void testExistingTopicsNotCreated() throws Throwable {
final String existingTopic = "existing-topic";
List<TopicPartitionInfo> tpInfo = new ArrayList<>();
tpInfo.add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
tpInfo.add(new TopicPartitionInfo(1, broker2, singleReplica, Collections.<Node>emptyList()));
tpInfo.add(new TopicPartitionInfo(2, broker3, singleReplica, Collections.<Node>emptyList()));
adminClient.addTopic(false, existingTopic, tpInfo, null);
WorkerUtils.createTopics(log, adminClient, Collections.singletonMap(existingTopic, new NewTopic(existingTopic, tpInfo.size(), TEST_REPLICATION_FACTOR)), false);
assertEquals(Collections.singleton(existingTopic), adminClient.listTopics().names().get());
}
use of org.apache.kafka.common.TopicPartitionInfo in project apache-kafka-on-k8s by banzaicloud.
the class WorkerUtilsTest method testExistingTopicsMustHaveRequestedNumberOfPartitions.
@Test(expected = RuntimeException.class)
public void testExistingTopicsMustHaveRequestedNumberOfPartitions() throws Throwable {
List<TopicPartitionInfo> tpInfo = new ArrayList<>();
tpInfo.add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
tpInfo.add(new TopicPartitionInfo(1, broker2, singleReplica, Collections.<Node>emptyList()));
adminClient.addTopic(false, TEST_TOPIC, tpInfo, null);
WorkerUtils.createTopics(log, adminClient, Collections.singletonMap(TEST_TOPIC, NEW_TEST_TOPIC), false);
}
use of org.apache.kafka.common.TopicPartitionInfo in project apache-kafka-on-k8s by banzaicloud.
the class StreamsResetterTest method shouldDeleteTopic.
@Test
public void shouldDeleteTopic() throws InterruptedException, ExecutionException {
Cluster cluster = createCluster(1);
try (MockAdminClient adminClient = new MockAdminClient(cluster.nodes(), cluster.nodeById(0))) {
TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(0, cluster.nodeById(0), cluster.nodes(), Collections.<Node>emptyList());
adminClient.addTopic(false, TOPIC, Collections.singletonList(topicPartitionInfo), null);
streamsResetter.doDelete(Collections.singletonList(TOPIC), adminClient);
assertEquals(Collections.emptySet(), adminClient.listTopics().names().get());
}
}
use of org.apache.kafka.common.TopicPartitionInfo in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopicManagerTest method shouldNotThrowExceptionIfExistsWithDifferentReplication.
@Test
public void shouldNotThrowExceptionIfExistsWithDifferentReplication() {
mockAdminClient.addTopic(false, topic, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.<Node>emptyList())), null);
// attempt to create it again with replication 1
final InternalTopicManager internalTopicManager2 = new InternalTopicManager(mockAdminClient, new StreamsConfig(config));
final InternalTopicConfig internalTopicConfig = new RepartitionTopicConfig(topic, Collections.<String, String>emptyMap());
internalTopicConfig.setNumberOfPartitions(1);
internalTopicManager2.makeReady(Collections.singletonMap(topic, internalTopicConfig));
}
Aggregations