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); }
@Benchmark public scala.collection.immutable.Map<String, String> immutableScalaPut() { int localSize = this.size; String[] localElements = this.elements; scala.collection.immutable.Map<String, String> map = HashMap$.MODULE$.empty(); for (int i = 0; i < localSize; i++) { map = map.updated(localElements[i], "dummy"); } return map; } }
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; }
/** * Directory loggedStoreDir associated with the logged store storeName is determined to be valid * if all of the following conditions are true. * a) If the store has to be persisted to disk. * b) If there is a valid offset file associated with the logged store. * c) If the logged store has not gone stale. * * @return true if the logged store is valid, false otherwise. */ private boolean isLoggedStoreValid(String storeName, File loggedStoreDir) { long changeLogDeleteRetentionInMs = StorageConfig.DEFAULT_CHANGELOG_DELETE_RETENTION_MS(); if (new StorageConfig(config).getChangeLogDeleteRetentionsInMs().get(storeName).isDefined()) { changeLogDeleteRetentionInMs = (long) new StorageConfig(config).getChangeLogDeleteRetentionsInMs().get(storeName).get(); } return this.taskStores.get(storeName).getStoreProperties().isPersistedToDisk() && StorageManagerUtil.isOffsetFileValid(loggedStoreDir, OFFSET_FILE_NAME) && !StorageManagerUtil.isStaleStore( loggedStoreDir, OFFSET_FILE_NAME, changeLogDeleteRetentionInMs, clock.currentTimeMillis()); }
/** * We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java. * * @param requestHeader the request without the body * @param body the body (maybe) * @param sessionStore the session store */ public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) { this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore); this.formParameters = new HashMap<>(); if (body instanceof AnyContentAsFormUrlEncoded) { final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get(); for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) { final Seq<String> v = parameters.get(key).get(); final String[] values = new String[v.size()]; v.copyToArray(values); formParameters.put(key, values); } } }
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; }
private long getTopicLogSize(String topic, int pid) { Option<Object> o = ZkUtils.getLeaderForPartition(zkClient, topic, pid); if (o.isEmpty() || o.get() == null) { log.error("No broker for partition %s - %s", topic, pid); return 0; } Integer leaderId = Int.unbox(o.get()); SimpleConsumer consumer = consumerMap.get(leaderId); if (consumer == null) { consumer = createSimpleConsumer(leaderId); } // createSimpleConsumer may fail. if (consumer == null) { return 0; } consumerMap.put(leaderId, consumer); TopicAndPartition topicAndPartition = new TopicAndPartition(topic, pid); PartitionOffsetRequestInfo requestInfo = new PartitionOffsetRequestInfo(OffsetRequest.LatestTime(), 1); OffsetRequest request = new OffsetRequest( new Map1<TopicAndPartition, PartitionOffsetRequestInfo>(topicAndPartition, requestInfo), 0, Request.OrdinaryConsumerId() ); OffsetResponse response = consumer.getOffsetsBefore(request); PartitionOffsetsResponse offsetsResponse = response.partitionErrorAndOffsets().get(topicAndPartition).get(); return scala.Long.unbox(offsetsResponse.offsets().head()); }
private PathBindable<?> pathBindableFor(Class<?> clazz) { PathBindable<?> builtIn = Scala.orNull(PathBindable$.MODULE$.pathBindableRegister().get(clazz)); if (builtIn != null) { return builtIn; } else if (play.mvc.PathBindable.class.isAssignableFrom(clazz)) { return PathBindable$.MODULE$.javaPathBindable((ClassTag) ClassTag$.MODULE$.apply(clazz)); } else if (clazz.equals(Object.class)) { // Special case for object, treat as a string return PathBindable.bindableString$.MODULE$; } else { throw new IllegalArgumentException("Don't know how to bind argument of type " + clazz); } }
public static scala.collection.immutable.Map<String, String> convertMapToScala(Map<String, String> map) { return emptyMap.$plus$plus(scala.collection.JavaConverters.mapAsScalaMapConverter(map).asScala()); } @SuppressWarnings("unchecked") // contains an upcast
private Map<String, String> buildSslConfig(JsonObject config) { Map<String, String> sslConfig = Map$.MODULE$.empty(); if (config.getString("sslMode")!= null) { sslConfig = sslConfig.$plus(Tuple2.apply("sslmode", config.getString("sslMode"))); } if (config.getString("sslRootCert") != null) { sslConfig = sslConfig.$plus(Tuple2.apply("sslrootcert", config.getString("sslRootCert"))); } return sslConfig; }
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); }
/** * 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); } }
v.setName(vs.name()); v.setIsTimeStampUnique(vs.processing().uniqueTimestamp()); if (vs.poolSize().isDefined()) v.setLifeCyclePoolSize(((Integer)vs.poolSize().get())); if (vs.processing().rate().isDefined()) v.setOutputStreamRate(((Integer)vs.processing().rate().get())); v.setPriority(vs.priority()); KeyValueImp [] addr=new KeyValueImp[vs.address().size()]; Iterable<String> keys=JavaConversions.asJavaIterable(vs.address().keys()); int i=0; for (String k:keys){ addr[i]=new KeyValueImp(k,vs.address().apply(k)); i++;
/** * We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java. * * @param requestHeader the request without the body * @param body the body (maybe) * @param sessionStore the session store */ public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) { this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore); this.formParameters = new HashMap<>(); if (body instanceof AnyContentAsFormUrlEncoded) { final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get(); for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) { final Seq<String> v = parameters.get(key).get(); final String[] values = new String[v.size()]; v.copyToArray(values); formParameters.put(key, values); } } }
private PathBindable<?> pathBindableFor(Class<?> clazz) { PathBindable<?> builtIn = Scala.orNull(PathBindable$.MODULE$.pathBindableRegister().get(clazz)); if (builtIn != null) { return builtIn; } else if (play.mvc.PathBindable.class.isAssignableFrom(clazz)) { return PathBindable$.MODULE$.javaPathBindable((ClassTag) ClassTag$.MODULE$.apply(clazz)); } else if (clazz.equals(Object.class)) { // Special case for object, treat as a string return PathBindable.bindableString$.MODULE$; } else { throw new IllegalArgumentException("Don't know how to bind argument of type " + clazz); } }