Re: calling ad-hoc topic creation from code

2014-02-25 Thread David Morales de Frías
[solved]. zkClient needs a serializer. This is the final code: ZkClient zkClient = new ZkClient(zookeeperCluster, 3, 3); zkClient.setZkSerializer(new ZkSerializer() { @Override public byte[] serialize(Object o) throws ZkMarshallingError { return ZKStri

Re: calling ad-hoc topic creation from code

2014-02-25 Thread David Morales de Frías
Nope... i have checked this and replication factor is 1. Anyway, when i tried to increase this param, an exception is thrown (rep. factor greater than num. of brokers). There is no difference in this code and the script, apparently, i can only see changes in the constructor used in zkClient. Any

Re: calling ad-hoc topic creation from code

2014-02-25 Thread Neha Narkhede
David, Topic creation can fail if you specify the replication factor > # of brokers in the cluster. Can you check if that is true in your case? Unfortunately, I don't think we fail the createTopic() API with the appropriate exception since there is still a race condition where the broker can come

Re: calling ad-hoc topic creation from code

2014-02-25 Thread David Morales de Frías
This is the code that i can see in CreateTopicCommand var zkClient: ZkClient = null try { zkClient = new ZkClient(zkConnect, 3, 3, ZKStringSerializer) createTopic(zkClient, topic, nPartitions, replicationFactor, replicaAssignmentStr) println("creation succeeded!")

Re: calling ad-hoc topic creation from code

2014-02-25 Thread Jun Rao
Is the ZK connection string + namespace the same btw the code and the script? Thanks, Jun On Tue, Feb 25, 2014 at 3:01 AM, David Morales de Frías < dmora...@paradigmatecnologico.com> wrote: > Hi there, > > I'm trying to create a topic from java code, by calling CreateTopicCommand: > > > *ZkCli

calling ad-hoc topic creation from code

2014-02-25 Thread David Morales de Frías
Hi there, I'm trying to create a topic from java code, by calling CreateTopicCommand: *ZkClient zkClient = new ZkClient(zookeeperCluster, 3, 3);* *CreateTopicCommand.createTopic(zkClient, topic, numPartitions.intValue(),replicationFactor.intValue(), "");* *zkClient.close();* The prog