本文整理了Java中scala.collection.immutable.Map.apply()
方法的一些代码示例,展示了Map.apply()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Map.apply()
方法的具体详情如下:
包路径:scala.collection.immutable.Map
类名称:Map
方法名:apply
暂无
代码示例来源:origin: linkedin/kafka-monitor
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);
}
代码示例来源:origin: linkedin/kafka-monitor
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);
}
代码示例来源:origin: linkedin/kafka-monitor
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;
}
代码示例来源:origin: org.mule.modules/edi-module-common
/**
* 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;
}
代码示例来源:origin: org.mule.modules/edi-module-common
/**
* 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);
}
}
代码示例来源:origin: ch.epfl.gsn/gsn-core
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;
}
代码示例来源:origin: ch.epfl.gsn/gsn-core
int i=0;
for (String k:keys){
addr[i]=new KeyValueImp(k,vs.address().apply(k));
i++;
内容来源于网络,如有侵权,请联系作者删除!