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


Java EmbeddedZookeeper.port方法代码示例

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


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

示例1: setUpClass

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException {
    // setup Zookeeper
    zkServer = new EmbeddedZookeeper();
    zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    ZkUtils zkUtils = ZkUtils.apply(zkClient, false);

    // setup Broker
    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafkaUtils-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);

    // create topics
    AdminUtils.createTopic(zkUtils, TOPIC_R, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
    AdminUtils.createTopic(zkUtils, TOPIC_S, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:24,代码来源:KafkaUtilsTest.java

示例2: setUpClass

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException {
    // setup Zookeeper
    zkServer = new EmbeddedZookeeper();
    zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    ZkUtils zkUtils = ZkUtils.apply(zkClient, false);

    // setup Broker
    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);

    // create topic
    AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:23,代码来源:KafkaDestinationProcessorTest.java

示例3: createKafkaCluster

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
public final String createKafkaCluster() throws IOException {
    System.setProperty("zookeeper.preAllocSize", Integer.toString(128));
    zkServer = new EmbeddedZookeeper();
    String zkConnect = ZK_HOST + ':' + zkServer.port();
    ZkClient zkClient = new ZkClient(zkConnect, SESSION_TIMEOUT, CONNECTION_TIMEOUT, ZKStringSerializer$.MODULE$);
    zkUtils = ZkUtils.apply(zkClient, false);
    brokerPort = getRandomPort();

    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKER_HOST + ':' + brokerPort);
    brokerProps.setProperty("offsets.topic.replication.factor", "1");
    brokerProps.setProperty("offsets.topic.num.partitions", "1");
    // we need this due to avoid OOME while running tests, see https://issues.apache.org/jira/browse/KAFKA-3872
    brokerProps.setProperty("log.cleaner.dedupe.buffer.size", Long.toString(2 * 1024 * 1024L));
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);

    return BROKER_HOST + ':' + brokerPort;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:24,代码来源:KafkaTestSupport.java

示例4: setUpClass

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException {
    // setup Zookeeper
    zkServer = new EmbeddedZookeeper();
    zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    ZkUtils zkUtils = ZkUtils.apply(zkClient, false);

    // setup Broker
    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);

    // create topics        
    AdminUtils.createTopic(zkUtils, TOPIC_OOS, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:23,代码来源:KafkaEntranceProcessorTest.java

示例5: setup

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {

    zkServer = new EmbeddedZookeeper();

    String zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    ZkUtils zkUtils = ZkUtils.apply(zkClient, false);

    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST +":" + BROKERPORT);
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
    //AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);

    JMeterContext jmcx = JMeterContextService.getContext();
    jmcx.setVariables(new JMeterVariables());

}
 
开发者ID:GSLabDev,项目名称:pepper-box,代码行数:24,代码来源:PepperBoxSamplerTest.java

示例6: startup

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
/**
 * Starts the Embedded Kafka and Zookeeper Servers.
 * @throws Exception - If an exeption occurs during startup.
 */
protected void startup() throws Exception {
    // Setup the embedded zookeeper
    logger.info("Starting up Embedded Zookeeper...");
    zkServer = new EmbeddedZookeeper();
    zookeperConnect = ZKHOST + ":" + zkServer.port();
    logger.info("Embedded Zookeeper started at: {}", zookeperConnect);

    // setup Broker
    logger.info("Starting up Embedded Kafka...");
    brokerPort = Integer.toString(PortUtils.getRandomFreePort());
    final Properties brokerProps = new Properties();
    brokerProps.setProperty(KafkaConfig$.MODULE$.BrokerIdProp(), "0");
    brokerProps.setProperty(KafkaConfig$.MODULE$.HostNameProp(), BROKERHOST);
    brokerProps.setProperty(KafkaConfig$.MODULE$.PortProp(), brokerPort);
    brokerProps.setProperty(KafkaConfig$.MODULE$.ZkConnectProp(), zookeperConnect);
    brokerProps.setProperty(KafkaConfig$.MODULE$.LogDirsProp(), Files.createTempDirectory(getClass().getSimpleName() + "-").toAbsolutePath().toString());
    final KafkaConfig config = new KafkaConfig(brokerProps);
    final Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
    logger.info("Embedded Kafka Server started at: {}:{}", BROKERHOST, brokerPort);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:EmbeddedKafkaInstance.java

示例7: setupKafka

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
/**
 * setup mini kafka and call the super to setup mini fluo
 */
@Before
public void setupKafka() throws Exception {
    // Install an instance of Rya on the Accumulo cluster.
    installRyaInstance();

    // Setup Kafka.
    zkServer = new EmbeddedZookeeper();
    final String zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    zkUtils = ZkUtils.apply(zkClient, false);

    // setup Broker
    final Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    final KafkaConfig config = new KafkaConfig(brokerProps);
    final Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:KafkaExportITBase.java

示例8: start

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
public void start() throws IOException
{
  // Find port
  try {
    ServerSocket serverSocket = new ServerSocket(0);
    BROKERPORT = Integer.toString(serverSocket.getLocalPort());
    serverSocket.close();
  } catch (IOException e) {
    throw Throwables.propagate(e);
  }

  // Setup Zookeeper
  zkServer = new EmbeddedZookeeper();
  String zkConnect = BROKERHOST + ":" + zkServer.port();
  zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
  zkUtils = ZkUtils.apply(zkClient, false);

  // Setup brokers
  cleanupDir();
  Properties props = new Properties();
  props.setProperty("zookeeper.connect", zkConnect);
  props.setProperty("broker.id", "0");
  props.setProperty("log.dirs", KAFKA_PATH);
  props.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
  KafkaConfig config = new KafkaConfig(props);
  Time mock = new MockTime();
  kafkaServer = TestUtils.createServer(config, mock);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:29,代码来源:EmbeddedKafka.java

示例9: startCluster

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
public void startCluster() {
	// Start Zookeeper.
	_zkServer = new EmbeddedZookeeper();
	_zkConnectString = "127.0.0.1:"+_zkServer.port();
	_zkClient = new ZkClient(_zkConnectString, 30000, 30000, ZKStringSerializer$.MODULE$);
	// Start Kafka Cluster.
    for(int i=0;i<clusterCount;i++) {
    	KafkaServer _kafkaServer = createKafkaServer(i,_zkConnectString);
    	kafkaBrokerList.add(_kafkaServer);
    }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:12,代码来源:KafkaClusterTestBase.java

示例10: start

import kafka.zk.EmbeddedZookeeper; //导入方法依赖的package包/类
void start()
  throws RuntimeException {
  if (_numStarted.incrementAndGet() == 1) {
    log.warn("Starting up Kafka server suite. Zk at " + _zkConnectString + "; Kafka server at " + _kafkaServerPort);
    _zkServer = new EmbeddedZookeeper();
    _zkConnectString = "127.0.0.1:"+_zkServer.port();
    _zkClient = new ZkClient(_zkConnectString, 30000, 30000, ZKStringSerializer$.MODULE$);

    Properties props = kafka.utils.TestUtils.createBrokerConfig(
        _brokerId,
        _zkConnectString,
        kafka.utils.TestUtils.createBrokerConfig$default$3(),
        kafka.utils.TestUtils.createBrokerConfig$default$4(),
        _kafkaServerPort,
        kafka.utils.TestUtils.createBrokerConfig$default$6(),
        kafka.utils.TestUtils.createBrokerConfig$default$7(),
        kafka.utils.TestUtils.createBrokerConfig$default$8(),
        kafka.utils.TestUtils.createBrokerConfig$default$9(),
        kafka.utils.TestUtils.createBrokerConfig$default$10(),
        kafka.utils.TestUtils.createBrokerConfig$default$11(),
        kafka.utils.TestUtils.createBrokerConfig$default$12(),
        kafka.utils.TestUtils.createBrokerConfig$default$13(),
        kafka.utils.TestUtils.createBrokerConfig$default$14()
        );


    KafkaConfig config = new KafkaConfig(props);
    Time mock = new MockTime();
    _kafkaServer = kafka.utils.TestUtils.createServer(config, mock);
  }
  else
  {
    log.info("Kafka server suite already started... continuing");
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:36,代码来源:KafkaTestBase.java


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