@GET @Path("/get") @Produces({MediaType.APPLICATION_JSON}) public Response test(@QueryParam("class") String className){ try{ if (className == null) throw new ClassNotFoundException(); List<ClassModel> list = new ArrayList<ClassModel>(); Iterator<Model> i = ModelConverters.readAll(Class.forName(className)).iterator(); while (i.hasNext()) list.add(new ClassModel(i.next())); return Response.ok(list).build(); } catch (ClassNotFoundException e) { return Response.status(400).entity("Could not find " + className).build(); } catch (Exception e){ return Response.status(500).entity("An error occurred: " + e.getMessage()).build(); } }
protected List<String> group() { List<String> groups = new ArrayList<>(); scala.collection.immutable.List<GroupOverview> list = adminClient.listAllConsumerGroupsFlattened(); if (list == null) return groups; Iterator<GroupOverview> iterator = list.iterator(); while (iterator.hasNext()) { groups.add(iterator.next().groupId()); } return groups; }
private List<Class<?>> filterClasses(final List<Class<?>> classes) { final Iterator<Class<?>> eachClass = classes.iterator(); final ArrayList<Class<?>> filteredClasses = new ArrayList<Class<?>>(); while(eachClass.hasNext()) { Class clazz = eachClass.next(); // if (clazz.getName().indexOf("fluxtream")!=-1) // continue; filteredClasses.add(clazz); } return JavaConversions.asScalaBuffer(filteredClasses).toList(); }
/** * Returns the consumer group assignments of partitions to client IDs or empty map if the group does not exist or is not active * * @param consumerGroup * the name of the consumer group * @return unmodifiable map of the consumer group assignments of partitions to client IDs or empty map if the group does not * exist or is not active * @throws IllegalArgumentException * if the consumerGroup is null, empty or blank * @throws AdminOperationException * if an issue occurs retrieving the assignments */ public Map<TopicPartition, String> getConsumerGroupAssignments(String consumerGroup) { if (StringUtils.isBlank(consumerGroup)) throw new IllegalArgumentException("consumerGroup cannot be null, empty or blank"); Map<TopicPartition, String> assignments = new HashMap<>(); Collection<AdminClient.ConsumerSummary> summaries = getConsumerGroupSummaries(consumerGroup); for (final AdminClient.ConsumerSummary consumerSummary : summaries) { Set<TopicPartition> topicPartitions = convertToJavaSet(consumerSummary.assignment().iterator()); for (final TopicPartition topicPartition : topicPartitions) { assignments.put(topicPartition, consumerSummary.clientId()); } } return Collections.unmodifiableMap(assignments); }
return Collections.unmodifiableCollection(convertToJavaSet(summary.consumers().get().iterator()));
public List<BrokerInfo> fetchAllBrokers(){ List<BrokerInfo> result = new ArrayList<>(); Seq<Broker> brokers = zkUtils.getAllBrokersInCluster(); Iterator<Broker> iterator = brokers.toList().iterator(); while(iterator.hasNext()){ Broker broker = iterator.next(); Node node = broker.getNode(ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)).get(); result.add(new BrokerInfo(node.idString(), node.host(), node.port())); } return result; }
public ClassModel(Model m){ id = m.id(); name = m.name(); qualifiedType = m.qualifiedType(); description = m.description().isEmpty() ? null : m.description().get(); baseModel = m.baseModel().isEmpty() ? null : m.baseModel().get(); discriminator = m.discriminator().isEmpty() ? null : m.discriminator().get(); properties = new HashMap<String,ClassModelProperty>(); LinkedHashMap<String,ModelProperty> propertiesMap = m.properties(); Iterator<Tuple2<String,ModelProperty>> i = propertiesMap.iterator(); while (i.hasNext()){ Tuple2<String,ModelProperty> t = i.next(); properties.put(t._1(),new ClassModelProperty(t._2())); } subTypes = new ArrayList<String>(); Iterator<String> stypes = m.subTypes().iterator(); while (stypes.hasNext()) subTypes.add(stypes.next()); }