Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/IKC-391-cluster-form' into IKC-3…
Browse files Browse the repository at this point in the history
…92-delete-cluster
  • Loading branch information
Piotr Belke authored and Piotr Belke committed Jul 25, 2024
2 parents 350d37d + 1e7bbbf commit f41bdfe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.consdata.kouncil.config.ClusterConfig;
import com.consdata.kouncil.config.KouncilConfiguration;
import com.consdata.kouncil.model.cluster.Cluster;
import com.consdata.kouncil.schema.clusteraware.SchemaAwareClusterService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.admin.AdminClient;
Expand All @@ -22,6 +23,7 @@ public class ClusterService {
private final ClusterRepository clusterRepository;
private final KouncilConfiguration kouncilConfiguration;
private final KafkaConnectionService kafkaConnectionService;
private final SchemaAwareClusterService schemaAwareClusterService;

public ClusterDto getClusterByName(String clusterName) {
Cluster cluster = clusterRepository.findByName(clusterName);
Expand All @@ -31,6 +33,7 @@ public ClusterDto getClusterByName(String clusterName) {
public String saveCluster(ClusterDto cluster) {
Cluster save = clusterRepository.save(ClusterConverter.convertToCluster(cluster));
kouncilConfiguration.initializeClusters();
schemaAwareClusterService.reloadSchemaConfiguration(kouncilConfiguration);
return save.getName();
}

Expand All @@ -56,6 +59,7 @@ public boolean testConnection(ClusterDto clusterDto) {
} finally {
kafkaConnectionService.cleanAdminClients();
kouncilConfiguration.initializeClusters();
schemaAwareClusterService.reloadSchemaConfiguration(kouncilConfiguration);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@
@Service
public class SchemaAwareClusterService {

private final Map<String, SchemaAwareCluster> schemaAwareCluster = new ConcurrentHashMap<>();
private Map<String, SchemaAwareCluster> schemaAwareCluster = new ConcurrentHashMap<>();

public SchemaAwareClusterService(KouncilConfiguration kouncilConfiguration) {
reloadSchemaConfiguration(kouncilConfiguration);
}

public SchemaAwareCluster getClusterSchema(String serverId) {
return schemaAwareCluster.get(serverId);
}

public boolean clusterHasSchemaRegistry(String serverId) {
return schemaAwareCluster.containsKey(serverId);
}

public void reloadSchemaConfiguration(KouncilConfiguration kouncilConfiguration){
schemaAwareCluster = new ConcurrentHashMap<>();
kouncilConfiguration.getClusterConfig().forEach((clusterKey, clusterValue) -> {
try {
SchemaRegistryClient schemaRegistryClient = clusterValue.getSchemaRegistry() != null
Expand All @@ -38,14 +51,6 @@ public SchemaAwareClusterService(KouncilConfiguration kouncilConfiguration) {
});
}

public SchemaAwareCluster getClusterSchema(String serverId) {
return schemaAwareCluster.get(serverId);
}

public boolean clusterHasSchemaRegistry(String serverId) {
return schemaAwareCluster.containsKey(serverId);
}

private SchemaAwareCluster initializeSchemaAwareCluster(SchemaRegistryFacade schemaRegistryFacade) {
EnumMap<MessageFormat, MessageFormatter> formatters = new EnumMap<>(MessageFormat.class);
formatters.put(MessageFormat.PROTOBUF, new ProtobufMessageFormatter(schemaRegistryFacade.getSchemaRegistryClient()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ import {Backend} from '@app/common-model';
*ngIf="(isAuthenticated$ | async) && authService.canAccess([KouncilRole.CLUSTER_LIST])">
</app-sidebar-menu-item>
<div style="width: 100%; height: 32px">
<button mat-icon-button
style="bottom: 20px; right: 0; position: absolute;"
(click)="changeState()">
<mat-icon style="margin: 0" class="material-symbols-outlined">
<div class="toggle-sidebar-container">
<button mat-icon-button class="toggle-sidebar-btn" (click)="changeState()">
<mat-icon class="material-symbols-outlined toggle-sidebar-btn-icon">
{{ (currentState$ | async) ? 'dock_to_right' : 'dock_to_left' }}
</mat-icon>
</button>
Expand Down

0 comments on commit f41bdfe

Please sign in to comment.