Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Kafka >> mail # user >> problem to start a kafka broker from java unit tests


Copy link to this message
-
Re: problem to start a kafka broker from java unit tests
I tried your test on 0.8 HEAD and it succeeded. Here is the log4j output
from the test run - http://pastebin.com/sP98SJuu

Could you try running your test again on 0.8 HEAD ?

Thanks,
Neha
On Tue, Sep 17, 2013 at 11:46 AM, Wu, Jiang2 <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I have some problem to start a local broker from java unit tests in
> eclipse. My code is as follows:
>
> @Test
> public void test(){
>                 KafkaServer server;
>                 EmbeddedZookeeper zk;
>
>                 zk=new EmbeddedZookeeper("127.0.0.1:2181");
>                 Properties props=new Properties();
>                 props.put("broker.id", "0");
>                 props.put("zookeeper.connect", "127.0.01:2181");
>                 props.put("log.dirs", "logDir");
>                 KafkaConfig kafkaConfig = new KafkaConfig(props);
>                 server = kafka.utils.TestUtils.createServer(kafkaConfig,
> null);
>                 ...
>                 server.shutDown();
> }
>
> It seems that both the zookeeper and kafka broker are started correctly,
> because /brokers, /controller_epoch are created in zookeeper. But the
> broker keeps throwing the following exceptions:
>
>
> 13/09/17 14:32:01 ERROR server.ZookeeperLeaderElector: Error while
> electing or becoming leader on broker 0
> java.net.ConnectException: Connection refused: connect
>         at sun.nio.ch.Net.connect0(Native Method)
>         at sun.nio.ch.Net.connect(Unknown Source)
>         at sun.nio.ch.Net.connect(Unknown Source)
>         at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
>         at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57)
>         at
> kafka.controller.ControllerChannelManager.kafka$controller$ControllerChannelManager$$addNewBroker(ControllerChannelManager.scala:82)
>         at
> kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:34)
>         at
> kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:34)
>         at scala.collection.immutable.Set$Set1.foreach(Set.scala:81)
>         at
> kafka.controller.ControllerChannelManager.<init>(ControllerChannelManager.scala:34)
>         at
> kafka.controller.KafkaController.startChannelManager(KafkaController.scala:520)
>         at
> kafka.controller.KafkaController.initializeControllerContext(KafkaController.scala:484)
>         at
> kafka.controller.KafkaController.onControllerFailover(KafkaController.scala:240)
>         at
> kafka.controller.KafkaController$$anonfun$1.apply$mcV$sp(KafkaController.scala:88)
>         at
> kafka.server.ZookeeperLeaderElector.elect(ZookeeperLeaderElector.scala:53)
>         at
> kafka.server.ZookeeperLeaderElector$LeaderChangeListener.handleDataDeleted(ZookeeperLeaderElector.scala:106)
>         at org.I0Itec.zkclient.ZkClient$6.run(ZkClient.java:549)
>         at org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:71)
> 13/09/17 14:32:01 INFO server.ZookeeperLeaderElector: 0 successfully
> elected as leader
> 13/09/17 14:32:01 INFO controller.KafkaController: [Controller 0]: Broker
> 0 starting become controller state transition
> 13/09/17 14:32:01 INFO controller.KafkaController: [Controller 0]:
> Controller 0 incremented epoch to 3
> 13/09/17 14:32:01 ERROR server.ZookeeperLeaderElector: Error while
> electing or becoming leader on broker 0
> java.net.ConnectException: Connection refused: connect
>         at sun.nio.ch.Net.connect0(Native Method)
>         at sun.nio.ch.Net.connect(Unknown Source)
>         at sun.nio.ch.Net.connect(Unknown Source)
>         at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
>         at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57)
>         at
> kafka.controller.ControllerChannelManager.kafka$controller$ControllerChannelManager$$addNewBroker(ControllerChannelManager.scala:82)
>         at
> kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:34)
>         at
> kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:34)

 
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB