Search in sources :

Example 11 with RetryOneTime

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();
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) Test(org.junit.Test)

Example 12 with RetryOneTime

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"));
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) Test(org.junit.Test)

Example 13 with RetryOneTime

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.
}
Also used : RetryOneTime(org.apache.curator.retry.RetryOneTime) NodeState(org.apache.camel.component.zookeepermaster.group.NodeState) Before(org.junit.Before)

Example 14 with RetryOneTime

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();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) RetryOneTime(org.apache.curator.retry.RetryOneTime) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Before(org.junit.Before)

Example 15 with RetryOneTime

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;
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime)

Aggregations

RetryOneTime (org.apache.curator.retry.RetryOneTime)25 CuratorFramework (org.apache.curator.framework.CuratorFramework)16 Test (org.junit.Test)10 Timing (org.apache.curator.test.Timing)8 TestingServer (org.apache.curator.test.TestingServer)6 Stat (org.apache.zookeeper.data.Stat)4 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)2 TestingCluster (org.apache.curator.test.TestingCluster)2 ElectionCandidate (com.dangdang.ddframe.job.reg.base.ElectionCandidate)1 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)1 CuratorZKClientBridge (com.netflix.curator.x.zkclientbridge.CuratorZKClientBridge)1 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)1 Random (java.util.Random)1 NodeState (org.apache.camel.component.zookeepermaster.group.NodeState)1