Search in sources :

Example 1 with ZookeeperConfiguration

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration in project elastic-job by dangdangdotcom.

the class RegistryCenterFactoryTest method assertCreateCoordinatorRegistryCenterWithoutDigest.

@Test
public void assertCreateCoordinatorRegistryCenterWithoutDigest() throws ReflectiveOperationException {
    ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "namespace", Optional.<String>absent()));
    assertThat(zkConfig.getNamespace(), is("namespace"));
    assertNull(zkConfig.getDigest());
}
Also used : ZookeeperConfiguration(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration) AbstractEmbedZookeeperBaseTest(com.dangdang.ddframe.job.lite.lifecycle.AbstractEmbedZookeeperBaseTest) Test(org.junit.Test)

Example 2 with ZookeeperConfiguration

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration in project elastic-job by dangdangdotcom.

the class RegistryCenterFactoryTest method assertCreateCoordinatorRegistryCenterWithDigest.

@Test
public void assertCreateCoordinatorRegistryCenterWithDigest() throws ReflectiveOperationException {
    ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "namespace", Optional.of("digest")));
    assertThat(zkConfig.getNamespace(), is("namespace"));
    assertThat(zkConfig.getDigest(), is("digest"));
}
Also used : ZookeeperConfiguration(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration) AbstractEmbedZookeeperBaseTest(com.dangdang.ddframe.job.lite.lifecycle.AbstractEmbedZookeeperBaseTest) Test(org.junit.Test)

Example 3 with ZookeeperConfiguration

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration in project elastic-job by dangdangdotcom.

the class BootstrapEnvironmentTest method assertGetZookeeperConfiguration.

@Test
public void assertGetZookeeperConfiguration() throws NoSuchFieldException {
    Properties properties = new Properties();
    properties.setProperty(EnvironmentArgument.ZOOKEEPER_DIGEST.getKey(), "test");
    ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", properties);
    ZookeeperConfiguration zkConfig = bootstrapEnvironment.getZookeeperConfiguration();
    assertThat(zkConfig.getServerLists(), is("localhost:2181"));
    assertThat(zkConfig.getNamespace(), is("elastic-job-cloud"));
    assertThat(zkConfig.getDigest(), is("test"));
}
Also used : Properties(java.util.Properties) ZookeeperConfiguration(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration) Test(org.junit.Test)

Example 4 with ZookeeperConfiguration

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration in project elastic-job by dangdangdotcom.

the class BootstrapEnvironment method getZookeeperConfiguration.

/**
     * 获取Zookeeper配置对象.
     * 
     * @return Zookeeper配置对象
     */
// TODO 其他zkConfig的值可配置
public ZookeeperConfiguration getZookeeperConfiguration() {
    ZookeeperConfiguration result = new ZookeeperConfiguration(getValue(EnvironmentArgument.ZOOKEEPER_SERVERS), getValue(EnvironmentArgument.ZOOKEEPER_NAMESPACE));
    String digest = getValue(EnvironmentArgument.ZOOKEEPER_DIGEST);
    if (!Strings.isNullOrEmpty(digest)) {
        result.setDigest(digest);
    }
    return result;
}
Also used : ZookeeperConfiguration(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration)

Example 5 with ZookeeperConfiguration

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration in project elastic-job by dangdangdotcom.

the class JavaMain method setUpRegistryCenter.

private static CoordinatorRegistryCenter setUpRegistryCenter() {
    ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(ZOOKEEPER_CONNECTION_STRING, JOB_NAMESPACE);
    CoordinatorRegistryCenter result = new ZookeeperRegistryCenter(zkConfig);
    result.init();
    return result;
}
Also used : ZookeeperRegistryCenter(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter) ZookeeperConfiguration(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration) CoordinatorRegistryCenter(com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)

Aggregations

ZookeeperConfiguration (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration)8 Test (org.junit.Test)4 AbstractEmbedZookeeperBaseTest (com.dangdang.ddframe.job.lite.lifecycle.AbstractEmbedZookeeperBaseTest)3 CoordinatorRegistryCenter (com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)2 ZookeeperRegistryCenter (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter)2 HashCode (com.google.common.hash.HashCode)1 Hasher (com.google.common.hash.Hasher)1 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1