public static SubscriptionName fromString(String string) { String[] tokens = string.split("\\$"); checkArgument(tokens.length > 1, "Incorrect string format. Expected 'topic$subscription'. Found:'%s'", string); return new SubscriptionName(tokens[1], TopicName.fromQualifiedName(tokens[0])); }
@Override public List<SchemaVersion> getVersions(TopicName topic) { Response response = target.path("subjects") .path(topic.qualifiedName()) .path("versions") .request() .get(); return extractSchemaVersions(topic.qualifiedName(), response); }
private static TopicName escapedTopicName(String qualifiedTopicName) { TopicName topicName = fromQualifiedName(qualifiedTopicName); return new TopicName( escapeMetricsReplacementChar(topicName.getGroupName()), topicName.getName() ); }
public UnavailableRateException(TopicName topicName, String subscriptionName, Throwable cause) { super(String.format( "Rate for %s subscription on %s topic in group %s is unavailable.", subscriptionName, topicName.getName(), topicName.getGroupName()), cause ); }
public List<String> listQualifiedTopicNames(String groupName) { return topicRepository.listTopicNames(groupName).stream() .map(topicName -> new TopicName(groupName, topicName).qualifiedName()) .collect(toList()); }
@Test public void shouldConvertQualifiedName() { // given TopicName topicName = new TopicName("group1", "topic1"); // when & then assertThat(TopicName.fromQualifiedName(topicName.qualifiedName())).isEqualTo(topicName); }
public static TopicBuilder topic(String groupName, String topicName) { return new TopicBuilder(new TopicName(groupName, topicName)); }
@Test public void shouldHandleDottedGroupName() { // given TopicName topicName = TopicName.fromQualifiedName("group.topic"); // when & then assertThat(topicName.getGroupName()).isEqualTo("group"); assertThat(topicName.getName()).isEqualTo("topic"); }
public List<String> findTopics(Topic topic, boolean tracking) { return topicEndpoint.list(topic.getName().getGroupName(), tracking); }
@Override public List<Subscription> subscriptionsOfTopic(TopicName topicName) { return subscriptions.values().stream() .filter(s -> s.getTopicName().equals(topicName)) .collect(Collectors.toList()); }
public UnavailableRateException(TopicName topicName, Throwable cause) { super(String.format( "Rate for %s topic in group %s is unavailable", topicName.getName(), topicName.getGroupName()), cause ); }
public static TopicBuilder topic(String groupName, String topicName) { return new TopicBuilder(new TopicName(groupName, topicName)); }
public List<String> findTopics(Topic topic, boolean tracking) { return topicEndpoint.list(topic.getName().getGroupName(), tracking); }
@Override public List<Subscription> subscriptionsOfTopic(TopicName topicName) { return subscriptions.values().stream() .filter(s -> s.getTopicName().equals(topicName)) .collect(Collectors.toList()); }
@Override public Optional<RawSchema> getLatestSchema(TopicName topic) { final String version = "latest"; Response response = target.path("subjects") .path(topic.qualifiedName()) .path("versions") .path(version) .request() .get(); return extractSchema(topic.qualifiedName(), version, response).map(RawSchema::valueOf); }
@GET @Path("/{topic}/offline-clients") @Produces(APPLICATION_JSON) public Response find(@PathParam("topic") String topic) { return offlineClientsService .map(service -> Response.ok(service.find(TopicName.fromQualifiedName(topic))).build()) .orElseThrow(OfflineClientsServiceAbsentException::new); }
public String subscriptionMetricPathWithoutBasePath(TopicName topicName, String subscriptionName, String metricName) { return Joiner.on(URL_SEPARATOR).join( "", GROUPS_PATH, topicName.getGroupName(), TOPICS_PATH, topicName.getName(), SUBSCRIPTIONS_PATH, subscriptionName, METRICS_PATH, metricName); }
public static TopicName fromQualifiedName(String qualifiedName) { if (Strings.isNullOrEmpty(qualifiedName)) { return null; } int index = qualifiedName.lastIndexOf(GROUP_SEPARATOR); if (index == -1) { throw new IllegalArgumentException("Missing group"); } String groupName = qualifiedName.substring(0, index); String topicName = qualifiedName.substring(index + 1, qualifiedName.length()); return new TopicName(groupName, topicName); }
public TopicWithSchema buildTopicWithSchema(TopicWithSchema topic) { createGroup(topic.getName().getGroupName()); return createTopic(topic); }
@Override public List<SchemaVersion> getVersions(TopicName topic) { Response response = target.path("subjects") .path(topic.qualifiedName()) .path("versions") .request() .get(); return extractSchemaVersions(topic.qualifiedName(), response); }