You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/14 05:36:42 UTC
[shardingsphere] branch master updated: Upgrade to CosId 1.10.0 (#17641)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3faaf9cde30 Upgrade to CosId 1.10.0 (#17641)
3faaf9cde30 is described below
commit 3faaf9cde3086b4f45c77073d4c4021355697a7b
Author: Ahoo Wang <ah...@qq.com>
AuthorDate: Sat May 14 13:36:32 2022 +0800
Upgrade to CosId 1.10.0 (#17641)
* Upgrade to CosId 1.10.0
* refactor: static import `Matchers.lessThanOrEqualTo`
---
.../src/main/release-docs/LICENSE | 2 +-
.../shardingsphere-sharding-cosid/pom.xml | 2 +-
.../keygen/CosIdKeyGenerateAlgorithmTest.java | 19 ++++++++++++-------
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE
index 2bdb231640c..3248de76b72 100644
--- a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE
+++ b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE
@@ -233,7 +233,7 @@ The text of each license is the standard Apache 2.0 license.
curator-client 5.1.0: https://github.com/apache/curator, Apache 2.0
curator-framework 5.1.0: https://github.com/apache/curator, Apache 2.0
curator-recipes 5.1.0: https://github.com/apache/curator, Apache 2.0
- cosid-core 1.8.6: https://github.com/Ahoo-Wang/CosId, Apache 2.0
+ cosid-core 1.10.0: https://github.com/Ahoo-Wang/CosId, Apache 2.0
error_prone_annotations 2.3.4: https://github.com/google/error-prone, Apache 2.0
esri-geometry-api 2.2.0: https://github.com/Esri/geometry-api-java, Apache 2.0
failsafe 2.3.3: https://github.com/jhalterman/failsafe, Apache 2.0
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/pom.xml b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/pom.xml
index bd3d061d6c2..e1f9b14f771 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/pom.xml
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/pom.xml
@@ -28,7 +28,7 @@
<name>${project.artifactId}</name>
<properties>
- <cosid.version>1.8.6</cosid.version>
+ <cosid.version>1.10.0</cosid.version>
</properties>
<dependencies>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java
index bc7f65bbc7b..fc0f8b87c70 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java
@@ -17,24 +17,27 @@
package org.apache.shardingsphere.sharding.cosid.algorithm.keygen;
+import java.util.Properties;
+import me.ahoo.cosid.IdGenerator;
+import me.ahoo.cosid.StringIdGenerator;
+import me.ahoo.cosid.converter.PrefixIdConverter;
+import me.ahoo.cosid.converter.Radix62IdConverter;
import me.ahoo.cosid.provider.DefaultIdGeneratorProvider;
import me.ahoo.cosid.provider.NotFoundIdGeneratorException;
import me.ahoo.cosid.segment.DefaultSegmentId;
import me.ahoo.cosid.segment.IdSegmentDistributor;
-import me.ahoo.cosid.util.MockIdGenerator;
+import me.ahoo.cosid.snowflake.MillisecondSnowflakeId;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
import org.apache.shardingsphere.sharding.factory.KeyGenerateAlgorithmFactory;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.junit.Test;
-import java.util.Properties;
-
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
public final class CosIdKeyGenerateAlgorithmTest {
@@ -72,12 +75,14 @@ public final class CosIdKeyGenerateAlgorithmTest {
@Test
public void assertGenerateKeyAsString() {
String idName = "test-cosid-as-string";
- DefaultIdGeneratorProvider.INSTANCE.set(idName, MockIdGenerator.INSTANCE);
+ String prefix = "test_";
+ IdGenerator stringIdGen = new StringIdGenerator(new MillisecondSnowflakeId(1, 0), new PrefixIdConverter(prefix, Radix62IdConverter.INSTANCE));
+ DefaultIdGeneratorProvider.INSTANCE.set(idName, stringIdGen);
KeyGenerateAlgorithm algorithm = KeyGenerateAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("COSID", createAsStringProperties(idName)));
Comparable<?> actual = algorithm.generateKey();
assertThat(actual, instanceOf(String.class));
- assertThat(actual.toString(), startsWith("test_"));
- assertTrue(actual.toString().length() <= 16);
+ assertThat(actual.toString(), startsWith(prefix));
+ assertThat(actual.toString().length(), lessThanOrEqualTo(16));
}
private Properties createAsStringProperties(final String idName) {