Skip to content

Commit

Permalink
Remove ClusterStatusService (#31274)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghaoranss authored May 17, 2024
1 parent c2514a5 commit 7a6cd19
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.mode.state;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.state.cluster.ClusterState;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -29,6 +30,7 @@ public final class StateContext {

private final AtomicReference<ClusterState> currentState = new AtomicReference<>(ClusterState.OK);

@Getter
private final StateService stateService;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.subscriber.ShardingSphereSchemaDataRegistrySubscriber;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.subscriber.ClusterProcessSubscriber;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.cluster.service.ClusterStatusService;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.cluster.subscriber.ClusterStatusSubscriber;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.subscriber.ComputeNodeStatusSubscriber;
Expand All @@ -49,6 +48,7 @@
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
import org.apache.shardingsphere.mode.repository.cluster.lock.holder.DistributedLockHolder;
import org.apache.shardingsphere.mode.repository.cluster.lock.impl.props.DefaultLockTypedProperties;
import org.apache.shardingsphere.mode.state.StateService;
import org.apache.shardingsphere.mode.storage.service.QualifiedDataSourceStatusService;

import java.sql.SQLException;
Expand All @@ -74,7 +74,7 @@ public ContextManager build(final ContextManagerBuilderParameter param, final Ev
setContextManagerAware(result);
createSubscribers(eventBusContext, repository);
registerOnline(eventBusContext, instanceContext, repository, param, result);
setClusterState(repository, result);
setClusterState(result);
return result;
}

Expand Down Expand Up @@ -121,13 +121,13 @@ private void registerOnline(final EventBusContext eventBusContext, final Instanc
new ClusterEventSubscriberRegistry(contextManager, repository).register();
}

private void setClusterState(final ClusterPersistRepository repository, final ContextManager contextManager) {
ClusterStatusService clusterStatusService = new ClusterStatusService(repository);
Optional<ClusterState> clusterState = clusterStatusService.load();
private void setClusterState(final ContextManager contextManager) {
StateService stateService = contextManager.getStateContext().getStateService();
Optional<ClusterState> clusterState = stateService.load();
if (clusterState.isPresent()) {
contextManager.updateClusterState(clusterState.get());
} else {
clusterStatusService.persist(ClusterState.OK);
stateService.persist(ClusterState.OK);
}
}

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 7a6cd19

Please sign in to comment.