本文整理汇总了Java中kafka.common.TopicExistsException类的典型用法代码示例。如果您正苦于以下问题:Java TopicExistsException类的具体用法?Java TopicExistsException怎么用?Java TopicExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TopicExistsException类属于kafka.common包,在下文中一共展示了TopicExistsException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import kafka.common.TopicExistsException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
kafkaSource = new KafkaSource();
kafkaServer = new KafkaSourceEmbeddedKafka(null);
try {
kafkaServer.createTopic(topic0, 1);
usedTopics.add(topic0);
kafkaServer.createTopic(topic1, 3);
usedTopics.add(topic1);
} catch (TopicExistsException e) {
//do nothing
e.printStackTrace();
}
context = prepareDefaultContext("flume-group");
kafkaSource.setChannelProcessor(createGoodChannel());
}
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:18,代码来源:TestKafkaSource.java
示例2: getTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
*
* @param topic
*/
@GET
@Path("/ui/topics/{topic}")
public void getTopic(@PathParam("topic") String topic) {
try {
LOGGER.info("Fetching details of topic: " + topic);
uiService.getTopic(getDmaapContext(), topic);
LOGGER.info("Returning details of topic: " + topic);
} catch (ConfigDbException | IOException | TopicExistsException excp) {
LOGGER.error("Error while fetching details of topic: " + topic, excp);
DMaaPResponseBuilder.respondWithError(getDmaapContext(), HttpStatus.SC_NOT_FOUND,
"Error while fetching details of topic: " + topic);
}
}
开发者ID:att,项目名称:dmaap-framework,代码行数:20,代码来源:UIRestServices.java
示例3: getTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
* @param dmaapContext
* @param topicName
* @throws ConfigDbException
* @throws IOException
* @throws TopicExistsException
*/
@Override
public void getTopic(DMaaPContext dmaapContext, String topicName)
throws ConfigDbException, IOException, TopicExistsException {
// TODO - We need to work on the templates and how data will be set in
// the template
LOGGER.info("Fetching detials of apikey: " + topicName);
Topic topic = getMetaBroker(dmaapContext).getTopic(topicName);
if (null == topic) {
LOGGER.error("Topic [" + topicName + "] does not exist.");
throw new TopicExistsException("Topic [" + topicName + "] does not exist.");
}
JSONObject json = new JSONObject();
json.put("topicName", topic.getName());
json.put("description", topic.getDescription());
json.put("owner", topic.getOwner());
LOGGER.info("Returning details of topic [" + topicName + "]. Sending response.");
DMaaPResponseBuilder.respondOk(dmaapContext, json);
}
开发者ID:att,项目名称:dmaap-framework,代码行数:30,代码来源:UIServiceImpl.java
示例4: createTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
* Creates a Topic.
*
* @param topicName Topic name.
* @param partitions Number of partitions for the topic.
* @param replicationFactor Replication factor.
* @param curatorFramework CuratorFramework.
*/
public static void createTopic(String topicName, int partitions, int replicationFactor, CuratorFramework curatorFramework) {
if (partitions <= 0)
throw new AdminOperationException("number of partitions must be larger than 0");
if (replicationFactor <= 0)
throw new AdminOperationException("replication factor must be larger than 0");
if (!topicExists(topicName, curatorFramework)) {
m_logger.info(String.format("Topic %s not found, creating...", topicName));
ZkClient zkClient = fromCurator(curatorFramework);
try {
AdminUtils.createTopic(zkClient, topicName, partitions, replicationFactor, new Properties());
m_logger.info("Topic created. name: {}, partitions: {}, replicationFactor: {}", topicName,
partitions, replicationFactor);
} catch (TopicExistsException ignore) {
m_logger.info("Topic exists. name: {}", topicName);
} finally {
if (zkClient != null) {
zkClient.close();
}
}
} else {
m_logger.info(String.format("Topic %s found!", topicName));
}
}
开发者ID:Microsoft,项目名称:Availability-Monitor-for-Kafka,代码行数:34,代码来源:KafkaUtils.java
示例5: createTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
public void createTopic(String name, int numPartitions, boolean waitUntilMetadataIsPropagated) throws InterruptedException {
ZkUtils zkUtils = null;
Level oldLevel = UnitTestHelper.getJavaLoggingLevel();
try {
UnitTestHelper.setJavaLoggingLevel(Level.OFF);
zkUtils = ZkUtils.apply(zookeeperConnectString, 30000, 30000, false);
AdminUtilsWrapper.createTopic(zkUtils, name, numPartitions, 1, new Properties());
if (waitUntilMetadataIsPropagated) {
waitUntilMetadataIsPropagated(name, numPartitions);
}
}catch(TopicExistsException tee) {
}finally {
if(zkUtils != null){
zkUtils.close();
}
UnitTestHelper.setJavaLoggingLevel(oldLevel);
}
}
开发者ID:apache,项目名称:metron,代码行数:19,代码来源:KafkaComponent.java
示例6: createKafkaTopicIfNecessary
import kafka.common.TopicExistsException; //导入依赖的package包/类
public static boolean createKafkaTopicIfNecessary(String brokerUri, int replFactor, int numPartitions, String topic)
throws IOException {
URI zkUri = URI.create(brokerUri);
Preconditions.checkArgument("zk".equals(zkUri.getScheme()));
String zkServerList = zkUri.getAuthority() + zkUri.getPath();
ZkUtils zkUtils = ZkUtils.apply(zkServerList, ZK_SESSION_TIMEOUT_MS,
ZK_CONNECTION_TIMEOUT_MS, JaasUtils.isZkSecurityEnabled());
try {
if (AdminUtils.topicExists(zkUtils, topic)) {
return false;
}
try {
AdminUtils.createTopic(zkUtils, topic, numPartitions, replFactor, new Properties());
} catch (TopicExistsException ignored) {
return false;
} catch (RuntimeException e) {
throw new IOException(e);
}
} finally {
if (zkUtils != null) {
zkUtils.close();
}
}
return true;
}
开发者ID:uber,项目名称:AthenaX,代码行数:28,代码来源:KafkaTestUtil.java
示例7: createTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
* Creates a new topic
* @param topicName The topic name
* @param partitionCount The partition count
* @param replicaCount The replica count
* @param topicProperties The optional topic properties
* @throws TopicExistsException thrown if the requested topic already exists
*/
public void createTopic(final String topicName, final int partitionCount, final int replicaCount, final Properties topicProperties) throws TopicExistsException {
if(!running.get()) throw new IllegalStateException("The KafkaTestServer is not running");
if(topicName==null || topicName.trim().isEmpty()) throw new IllegalArgumentException("The passed topic name was null or empty");
if(partitionCount < 1) throw new IllegalArgumentException("Invalid topic partition count: " + partitionCount);
if(replicaCount < 1) throw new IllegalArgumentException("Invalid topic replica count: " + replicaCount);
final ZkUtils z = getZkUtils();
AdminUtils.createTopic(z, topicName, partitionCount, replicaCount, topicProperties==null ? new Properties() : topicProperties, new RackAwareMode.Disabled$());
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:17,代码来源:KafkaTestServer.java
示例8: create
import kafka.common.TopicExistsException; //导入依赖的package包/类
public void create(final String... topics) {
final ZkClient zkClient = createZkClient();
final List<String> existingTopics = getTopics(zkClient);
try {
for (final String topic:topics) {
if ( ! (existingTopics.contains(topic) || exists(zkClient, topic)) ) {
String[] args = {
"--zookeeper", zkConnect,
"--partitions", "1",
"--replication-factor", "1",
"--create",
"--topic", topic
};
final TopicCommand.TopicCommandOptions opts = new TopicCommand.TopicCommandOptions(args);
opts.checkArgs();
try {
TopicCommand.createTopic(zkClient, opts);
} catch (TopicExistsException e) {
LOGGER.warn("unable to create topic, the topic '{}' is already defined", topic, e);
}
}
}
} finally {
zkClient.close();
}
}
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:31,代码来源:TopicStatement.java
示例9: createTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
* Creates a new topic
* @param topicName The topic name
* @param partitionCount The partition count
* @param replicaCount The replica count
* @param topicProperties The optional topic properties
* @throws TopicExistsException thrown if the requested topic already exists
*/
public void createTopic(final String topicName, final int partitionCount, final int replicaCount, final Properties topicProperties) throws TopicExistsException {
if(!connected.get()) throw new IllegalStateException("The KafkaTestServer is not running");
if(topicName==null || topicName.trim().isEmpty()) throw new IllegalArgumentException("The passed topic name was null or empty");
if(partitionCount < 1) throw new IllegalArgumentException("Invalid topic partition count: " + partitionCount);
if(replicaCount < 1) throw new IllegalArgumentException("Invalid topic replica count: " + replicaCount);
AdminUtils.createTopic(zkUtils, topicName, partitionCount, replicaCount, topicProperties==null ? new Properties() : topicProperties, new RackAwareMode.Disabled$());
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:16,代码来源:KafkaAdminClient.java
示例10: getTopic
import kafka.common.TopicExistsException; //导入依赖的package包/类
/**
* Fetching detials of topic in a templated form for display
*
* @param dmaapContext
* @param topic
* @throws ConfigDbException
* @throws IOException
* @throws TopicExistsException
*/
void getTopic(DMaaPContext dmaapContext, final String topic)
throws ConfigDbException, IOException, TopicExistsException;
开发者ID:att,项目名称:dmaap-framework,代码行数:12,代码来源:UIService.java
注:本文中的kafka.common.TopicExistsException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论