Skip to content

Commit

Permalink
#205 #206 refactor backend
Browse files Browse the repository at this point in the history
Signed-off-by: Niklas Teschner <[email protected]>
  • Loading branch information
nikkite99 committed Jul 14, 2023
1 parent 76f59db commit ed9793a
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public ResponseEntity<Void> flush() {
.forEach(cache -> Objects.requireNonNull(cacheManager.getCache(cache)).clear());
return new ResponseEntity<>(HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ public ResponseEntity<ClusterDetailDto> getClusterDetails(@RequestParam String c
public ResponseEntity<ClustersDto> getAll() {
return new ResponseEntity<>(new ClustersDto(clusterService.getAllNames()), HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public ResponseEntity<MessagesDto> getMessages(@RequestParam String topic,
Set<MessageDto> messageDtos = messageService.getLatestMessagesFiltered(topic, numMessages, producers, subscriptions);
return new ResponseEntity<>(new MessagesDto(messageDtos), HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ private ResponseEntity<NamespacesDto> wrapInEntity(List<NamespaceDto> namespaceD
return new ResponseEntity<>(new NamespacesDto(namespaceDtos), HttpStatus.OK);
}

private List<NamespaceDto> getAllForNamespaces(List<String> namespaces) {
return namespaceService.getAllForNamespaces(namespaces);
}

private List<NamespaceDto> getAllForTenants(List<String> tenants) {
if (tenants.isEmpty()) {
tenants = tenantService.getAllNames();
}
return namespaceService.getAllForTenants(tenants);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public static ConsumerDto create(TopicStats topicStats, String consumer) {


private static ConsumerStats getConsumerStatsByTopic(TopicStats topicStats, String consumer) {
return topicStats.getSubscriptions()
.values().stream()
return topicStats.getSubscriptions().values().stream()
.flatMap(subscriptionStats -> subscriptionStats.getConsumers().stream())
.filter(c -> c.getConsumerName().equals(consumer))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public void setTopics(List<String> topics) {
this.topics = topics;
}

/**
* @return An unmodifiable copy of the topics of this namespace.
*/
public List<String> getTopics() {
return List.copyOf(topics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
public class NamespaceDto {

private String id;

private String tenant;

private long numberOfTopics;

public static NamespaceDto fromString(String namespaceId) {
Expand All @@ -26,4 +24,5 @@ public static NamespaceDto fromString(String namespaceId) {
namespaceDto.setTenant(NamespaceName.get(namespaceId).getTenant());
return namespaceDto;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ private static PublisherStats getPublisherStats(TopicStats topicStats, String pr
.filter(ps -> Objects.equals(ps.getProducerName(), producer))
.findFirst()
.orElseThrow(() -> new RuntimeException("No PublisherStats found for " + producer));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ private static List<String> getConsumers(SubscriptionStats subscriptionStats) {
.stream()
.map(ConsumerStats::getConsumerName)
.toList();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public class TenantDetailDto {
private String name;
private List<String> namespaces;
private TenantInfo tenantInfo;
/**
* @return An unmodifiable copy of the namespaces of this tenant.
*/

public List<String> getNamespaces() {
return List.copyOf(namespaces);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ public static TenantDto create(TenantInfo tenantInfo, String name) {
.tenantInfo(tenantInfo)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static TopicDetailDto create(
.toList();
topicDetailDto.setSchemaInfos(schemaInfosSorted);
}

return topicDetailDto;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public static TopicStatsDto createTopicStatsDto(TopicStats topicStats) {
.averageMessageSize(topicStats.getAverageMsgSize())
.storageSize(topicStats.getStorageSize())
.build();

}

private static List<String> getProducers(TopicStats topicStats) {
Expand All @@ -53,9 +52,4 @@ private static List<String> getProducers(TopicStats topicStats) {
.toList();
}






}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ private List<String> getTenantsAllowedForCluster(String clusterName) throws Puls

private ClusterDto enrichWithCardDetails(ClusterDto clusterDto) {
List<String> tenants = getTenantsAllowedForCluster(clusterDto.getName());
long numberOfNamespaces = tenants.stream().mapToLong(t -> namespaceService.getAllOfTenant(t).size()).sum();
long numberOfNamespaces = tenants.stream()
.mapToLong(t -> namespaceService.getAllOfTenant(t).size())
.sum();
clusterDto.setNumberOfTenants(tenants.size());
clusterDto.setNumberOfNamespaces(numberOfNamespaces);
return clusterDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ private TenantInfo getTenantInfo(String tenantName) {
private TenantDto enrichWithCardDetails(TenantDto tenantDto) {
try {
List<String> namespaces = pulsarAdmin.namespaces().getNamespaces(tenantDto.getName());
long numberOfTopics = namespaces.stream().mapToLong(n -> topicService.getAllForNamespace(n).size()).sum();
long numberOfTopics = namespaces.stream()
.mapToLong(n -> topicService.getAllForNamespace(n).size())
.sum();
tenantDto.setNumberOfTopics(numberOfTopics);
tenantDto.setNumberOfNamespaces(namespaces.size());
return tenantDto;
Expand Down

0 comments on commit ed9793a

Please sign in to comment.