提交 2db3fcb4 authored 作者: 陈世营's avatar 陈世营

【修改】 leaf 配置修改

上级 1a0ef56e
package com.loit.component.keygen.leaf; package com.loit.component.keygen.leaf;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
...@@ -10,6 +11,7 @@ import lombok.Getter; ...@@ -10,6 +11,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -19,7 +21,7 @@ import java.util.concurrent.SynchronousQueue; ...@@ -19,7 +21,7 @@ import java.util.concurrent.SynchronousQueue;
* Key generator implemented by leaf segment algorithms. * Key generator implemented by leaf segment algorithms.
* *
*/ */
public final class LeafSegmentLeafKeyGenerator implements LeafKeyGenerator { public final class LeafSegmentKeyGenerator implements LeafKeyGenerator {
private static final String DEFAULT_NAMESPACE = "leaf_segment"; private static final String DEFAULT_NAMESPACE = "leaf_segment";
...@@ -47,7 +49,7 @@ public final class LeafSegmentLeafKeyGenerator implements LeafKeyGenerator { ...@@ -47,7 +49,7 @@ public final class LeafSegmentLeafKeyGenerator implements LeafKeyGenerator {
@Setter @Setter
private Properties properties = new Properties(); private Properties properties = new Properties();
public LeafSegmentLeafKeyGenerator() { public LeafSegmentKeyGenerator() {
incrementCacheIdExecutor = Executors.newSingleThreadExecutor(); incrementCacheIdExecutor = Executors.newSingleThreadExecutor();
cacheIdQueue = new SynchronousQueue<>(); cacheIdQueue = new SynchronousQueue<>();
} }
...@@ -163,35 +165,35 @@ public final class LeafSegmentLeafKeyGenerator implements LeafKeyGenerator { ...@@ -163,35 +165,35 @@ public final class LeafSegmentLeafKeyGenerator implements LeafKeyGenerator {
} }
private long getStep() { private long getStep() {
long result = Long.parseLong(properties.getProperty("step", DEFAULT_STEP)); long result = Long.parseLong(properties.getProperty("leaf.segment.step", DEFAULT_STEP));
Preconditions.checkArgument(result > 0L && result < Long.MAX_VALUE); Preconditions.checkArgument(result > 0L && result < Long.MAX_VALUE);
return result; return result;
} }
private long getInitialValue() { private long getInitialValue() {
long result = Long.parseLong(properties.getProperty("initialValue", DEFAULT_INITIAL_VALUE)); long result = Long.parseLong(properties.getProperty("leaf.segment.id.initial.value", DEFAULT_INITIAL_VALUE));
Preconditions.checkArgument(result >= 0L && result < Long.MAX_VALUE); Preconditions.checkArgument(result >= 0L && result < Long.MAX_VALUE);
return result; return result;
} }
private String getLeafKey() { private String getLeafKey() {
String leafKey = properties.getProperty("leafKey"); String leafKey = properties.getProperty("leaf.key");
Preconditions.checkArgument(!Strings.isNullOrEmpty(leafKey)); Preconditions.checkArgument(!Strings.isNullOrEmpty(leafKey));
Preconditions.checkArgument(leafKey.matches(REGULAR_PATTERN)); Preconditions.checkArgument(leafKey.matches(REGULAR_PATTERN));
return SLANTING_BAR + leafKey; return SLANTING_BAR + leafKey;
} }
private String getServerList() { private String getServerList() {
String result = properties.getProperty("serverList"); String result = properties.getProperty("server.list");
Preconditions.checkArgument(!Strings.isNullOrEmpty(result)); Preconditions.checkArgument(!Strings.isNullOrEmpty(result));
return result; return result;
} }
private String getDigest() { private String getDigest() {
return properties.getProperty("digest"); return properties.getProperty("registry.center.digest");
} }
private String getRegistryCenterType() { private String getRegistryCenterType() {
return properties.getProperty("registryCenterType", DEFAULT_REGISTRY_CENTER); return properties.getProperty("registry.center.type", DEFAULT_REGISTRY_CENTER);
} }
} }
...@@ -13,9 +13,9 @@ import static org.hamcrest.CoreMatchers.is; ...@@ -13,9 +13,9 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
@FixMethodOrder(value = MethodSorters.NAME_ASCENDING) @FixMethodOrder(value = MethodSorters.NAME_ASCENDING)
public final class LeafSegmentLeafKeyGeneratorTest { public final class LeafSegmentKeyGeneratorTest {
private final LeafSegmentLeafKeyGenerator leafSegmentKeyGenerator = new LeafSegmentLeafKeyGenerator(); private final LeafSegmentKeyGenerator leafSegmentKeyGenerator = new LeafSegmentKeyGenerator();
@Test @Test
public void assertGetProperties() { public void assertGetProperties() {
...@@ -33,11 +33,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -33,11 +33,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test @Test
public void assertGenerateKeyWithSingleThread() { public void assertGenerateKeyWithSingleThread() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("step", "5"); properties.setProperty("leaf.segment.step", "5");
properties.setProperty("leafKey", "test_table_1"); properties.setProperty("leaf.key", "test_table_1");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L); List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L);
List<Comparable<?>> actual = new ArrayList<>(); List<Comparable<?>> actual = new ArrayList<>();
...@@ -50,11 +50,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -50,11 +50,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test @Test
public void assertGenerateKeyWithFirstSpecialStep() { public void assertGenerateKeyWithFirstSpecialStep() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("leafKey", "test_table_6"); properties.setProperty("leaf.key", "test_table_6");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L); List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L);
List<Comparable<?>> actual = new ArrayList<>(); List<Comparable<?>> actual = new ArrayList<>();
...@@ -67,11 +67,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -67,11 +67,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test @Test
public void assertGenerateKeyWithSecondSpecialStep() { public void assertGenerateKeyWithSecondSpecialStep() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("step", "7"); properties.setProperty("leaf.segment.step", "7");
properties.setProperty("leafKey", "test_table_7"); properties.setProperty("leaf.key", "test_table_7");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L); List<Comparable<?>> expected = Arrays.<Comparable<?>>asList(100001L, 100002L, 100003L, 100004L, 100005L, 100006L, 100007L, 100008L, 100009L, 100010L);
List<Comparable<?>> actual = new ArrayList<>(); List<Comparable<?>> actual = new ArrayList<>();
...@@ -86,11 +86,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -86,11 +86,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
int threadNumber = 2; int threadNumber = 2;
ExecutorService executor = Executors.newFixedThreadPool(threadNumber); ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("leafKey", "test_table_2"); properties.setProperty("leaf.key", "test_table_2");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
Set<Comparable<?>> actual = new HashSet<>(); Set<Comparable<?>> actual = new HashSet<>();
int taskNumber = threadNumber * 2; int taskNumber = threadNumber * 2;
...@@ -111,12 +111,12 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -111,12 +111,12 @@ public final class LeafSegmentLeafKeyGeneratorTest {
int threadNumber = 2; int threadNumber = 2;
ExecutorService executor = Executors.newFixedThreadPool(threadNumber); ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("digest", "name:123456"); properties.setProperty("registry.center.digest", "name:123456");
properties.setProperty("leafKey", "test_table_3"); properties.setProperty("leaf.key", "test_table_3");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
Set<Comparable<?>> actual = new HashSet<>(); Set<Comparable<?>> actual = new HashSet<>();
int taskNumber = threadNumber * 2; int taskNumber = threadNumber * 2;
...@@ -137,10 +137,10 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -137,10 +137,10 @@ public final class LeafSegmentLeafKeyGeneratorTest {
int threadNumber = 2; int threadNumber = 2;
ExecutorService executor = Executors.newFixedThreadPool(threadNumber); ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_4"); properties.setProperty("leaf.key", "test_table_4");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
Set<Comparable<?>> actual = new HashSet<>(); Set<Comparable<?>> actual = new HashSet<>();
int taskNumber = threadNumber * 2; int taskNumber = threadNumber * 2;
...@@ -161,10 +161,10 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -161,10 +161,10 @@ public final class LeafSegmentLeafKeyGeneratorTest {
int threadNumber = 2; int threadNumber = 2;
ExecutorService executor = Executors.newFixedThreadPool(threadNumber); ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("leafKey", "test_table_5"); properties.setProperty("leaf.key", "test_table_5");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
int taskNumber = threadNumber * 2; int taskNumber = threadNumber * 2;
Set<Comparable<?>> actual = new HashSet<>(); Set<Comparable<?>> actual = new HashSet<>();
...@@ -183,11 +183,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -183,11 +183,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetStepFailureWhenNegative() { public void assertSetStepFailureWhenNegative() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", String.valueOf(-1L)); properties.setProperty("leaf.segment.step", String.valueOf(-1L));
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_9"); properties.setProperty("leaf.key", "test_table_9");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -195,11 +195,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -195,11 +195,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetStepFailureWhenZero() { public void assertSetStepFailureWhenZero() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", String.valueOf(0L)); properties.setProperty("leaf.segment.step", String.valueOf(0L));
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_10"); properties.setProperty("leaf.key", "test_table_10");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -207,11 +207,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -207,11 +207,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetStepFailureWhenTooMuch() { public void assertSetStepFailureWhenTooMuch() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", String.valueOf(Long.MAX_VALUE)); properties.setProperty("leaf.segment.step", String.valueOf(Long.MAX_VALUE));
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_11"); properties.setProperty("leaf.key", "test_table_11");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -219,11 +219,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -219,11 +219,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetInitialValueFailureWhenNegative() { public void assertSetInitialValueFailureWhenNegative() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", String.valueOf(-1L)); properties.setProperty("leaf.segment.id.initial.value", String.valueOf(-1L));
properties.setProperty("leafKey", "test_table_12"); properties.setProperty("leaf.key", "test_table_12");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -231,11 +231,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -231,11 +231,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetInitialValueFailureWhenTooMuch() { public void assertSetInitialValueFailureWhenTooMuch() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", String.valueOf(Long.MAX_VALUE)); properties.setProperty("leaf.segment.id.initial.value", String.valueOf(Long.MAX_VALUE));
properties.setProperty("leafKey", "test_table_13"); properties.setProperty("leaf.key", "test_table_13");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -243,10 +243,10 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -243,10 +243,10 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetServerListFailureWhenNull() { public void assertSetServerListFailureWhenNull() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_14"); properties.setProperty("leaf.key", "test_table_14");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -254,11 +254,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -254,11 +254,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetServerListFailureWhenArgumentEmpty() { public void assertSetServerListFailureWhenArgumentEmpty() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", ""); properties.setProperty("server.list", "");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "test_table_15"); properties.setProperty("leaf.key", "test_table_15");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -266,11 +266,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -266,11 +266,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetLeafKeyFailureWhenArgumentIllegal() { public void assertSetLeafKeyFailureWhenArgumentIllegal() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "/test_table_16"); properties.setProperty("leaf.key", "/test_table_16");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -278,11 +278,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -278,11 +278,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetLeafKeyFailureWhenArgumentEmpty() { public void assertSetLeafKeyFailureWhenArgumentEmpty() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", ""); properties.setProperty("leaf.key", "");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -290,10 +290,10 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -290,10 +290,10 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetLeafKeyFailureWhenNull() { public void assertSetLeafKeyFailureWhenNull() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
...@@ -301,11 +301,11 @@ public final class LeafSegmentLeafKeyGeneratorTest { ...@@ -301,11 +301,11 @@ public final class LeafSegmentLeafKeyGeneratorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void assertSetRegistryCenterTypeFailureWhenWrongType() { public void assertSetRegistryCenterTypeFailureWhenWrongType() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("serverList", "127.0.0.1:2181"); properties.setProperty("server.list", "127.0.0.1:2181");
properties.setProperty("step", "3"); properties.setProperty("leaf.segment.step", "3");
properties.setProperty("initialValue", "100001"); properties.setProperty("leaf.segment.id.initial.value", "100001");
properties.setProperty("leafKey", "/test_table_17"); properties.setProperty("leaf.key", "/test_table_17");
properties.setProperty("registryCenterType", "zookeeper"); properties.setProperty("registry.center.type", "zookeeper");
leafSegmentKeyGenerator.setProperties(properties); leafSegmentKeyGenerator.setProperties(properties);
leafSegmentKeyGenerator.generateKey(); leafSegmentKeyGenerator.generateKey();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论