我试图在我的项目中重新分配分区,我得到了这个错误。
2017-08-22 15:57:28 DEBUG ZookeeperBackedAdoptionLogicImpl:320 - Calling ReassignPartitionsCommand with args:[--reassignment-json-file=partitions-to-move.json.1503417447767, --zookeeper=172.31.14.207:2181, --execute]
java.lang.IllegalArgumentException: long is not a value type
at joptsimple.internal.Reflection.findConverter(Reflection.java:66)
at joptsimple.ArgumentAcceptingOptionSpec.ofType(ArgumentAcceptingOptionSpec.java:111)
at kafka.admin.ReassignPartitionsCommand$ReassignPartitionsCommandOptions.<init>(ReassignPartitionsCommand.scala:301)
at kafka.admin.ReassignPartitionsCommand$.validateAndParseArgs(ReassignPartitionsCommand.scala:236)
at kafka.admin.ReassignPartitionsCommand$.main(ReassignPartitionsCommand.scala:34)
at kafka.admin.ReassignPartitionsCommand.main(ReassignPartitionsCommand.scala)
at rebalancer.core.ZookeeperBackedAdoptionLogicImpl.reassignPartitionToLocalBroker(ZookeeperBackedAdoptionLogicImpl.java:321)
at rebalancer.core.ZookeeperBackedAdoptionLogicImpl.adoptRemotePartition(ZookeeperBackedAdoptionLogicImpl.java:267)
at rebalancer.core.ZookeeperBackedAdoptionLogicImpl.run(ZookeeperBackedAdoptionLogicImpl.java:118)
我创建json文件并将其用作重新分配分区的输入。我试图使用同一个文件与Kafka的内置脚本,它是工作。
kafka-reassign-partitions.bat --reassignment-json-file=partitions-to-move.json.1503417447767 --zookeeper=172.31.14.207:2181 --execute
我还试着用同样的代码编写一个简单的程序来测试同样的文件,它也可以正常工作。任何json文件都会发生这种情况,我在测试之前重置了kafka环境。
public class reassignPartition {
private static CuratorFramework client;
public static void main (String[] args) {
client = CuratorFrameworkFactory.newClient(args[0] + ":2181", new ExponentialBackoffRetry(1000, 30));
client.start();
String reassignmentConfigFileName = args[1];
String[] reassignCmdArgs = { "--reassignment-json-file=" + Paths.get(reassignmentConfigFileName),
"--zookeeper=" + client.getZookeeperClient().getCurrentConnectionString(), "--execute" };
System.out.println("Calling ReassignPartitionsCommand with args:{}"+ Arrays.toString(reassignCmdArgs));
ReassignPartitionsCommand.main(reassignCmdArgs);
}
}
有什么问题吗?
更新:json内容 {"partitions":[{"topic":"test1","partition":0,"replicas":[1]}],"version":1}
1条答案
按热度按时间dm7nw8vv1#
是版本不匹配。。使用不同版本的陷阱之一。Kafka0.10.2.0使用jopt-simple-4.9.jar,Kafka0.11.0.0使用jopt-simple-5.0.4.jar