use of org.apache.curator.retry.RetryOneTime in project elastic-job by dangdangdotcom.
the class ZookeeperRegistryCenterModifyTest method assertPersistEphemeral.
@Test
public void assertPersistEphemeral() throws Exception {
zkRegCenter.persist("/persist", "persist_value");
zkRegCenter.persistEphemeral("/ephemeral", "ephemeral_value");
assertThat(zkRegCenter.get("/persist"), is("persist_value"));
assertThat(zkRegCenter.get("/ephemeral"), is("ephemeral_value"));
zkRegCenter.close();
CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000));
client.start();
client.blockUntilConnected();
assertThat(client.getData().forPath("/" + ZookeeperRegistryCenterModifyTest.class.getName() + "/persist"), is("persist_value".getBytes()));
assertNull(client.checkExists().forPath("/" + ZookeeperRegistryCenterModifyTest.class.getName() + "/ephemeral"));
zkRegCenter.init();
}
use of org.apache.curator.retry.RetryOneTime in project elastic-job by dangdangdotcom.
the class ZookeeperRegistryCenterModifyTest method assertPersistSequential.
@Test
public void assertPersistSequential() throws Exception {
assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential"));
assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential"));
CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000));
client.start();
client.blockUntilConnected();
List<String> actual = client.getChildren().forPath("/" + ZookeeperRegistryCenterModifyTest.class.getName() + "/sequential");
assertThat(actual.size(), is(2));
for (String each : actual) {
assertThat(each, startsWith("test_sequential"));
assertThat(zkRegCenter.get("/sequential/" + each), startsWith("test_value"));
}
}
use of org.apache.curator.retry.RetryOneTime in project camel by apache.
the class ZooKeeperGroupTest method setUp.
@Before
public void setUp() throws Exception {
int port = findFreePort();
curator = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1)).build();
//curator.start();
group = new ZooKeeperGroup<>(curator, PATH, NodeState.class);
//group.start();
// Starting curator and group is not necessary for the current tests.
}
use of org.apache.curator.retry.RetryOneTime in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method beforeClass.
@Before
public void beforeClass() throws Exception {
zookeeper = new TestingServer(SocketUtils.findAvailableTcpPort());
curatorFramework = CuratorFrameworkFactory.newClient(zookeeper.getConnectString(), new RetryOneTime(1000));
curatorFramework.start();
curatorFramework.create().forPath(CONFIG_BASE_PATH);
Map<String, Object> defaults = new HashMap<>();
defaults.put(DEF_KEY1, DEF_VAL1);
defaults.put(DEF_KEY2, DEF_VAL2);
defaultConfiguration = new MapConfiguration(defaults);
node = UUID.randomUUID().toString();
config = new ConcurrentCompositeConfiguration();
}
use of org.apache.curator.retry.RetryOneTime in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method createCuratorFramework.
private CuratorFramework createCuratorFramework() {
CuratorFramework curator = CuratorFrameworkFactory.newClient(testingServer.getConnectString(), 5000, 5000, new RetryOneTime(1000));
curator.start();
return curator;
}
Aggregations