Skip to content

Commit

Permalink
Refactor StateContext (#32909)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Sep 16, 2024
1 parent 973d027 commit 28e3d2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@

package org.apache.shardingsphere.mode.state;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.state.cluster.ClusterState;

import java.util.concurrent.atomic.AtomicReference;

/**
* State context.
*/
@Slf4j
public final class StateContext {

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

public StateContext(final ClusterState repositoryClusterState) {
if (clusterState.get() != repositoryClusterState) {
switchClusterState(repositoryClusterState);
}
public StateContext(final ClusterState clusterState) {
this.clusterState = new AtomicReference<>(clusterState);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class StateContextTest {
private final StateContext stateContext = new StateContext(ClusterState.OK);

@Test
void assertGetCurrentClusterState() {
void assertGetClusterState() {
assertThat(stateContext.getClusterState(), is(ClusterState.OK));
}

Expand Down

0 comments on commit 28e3d2c

Please sign in to comment.