private Set<Integer> aliveBrokers() { // We get the alive brokers from ZK directly. return JavaConversions.asJavaCollection(_zkUtils.getAllBrokersInCluster()) .stream().map(Broker::id).collect(toSet()); }
@Override public boolean canBeUsed(Object obj, boolean expand) { if (!expand) return false; if (!(obj instanceof scala.collection.immutable.Seq<?>)) return false; Collection<?> col = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj); if (col.isEmpty()) return false; for (Object o : col) { if (!(o instanceof scala.collection.immutable.Seq)) return false; Collection<?> col2 = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) o); for (Object o2 : col2) { if (!parent.isPrimitiveType(o2.getClass().getName())) return false; } } return true; }
@Override public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException { logger.debug("collection"); // convert this 'on the fly' to an array of objects Collection<?> c = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj); jgen.writeStartArray(); for (Object o : c) { if (!parent.writeObject(o, jgen, false)) jgen.writeObject(o.toString()); } jgen.writeEndArray(); return true; } }
logger.debug("collection of collections"); Collection<?> m = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj); int max = 0; Collection<?> e = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) entry); if (max < e.size()) max = e.size(); List<List<?>> values = new ArrayList<List<?>>(); for (Object entry : m) { Collection<?> e = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) entry); List<Object> l2 = new ArrayList<Object>(e); if (l2.size() < max) {
@Override public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException { logger.debug("list of maps"); // convert this 'on the fly' to a datatable Collection<?> col = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj); List<Map<String, Object>> tab = new ArrayList<Map<String, Object>>(); for (Object o : col) { Map<String, Object> row = scala.collection.JavaConversions.mapAsJavaMap((scala.collection.Map<String, Object>) o); tab.add(row); } TableDisplay t = new TableDisplay(tab, parent); jgen.writeObject(t); return true; } }
@Override public boolean canBeUsed(Object obj, boolean expand) { if (!expand) return false; if (!(obj instanceof scala.collection.immutable.Seq<?>)) return false; Collection<?> col = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj); if (col.isEmpty()) return false; for (Object o : col) { if (!(o instanceof scala.collection.Map<?, ?>)) return false; Map<?, ?> m = scala.collection.JavaConversions.mapAsJavaMap((scala.collection.Map<?, ?>) o); Set<?> keys = m.keySet(); for (Object key : keys) { if (key != null && !parent.isPrimitiveType(key.getClass().getName())) return false; Object val = m.get(key); if (val != null && !parent.isPrimitiveType(val.getClass().getName())) return false; } } return true; }
private static void rddToString(RDD rdd, StringBuilder sb, String offset) { sb.append(offset).append(rdd.getClass().getCanonicalName()).append("[").append(rdd.hashCode()).append("]"); if (rdd.getStorageLevel().useMemory()) { sb.append("(cached)"); } sb.append("\n"); Collection<Dependency> dependencies = JavaConversions.asJavaCollection(rdd.dependencies()); if (dependencies != null) { offset += "\t"; for (Dependency dependency : dependencies) { RDD parentRdd = dependency.rdd(); rddToString(parentRdd, sb, offset); } } else if (rdd instanceof UnionRDD) { UnionRDD unionRDD = (UnionRDD) rdd; offset += "\t"; Collection<RDD> parentRdds = JavaConversions.asJavaCollection(unionRDD.rdds()); for (RDD parentRdd : parentRdds) { rddToString(parentRdd, sb, offset); } } }
/** * Check whether the topic has partitions undergoing partition reassignment and wait for the reassignments to finish. * * @param zkUtils the ZkUtils class used to check ongoing partition reassignments. * @return Whether there are no ongoing partition reassignments. */ public static boolean ensureTopicNotUnderPartitionReassignment(ZkUtils zkUtils, String topic) { int attempt = 0; while (JavaConversions.asJavaCollection(zkUtils.getPartitionsBeingReassigned().keys()).stream() .anyMatch(tp -> tp.topic().equals(topic))) { try { sleep(1000 << attempt); } catch (InterruptedException e) { // Let it go. } if (++attempt == 10) { return false; } } return true; }
Collection<Broker> brokers = scala.collection.JavaConversions.asJavaCollection(zkClient.getAllBrokersInCluster());
@Override public void write(final Kryo kryo, final Output output, final WrappedArray<T> iterable) { output.writeVarInt(iterable.size(), true); JavaConversions.asJavaCollection(iterable).forEach(t -> { kryo.writeClassAndObject(output, t); }); }
@Override public Collection<String> getNotation(String module) { return JavaConversions.asJavaCollection(editing.getSymbolCompletion(module)); }
public EventHubConfig(Config config) { super(config); // Build reverse index for streamName -> streamId StreamConfig streamConfig = new StreamConfig(config); LOG.info("Building mappings from physicalName to streamId"); JavaConversions.asJavaCollection(streamConfig.getStreamIds()) .forEach((streamId) -> { String physicalName = streamConfig.getPhysicalName(streamId); LOG.info("Obtained physicalName: {} for streamId: {} ", physicalName, streamId); physcialToId.put(physicalName, streamId); }); }
static List<String> brokersToEndpoints(List<Broker> brokers) { List<String> endpoints = new LinkedList<String>(); for (Broker broker : brokers) { for (EndPoint ep : JavaConversions.asJavaCollection(broker.endPoints().values())) { endpoints.add(ep.connectionString()); } } return endpoints; }
@Override public void write(final Kryo kryo, final Output output, final WrappedArray<T> iterable) { output.writeVarInt(iterable.size(), true); JavaConversions.asJavaCollection(iterable).forEach(t -> { kryo.writeClassAndObject(output, t); }); }
@Override public List<String> getMMTConstants() { List<String> result = new ArrayList<String>(); info.kwarc.mmt.api.ontology.IsConstant$ t = info.kwarc.mmt.api.ontology.IsConstant$.MODULE$; for (Path p : JavaConversions.asJavaCollection(controller.depstore().getInds(t).toList())) { result.add(p.toPath()); } return result; }
public List<String> getDefinition(String SymbolURI) { Path p = Path.parse(SymbolURI); info.kwarc.mmt.api.ontology.isDefinedBy$ isdefBy = info.kwarc.mmt.api.ontology.isDefinedBy$.MODULE$; List<String> result = new ArrayList<String>(); for (FragPath fragPath : JavaConversions.asJavaCollection(controller.depstore().getObjects(p, isdefBy))) { result.add(fragPath.toPath()); }; return result; }
@Override public List<String> getMMTTheories() { List<String> result = new ArrayList<String>(); info.kwarc.mmt.api.ontology.IsTheory$ t = info.kwarc.mmt.api.ontology.IsTheory$.MODULE$; for (Path p : JavaConversions.asJavaCollection(controller.depstore().getInds(t).toList())) { result.add(p.toPath()); } return result; }
public void getDeclaredTheories(String MMTUri) { Declares$ declares = Declares$.MODULE$; Path startURI = Path.parse(MMTUri); for (Path p : JavaConversions.asJavaCollection(controller.depstore().queryList(startURI, new ToObject(declares)))) { System.out.println(p); } }
@Override public Collection<String> getAutocomplete(String module, String prefix) { MMTAutoCompleteRequest req = new MMTAutoCompleteRequest(prefix, "http://mathhub.info/"+module); MMTAutoCompleteResponse resp = editing.getAutocompleteResponse(req); return JavaConversions.asJavaCollection(resp.getResponse()); }
public void getDependents(String MMTUri) { ToSubject dependsOn = new ToSubject(DependsOn$.MODULE$); ToSubject hasMeta = new ToSubject(HasMeta$.MODULE$); ToSubject includes = new ToSubject(Includes$.MODULE$); RelationExp reflexive = Reflexive$.MODULE$; List<RelationExp> rels = Arrays.asList(new RelationExp[]{dependsOn, hasMeta, includes, reflexive}); Transitive transitive = new Transitive(new Choice(JavaConversions.asScalaBuffer(rels))); Path startURI = Path.parse(MMTUri); for (Path p : JavaConversions.asJavaCollection(controller.depstore().queryList(startURI, transitive))) { System.out.println(p); } }