@Override public void start() { LOG.info("Starting embedded kafka server..."); kafkaServer = new EmbeddedKafkaServer(kafkaProperties); Service.State state = kafkaServer.startAndWait(); if (state != Service.State.RUNNING) { throw new IllegalStateException("Kafka server has not started... terminating."); } LOG.info("Embedded kafka server started successfully."); }
@Override public void start() { LOG.info("Starting embedded kafka server..."); kafkaServer = new EmbeddedKafkaServer(kafkaProperties); Service.State state = kafkaServer.startAndWait(); if (state != Service.State.RUNNING) { throw new IllegalStateException("Kafka server has not started... terminating."); } LOG.info("Embedded kafka server started successfully."); }
@Override protected void startUp() throws Exception { // Create the ZK node for Kafka to use. If the node already exists, delete it to make sure there is // no left over content from previous AM attempt. LOG.info("Preparing Kafka ZK path {}{}", zkClient.getConnectString(), kafkaZKPath); ZKOperations.createDeleteIfExists(zkClient, kafkaZKPath, null, CreateMode.PERSISTENT, true).get(); kafkaServer.startAndWait(); }
@Override protected void startUp() throws Exception { // Create the ZK node for Kafka to use. If the node already exists, delete it to make sure there is // no left over content from previous AM attempt. LOG.info("Preparing Kafka ZK path {}{}", zkClient.getConnectString(), kafkaZKPath); ZKOperations.createDeleteIfExists(zkClient, kafkaZKPath, null, CreateMode.PERSISTENT, true).get(); kafkaServer.startAndWait(); }
@Override protected void before() throws Throwable { tmpFolder.create(); zkServer = InMemoryZKServer.builder().setDataDir(tmpFolder.newFolder()).build(); zkServer.startAndWait(); LOG.info("In memory ZK started on {}", zkServer.getConnectionStr()); kafkaServer = new EmbeddedKafkaServer(generateKafkaConfig()); kafkaServer.startAndWait(); initializeCConf(); injector = createInjector(); zkClient = injector.getInstance(ZKClientService.class); zkClient.startAndWait(); kafkaClient = injector.getInstance(KafkaClientService.class); kafkaClient.startAndWait(); brokerService = injector.getInstance(BrokerService.class); brokerService.startAndWait(); String brokerList = updateKafkaBrokerList(injector.getInstance(CConfiguration.class), brokerService); LOG.info("Waiting for Kafka server to startup..."); waitForKafkaStartup(); LOG.info("Kafka server started with broker list {}", brokerList); }
@Before public void beforeTest() throws Exception { zkServer = InMemoryZKServer.builder().setDataDir(TEMP_FOLDER.newFolder()).build(); zkServer.startAndWait(); CConfiguration cConf = CConfiguration.create(); String kafkaZKNamespace = cConf.get(KafkaConstants.ConfigKeys.ZOOKEEPER_NAMESPACE_CONFIG); kafkaZKConnect = zkServer.getConnectionStr(); if (kafkaZKNamespace != null) { ZKClientService zkClient = new DefaultZKClientService(zkServer.getConnectionStr(), 2000, null, ImmutableMultimap.<String, byte[]>of()); zkClient.startAndWait(); zkClient.create("/" + kafkaZKNamespace, null, CreateMode.PERSISTENT); zkClient.stopAndWait(); kafkaZKConnect += "/" + kafkaZKNamespace; } kafkaServer = createKafkaServer(kafkaZKConnect, TEMP_FOLDER.newFolder()); kafkaServer.startAndWait(); }