public List<String> getTopics() { try { return JavaConversions.asJavaList(ZkUtils.getAllTopics(zkClient)); } catch (Exception e) { log.error(e, "could not get topics"); return Collections.emptyList(); } }
public List<BrokerInfo> getCluster() { return Lists.transform( JavaConversions.asJavaList(ZkUtils.getAllBrokersInCluster(zkClient)), new Function<Broker, BrokerInfo>() { @Override public BrokerInfo apply(Broker input) { BrokerInfo info = new BrokerInfo(); info.host = input.host(); info.port = input.port(); info.id = input.id(); return info; } } ); }
/** * @param tail * @return the planed producer */ public <T> List<T> plan(JTailProducer<Memory, T> tail) { return JavaConversions.asJavaList(platform.plan(tail.unwrap())); }
public List<PartitionInfo> getPartitionInfos(String group, String topic) { Seq<String> singleTopic = JavaConversions.asScalaBuffer(Collections.singletonList(topic)).toSeq(); scala.collection.Map<String, Seq<Object>> pidMap = ZkUtils.getPartitionsForTopics(zkClient, singleTopic); Option<Seq<Object>> partitions = pidMap.get(topic); if (partitions.get() == null) { return Collections.emptyList(); } List<PartitionInfo> infos = Lists.newArrayList(); for (Object o : JavaConversions.asJavaList(partitions.get())) { PartitionInfo info = getPartitionInfo(group, topic, Int.unbox(o)); if (info != null) { infos.add(info); } } return infos; }
consumers = JavaConversions.asJavaList(ZkUtils.getChildren(zkClient, ZkUtils.ConsumersPath())); } catch (Exception e) { log.error(e, "could not get all consumer list");
@Override public List<T> handle(final QueryResult res) { final Option<ResultSet> rowsOption = res.rows(); final List<T> response = new ArrayList<>(); if (rowsOption.isDefined()) { final ResultSet resultSet = rowsOption.get(); final List<String> columnNames = JavaConversions.asJavaList(resultSet.columnNames()); final Iterator<RowData> rows = resultSet.iterator(); while (rows.hasNext()) { final RowData row = rows.next(); final T obj = mapper.map(new TypedRowData(row), columnNames); response.add(obj); } } return response; } });
public static List<SocketAddress> getOnlineServers(String clusterName) { try { ZookeeperServerSetCluster cluster = getForService(clusterName); // Run the monitor() method, which will block the thread until the initial list of servers arrives. new ServerSetImpl(zooKeeperClient, getPath(clusterName)).monitor(new DynamicHostSet.HostChangeMonitor<ServiceInstance>(){ public void onChange(ImmutableSet<ServiceInstance> serviceInstances) { // do nothing } }); return JavaConversions.asJavaList(cluster.snap()._1()); } catch (DynamicHostSet.MonitorException e) { throw new RuntimeException("Couldn't get list of online servers", e); } }
@Override public T handle(final QueryResult res) { final Option<ResultSet> rowsOption = res.rows(); if (rowsOption.isDefined()) { final ResultSet resultSet = rowsOption.get(); final List<String> columnNames = JavaConversions.asJavaList(resultSet.columnNames()); final Iterator<RowData> rows = resultSet.iterator(); if (rows.hasNext()) { final RowData row = rows.next(); return mapper.map(new TypedRowData(row), columnNames); } } return null; } });