当前位置: 首页>>代码示例>>Java>>正文


Java AdminUtils.deleteTopic方法代码示例

本文整理汇总了Java中kafka.admin.AdminUtils.deleteTopic方法的典型用法代码示例。如果您正苦于以下问题:Java AdminUtils.deleteTopic方法的具体用法?Java AdminUtils.deleteTopic怎么用?Java AdminUtils.deleteTopic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kafka.admin.AdminUtils的用法示例。


在下文中一共展示了AdminUtils.deleteTopic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteTopics

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
 * Deletes the named topics
 * @param topicNames The names of the topics to delete
 * @return A set of the names of the topics that were successfully deleted
 */
public String[] deleteTopics(final String...topicNames) {
	if(!connected.get()) throw new IllegalStateException("The KafkaTestServer is not running");
	if(topicNames==null || topicNames.length==0) return new String[0];
	final Set<String> deleted = new LinkedHashSet<String>();
	for(String topicName: topicNames) {
		if(topicName==null || topicName.trim().isEmpty()) {
			try {
				AdminUtils.deleteTopic(zkUtils, topicName.trim());
				deleted.add(topicName.trim());
			} catch (Exception ex) {
				log.warn("Failed to delete topic [" + topicName.trim() + "]", ex);
			}
		}
	}
	return deleted.toArray(new String[deleted.size()]);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:22,代码来源:KafkaAdminClient.java

示例2: deleteTopics

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
 * Deletes the named topics
 * @param topicNames The names of the topics to delete
 * @return A set of the names of the topics that were successfully deleted
 */
public String[] deleteTopics(final String...topicNames) {
	if(!running.get()) throw new IllegalStateException("The KafkaTestServer is not running");
	if(topicNames==null || topicNames.length==0) return new String[0];
	final Set<String> deleted = new LinkedHashSet<String>();
	final ZkUtils z = getZkUtils();
	for(String topicName: topicNames) {
		if(topicName==null || topicName.trim().isEmpty()) {
			try {
				AdminUtils.deleteTopic(z, topicName.trim());
				deleted.add(topicName.trim());
			} catch (Exception ex) {
				log.warn("Failed to delete topic [" + topicName.trim() + "]", ex);
			}
		}
	}
	return deleted.toArray(new String[deleted.size()]);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:23,代码来源:KafkaTestServer.java

示例3: deleteTestTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
@Override
public void deleteTestTopic(String topic) {
	ZkUtils zkUtils = getZkUtils();
	try {
		LOG.info("Deleting topic {}", topic);

		ZkClient zk = new ZkClient(zookeeperConnectionString, Integer.valueOf(standardProps.getProperty("zookeeper.session.timeout.ms")),
			Integer.valueOf(standardProps.getProperty("zookeeper.connection.timeout.ms")), new ZooKeeperStringSerializer());

		AdminUtils.deleteTopic(zkUtils, topic);

		zk.close();
	} finally {
		zkUtils.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:KafkaTestEnvironmentImpl.java

示例4: deleteTopics

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public static void deleteTopics(final KafkaEmbedded kafkaEmbedded, final String... topics) {
    ZkUtils zkUtils = new ZkUtils(kafkaEmbedded.getZkClient(), null, false);
    for (String topic : topics) {

        if (AdminUtils.topicExists(zkUtils, topic)) {
            LOGGER.info("Deleting topic {}", topic);
            kafkaEmbedded.waitUntilSynced(topic, 0);
            AdminUtils.deleteTopic(zkUtils, topic);
            while (AdminUtils.topicExists(zkUtils, topic)) {
                //wait for topic to die
            }
            kafkaEmbedded.waitUntilSynced(topic, 0);
        }
    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:16,代码来源:KafkaEmbededUtils.java

示例5: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public static void deleteTopic(String topicName) {
  int sessionTimeoutMs = 10000;
  int connectionTimeoutMs = 10000;
  ZkUtils zkUtils =
      ZkUtils.apply(testUtil.getZkUrl(), sessionTimeoutMs, connectionTimeoutMs, false);
  AdminUtils.deleteTopic(zkUtils, topicName);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:8,代码来源:TestKafkaSink.java

示例6: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public void deleteTopic(final String topic) {
    log.debug("Deleting topic { name: {} }", topic);

    final ZkClient zkClient = new ZkClient(
        zookeeperConnect(),
        DEFAULT_ZK_SESSION_TIMEOUT_MS,
        DEFAULT_ZK_CONNECTION_TIMEOUT_MS,
        ZKStringSerializer$.MODULE$);
    final boolean isSecure = false;
    final ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(zookeeperConnect()), isSecure);
    AdminUtils.deleteTopic(zkUtils, topic);
    zkClient.close();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:14,代码来源:KafkaEmbedded.java

示例7: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
 * @param zkServers Zookeeper server string: host1:port1[,host2:port2,...]
 * @param topic topic to delete, if it exists
 */
public static void deleteTopic(String zkServers, String topic) {
  ZkUtils zkUtils = ZkUtils.apply(zkServers, ZK_TIMEOUT_MSEC, ZK_TIMEOUT_MSEC, false);
  try {
    if (AdminUtils.topicExists(zkUtils, topic)) {
      log.info("Deleting topic {}", topic);
      AdminUtils.deleteTopic(zkUtils, topic);
      log.info("Deleted Zookeeper topic {}", topic);
    } else {
      log.info("No need to delete topic {} as it does not exist", topic);
    }
  } finally {
    zkUtils.close();
  }
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:19,代码来源:KafkaUtils.java

示例8: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public void deleteTopic(final String topic) {
  log.debug("Deleting topic { name: {} }", topic);

  final ZkClient zkClient = new ZkClient(
      zookeeperConnect(),
      DEFAULT_ZK_SESSION_TIMEOUT_MS,
      DEFAULT_ZK_CONNECTION_TIMEOUT_MS,
      ZKStringSerializer$.MODULE$);
  final boolean isSecure = false;
  final ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(zookeeperConnect()), isSecure);
  AdminUtils.deleteTopic(zkUtils, topic);
  zkClient.close();
}
 
开发者ID:Landoop,项目名称:kafka-testkit,代码行数:14,代码来源:KafkaEmbedded.java

示例9: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
@Override
public void deleteTopic(final String topicName) {
    if (AdminUtils.topicExists(zkUtils, topicName)) {
        AdminUtils.deleteTopic(zkUtils, topicName);
    }
    throw new UnknownTopicException(topicName);
}
 
开发者ID:craftsmenlabs,项目名称:kafka-admin-rest-api,代码行数:8,代码来源:TopicServiceImpl.java

示例10: deleteTestTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
@Override
public void deleteTestTopic(String topic) {
	LOG.info("Deleting topic {}", topic);

	ZkClient zk = createZkClient();
	AdminUtils.deleteTopic(zk, topic);
	zk.close();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:KafkaTestEnvironmentImpl.java

示例11: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
 * Delete topic
 *
 * @return if the topic was deleted or not
 */
public synchronized boolean deleteTopic(String topic) {
  boolean deleted = true;
  try {
    AdminUtils.deleteTopic(getZooKeeperUtils(), topic);
  } catch (TopicAlreadyMarkedForDeletionException topicAlreadyMarkedForDeletionException) {
    deleted = false;
  }
  return deleted && AdminUtils.topicExists(getZooKeeperUtils(), topic);
}
 
开发者ID:ggear,项目名称:cloudera-framework,代码行数:15,代码来源:KafkaServer.java

示例12: tearDownClass

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
@AfterClass
public static void tearDownClass() {
  for (int i = 0; i < topics.length; i++) {
    AdminUtils.deleteTopic(zkUtils, topics[i]);
  }
  kafkaServer.shutdown();
  zookeeper.shutdown();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:9,代码来源:KafkaProducer09IT.java

示例13: deleteTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
 * Delete may not work
 *
 * @param topic
 */
public void deleteTopic(String topic) {
    ZkClient zkClient = new ZkClient(zkConnection);
    ZkUtils zkUtils = new ZkUtils(zkClient, zkConnection, false);
    zkClient.setZkSerializer(new ZKStringSerializer());
    AdminUtils.deleteTopic(zkUtils, topic);
    zkClient.close();
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:MockKafka.java

示例14: deleteKafkaTopic

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public static void deleteKafkaTopic(String zkConnString, String topicName) {
    final int sessionTimeoutMillis = 10000;
    final int connTimeOutMillis = 10000;
    ZkClient zkClient = new ZkClient(zkConnString, sessionTimeoutMillis, connTimeOutMillis, ZKStringSerializer$.MODULE$);

    try {
        AdminUtils.deleteTopic(zkClient, topicName);
    } catch (Exception e) {
        LOG.warn("could not delete topic " + topicName + " assuming that it does not exist and moving on.", e);
    }
}
 
开发者ID:Parth-Brahmbhatt,项目名称:storm-smoke-test,代码行数:12,代码来源:CleanupUtils.java

示例15: stopClients

import kafka.admin.AdminUtils; //导入方法依赖的package包/类
public void stopClients() throws IOException {
  for (Map.Entry<String, KafkaConsumerSuite> consumerSuiteEntry: _topicConsumerMap.entrySet())
  {
    consumerSuiteEntry.getValue().shutdown();
    AdminUtils.deleteTopic(_kafkaServerSuite.getZkClient(), consumerSuiteEntry.getKey());
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:8,代码来源:KafkaTestBase.java


注:本文中的kafka.admin.AdminUtils.deleteTopic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。