private static scala.collection.Map<Object, scala.collection.Seq<Object>> getPartitionAssignment(KafkaZkClient zkClient, String topic) { scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic); return zkClient.getPartitionAssignmentForTopics(topicList).apply(topic); }
private static void reassignPartitions(KafkaZkClient zkClient, Collection<Broker> brokers, String topic, int partitionCount, int replicationFactor) { scala.collection.mutable.ArrayBuffer<BrokerMetadata> brokersMetadata = new scala.collection.mutable.ArrayBuffer<>(brokers.size()); for (Broker broker : brokers) { brokersMetadata.$plus$eq(new BrokerMetadata(broker.id(), broker.rack())); } scala.collection.Map<Object, Seq<Object>> assignedReplicas = AdminUtils.assignReplicasToBrokers(brokersMetadata, partitionCount, replicationFactor, 0, 0); scala.collection.immutable.Map<TopicPartition, Seq<Object>> newAssignment = new scala.collection.immutable.HashMap<>(); scala.collection.Iterator<scala.Tuple2<Object, scala.collection.Seq<Object>>> it = assignedReplicas.iterator(); while (it.hasNext()) { scala.Tuple2<Object, scala.collection.Seq<Object>> scalaTuple = it.next(); TopicPartition tp = new TopicPartition(topic, (Integer) scalaTuple._1); newAssignment = newAssignment.$plus(new scala.Tuple2<>(tp, scalaTuple._2)); } scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic); scala.collection.Map<Object, scala.collection.Seq<Object>> currentAssignment = zkClient.getPartitionAssignmentForTopics(topicList).apply(topic); String currentAssignmentJson = formatAsReassignmentJson(topic, currentAssignment); String newAssignmentJson = formatAsReassignmentJson(topic, assignedReplicas); LOG.info("Reassign partitions for topic " + topic); LOG.info("Current partition replica assignment " + currentAssignmentJson); LOG.info("New partition replica assignment " + newAssignmentJson); zkClient.createPartitionReassignment(newAssignment); }
private static List<PartitionInfo> getPartitionInfo(KafkaZkClient zkClient, String topic) { scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic); scala.collection.Map<Object, scala.collection.Seq<Object>> partitionAssignments = zkClient.getPartitionAssignmentForTopics(topicList).apply(topic); List<PartitionInfo> partitionInfoList = new ArrayList<>(); scala.collection.Iterator<scala.Tuple2<Object, scala.collection.Seq<Object>>> it = partitionAssignments.iterator(); while (it.hasNext()) { scala.Tuple2<Object, scala.collection.Seq<Object>> scalaTuple = it.next(); Integer partition = (Integer) scalaTuple._1(); scala.Option<Object> leaderOption = zkClient.getLeaderForPartition(new TopicPartition(topic, partition)); Node leader = leaderOption.isEmpty() ? null : new Node((Integer) leaderOption.get(), "", -1); Node[] replicas = new Node[scalaTuple._2().size()]; for (int i = 0; i < replicas.length; i++) { Integer brokerId = (Integer) scalaTuple._2().apply(i); replicas[i] = new Node(brokerId, "", -1); } partitionInfoList.add(new PartitionInfo(topic, partition, leader, replicas, null)); } return partitionInfoList; }
/** * Get schema for structure. Schemas are immutable, so if the schema has previously been loaded and cached it's * returned immediately. Otherwise it's loaded from the classpath, and added to the cache before being returned. * * @param type * @param version * @param ident * @return structure */ protected Structure getSchema(String type, String version, String ident) { String path = File.separator + type.toLowerCase() + File.separator + version.toLowerCase() + File.separator + ident + ".esl"; Structure structure = loadedSchemas.get(path); if (structure == null) { try { YamlReader yamlrdr = new YamlReader(); InputStream is = yamlrdr.findSchema(path, new String[] { "" }); EdiSchema schema = yamlrdr.loadYaml(new InputStreamReader(is), new String[0]); structure = (Structure)schema.structures().apply(ident); loadedSchemas.put(path, structure); return structure; } catch (Exception e) { throw new RuntimeException("Could not load schema " + ident + " from path " + path, e); } } return structure; }
/** * Build metadata for structures list. * * @param root * @param structKey key for map of structure lists in root * @param read input version of structure data */ public void buildStructures(DynamicObjectBuilder<?> root, String structKey, boolean read) { DynamicObjectBuilder<?> structuresMap = root.addDynamicObjectField(structKey); Iterator<String> keys = schema.structures().keysIterator(); while (!keys.isEmpty()) { Structure structure = (Structure)schema.structures().apply(keys.next()); DynamicObjectBuilder<?> tranMap = structuresMap.addList(structure.ident()). ofDynamicObject(structure.ident()); buildStructure(structure, read, tranMap); } }
public static AddressBean address(WrapperConf w){ KeyValueImp [] p=new KeyValueImp[w.params().size()]; Iterable<String> keys=JavaConversions.asJavaIterable(w.params().keys()); int i=0; for (String k:keys){ p[i]=new KeyValueImp(k,w.params().apply(k)); i++; } AddressBean a = new AddressBean(w.wrapper(),p); if(w.partialKey().isDefined()){ a.setPartialOrderKey(w.partialKey().get()); } DataField [] out=new DataField[(w.output().size())]; for (int j=0;j<out.length;j++){ out[j]=dataField(w.output().apply(j)); } a.setVsconfig(out); return a; }
int i=0; for (String k:keys){ addr[i]=new KeyValueImp(k,vs.address().apply(k)); i++;