@@ -0,0 +1,2873 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.smartloli.kafka.eagle.admin;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Map.Entry;%0A%0Aimport org.apache.kafka.common.TopicPartition;%0Aimport org.smartloli.kafka.eagle.common.util.KafkaZKPoolUtils;%0A%0Aimport com.alibaba.fastjson.JSONArray;%0Aimport com.alibaba.fastjson.JSONObject;%0A%0Aimport kafka.admin.ReassignPartitionsCommand;%0Aimport scala.Tuple2;%0Aimport scala.collection.JavaConversions;%0Aimport scala.collection.JavaConverters;%0Aimport scala.collection.Map;%0Aimport scala.collection.Seq;%0A%0A/**%0A * TODO%0A * %0A * @author smartloli.%0A *%0A *         Created by May 18, 2020%0A */%0Apublic class TestKafkaAdminServer %7B%0A%09private static KafkaZKPoolUtils kafkaZKPool = KafkaZKPoolUtils.getInstance();%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09JSONObject topics = new JSONObject();%0A%09%09JSONArray values = new JSONArray();%0A%09%09JSONObject topic01 = new JSONObject();%0A%09%09topic01.put(%22topic%22, %22k20200326%22);%0A%09%09values.add(topic01);%0A%09%09topics.put(%22topics%22, values);%0A%09%09topics.put(%22version%22, 1);%0A%09%09List%3CObject%3E ids = new ArrayList%3CObject%3E();%0A%09%09ids.add(0);%0A%09%09Seq%3CObject%3E seq = JavaConverters.asScalaIteratorConverter(ids.iterator()).asScala().toSeq();%0A%09%09Tuple2%3CMap%3CTopicPartition, Seq%3CObject%3E%3E, Map%3CTopicPartition, Seq%3CObject%3E%3E%3E tuple = ReassignPartitionsCommand.generateAssignment(kafkaZKPool.getZkClient(%22cluster1%22), seq, topics.toJSONString(), true);%0A%09%09System.out.println(%22Proposed partition reassignment configuartion%22);%0A%09%09for (Entry%3CTopicPartition, Seq%3CObject%3E%3E entry : JavaConversions.mapAsJavaMap(tuple._1).entrySet()) %7B%0A%09%09%09List%3CObject%3E object = JavaConversions.seqAsJavaList(entry.getValue());%0A%09%09%09System.out.println(entry.getKey().topic() + %22,%22 + entry.getKey().partition() + %22,%22 + object.toString());%0A%09%09%7D%0A%09%09System.out.println(%22Current partition replica assignment%22);%0A%09%09for (Entry%3CTopicPartition, Seq%3CObject%3E%3E entry : JavaConversions.mapAsJavaMap(tuple._2).entrySet()) %7B%0A%09%09%09List%3CObject%3E object = JavaConversions.seqAsJavaList(entry.getValue());%0A%09%09%09System.out.println(entry.getKey().topic() + %22,%22 + entry.getKey().partition() + %22,%22 + object.toString());%0A%09%09%7D%0A%09%7D%0A%7D%0A

add reassignment