Skip to content

Commit

Permalink
Remove ComputeNodeInstanceContextAware interface for ClusterPersistRe…
Browse files Browse the repository at this point in the history
…pository
  • Loading branch information
menghaoranss committed May 30, 2024
1 parent 18fa595 commit 2e51576
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.curator.framework.api.GetChildrenBuilder;
import org.apache.curator.framework.api.ProtectACLCreateModeStatPathAndBytesable;
import org.apache.curator.framework.api.SetDataBuilder;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
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.zookeeper.lock.ZookeeperDistributedLock;
Expand Down Expand Up @@ -107,7 +108,7 @@ void init() {
mockClient();
mockBuilder();
ClusterPersistRepositoryConfiguration config = new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, new Properties());
REPOSITORY.init(config);
REPOSITORY.init(config, mock(ComputeNodeInstanceContext.class));
mockDistributedLockHolder();
}

Expand Down Expand Up @@ -188,25 +189,28 @@ void assertBuildCuratorClientWithCustomConfiguration() {
new Property(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "1"),
new Property(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "1000"),
new Property(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "2000"));
assertDoesNotThrow(() -> REPOSITORY.init(new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, props)));
assertDoesNotThrow(() -> REPOSITORY.init(new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, props),
mock(ComputeNodeInstanceContext.class)));
}

@Test
void assertBuildCuratorClientWithTimeToLiveSecondsEqualsZero() {
assertDoesNotThrow(() -> REPOSITORY.init(new ClusterPersistRepositoryConfiguration(
REPOSITORY.getType(), "governance", SERVER_LISTS, PropertiesBuilder.build(new Property(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0")))));
REPOSITORY.getType(), "governance", SERVER_LISTS, PropertiesBuilder.build(new Property(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0"))),
mock(ComputeNodeInstanceContext.class)));
}

@Test
void assertBuildCuratorClientWithOperationTimeoutMillisecondsEqualsZero() {
assertDoesNotThrow(() -> REPOSITORY.init(new ClusterPersistRepositoryConfiguration(
REPOSITORY.getType(), "governance", SERVER_LISTS, PropertiesBuilder.build(new Property(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0")))));
REPOSITORY.getType(), "governance", SERVER_LISTS, PropertiesBuilder.build(new Property(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0"))),
mock(ComputeNodeInstanceContext.class)));
}

@Test
void assertBuildCuratorClientWithDigest() {
REPOSITORY.init(new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS,
PropertiesBuilder.build(new Property(ZookeeperPropertyKey.DIGEST.getKey(), "any"))));
PropertiesBuilder.build(new Property(ZookeeperPropertyKey.DIGEST.getKey(), "any"))), mock(ComputeNodeInstanceContext.class));
verify(builder).aclProvider(any(ACLProvider.class));
}

Expand Down

0 comments on commit 2e51576

Please sign in to comment.