Search in sources :

Example 1 with CuratorFramework

use of org.apache.storm.shade.org.apache.curator.framework.CuratorFramework in project storm by apache.

the class CuratorUtils method newCuratorStarted.

public static CuratorFramework newCuratorStarted(Map<String, Object> conf, List<String> servers, Object port, ZookeeperAuthInfo auth, List<ACL> defaultAcl) {
    CuratorFramework ret = newCurator(conf, servers, port, auth, defaultAcl);
    LOG.info("Starting Utils Curator (2)...");
    ret.start();
    return ret;
}
Also used : CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework)

Example 2 with CuratorFramework

use of org.apache.storm.shade.org.apache.curator.framework.CuratorFramework in project storm by apache.

the class CuratorUtils method newCuratorStarted.

public static CuratorFramework newCuratorStarted(Map<String, Object> conf, List<String> servers, Object port, String root, ZookeeperAuthInfo auth, List<ACL> defaultAcl) {
    CuratorFramework ret = newCurator(conf, servers, port, root, auth, defaultAcl);
    LOG.info("Starting Utils Curator...");
    ret.start();
    return ret;
}
Also used : CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework)

Example 3 with CuratorFramework

use of org.apache.storm.shade.org.apache.curator.framework.CuratorFramework in project storm by apache.

the class BlobStoreUtils method createZKClient.

@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public static CuratorFramework createZKClient(Map<String, Object> conf, DaemonType type) {
    @SuppressWarnings("unchecked") List<String> zkServers = (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS);
    Object port = conf.get(Config.STORM_ZOOKEEPER_PORT);
    ZookeeperAuthInfo zkAuthInfo = new ZookeeperAuthInfo(conf);
    CuratorFramework zkClient = CuratorUtils.newCurator(conf, zkServers, port, (String) conf.get(Config.STORM_ZOOKEEPER_ROOT), zkAuthInfo, type.getDefaultZkAcls(conf));
    zkClient.start();
    return zkClient;
}
Also used : CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework) ZookeeperAuthInfo(org.apache.storm.utils.ZookeeperAuthInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with CuratorFramework

use of org.apache.storm.shade.org.apache.curator.framework.CuratorFramework in project storm by apache.

the class CuratorUtilsTest method newCuratorUsesExponentialBackoffTest.

@Test
public void newCuratorUsesExponentialBackoffTest() throws InterruptedException {
    final int expectedInterval = 2400;
    final int expectedRetries = 10;
    final int expectedCeiling = 3000;
    Map<String, Object> config = Utils.readDefaultConfig();
    config.put(Config.STORM_ZOOKEEPER_RETRY_INTERVAL, expectedInterval);
    config.put(Config.STORM_ZOOKEEPER_RETRY_TIMES, expectedRetries);
    config.put(Config.STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING, expectedCeiling);
    CuratorFramework curator = CuratorUtils.newCurator(config, Arrays.asList("bogus_server"), 42, "", DaemonType.WORKER.getDefaultZkAcls(config));
    StormBoundedExponentialBackoffRetry policy = (StormBoundedExponentialBackoffRetry) curator.getZookeeperClient().getRetryPolicy();
    Assert.assertEquals(policy.getBaseSleepTimeMs(), expectedInterval);
    Assert.assertEquals(policy.getN(), expectedRetries);
    Assert.assertEquals(policy.getSleepTimeMs(10, 0), expectedCeiling);
}
Also used : CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework) Test(org.junit.Test)

Example 5 with CuratorFramework

use of org.apache.storm.shade.org.apache.curator.framework.CuratorFramework in project storm by apache.

the class LocalFsBlobStoreSynchronizerTest method testNimbodesWithLatestVersionOfBlob.

@Test
public void testNimbodesWithLatestVersionOfBlob() throws Exception {
    try (TestingServer server = new TestingServer();
        CuratorFramework zkClient = CuratorFrameworkFactory.newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3))) {
        zkClient.start();
        // Creating nimbus hosts containing latest version of blob
        zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1");
        zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2");
        Set<NimbusInfo> set = BlobStoreUtils.getNimbodesWithLatestSequenceNumberOfBlob(zkClient, "key1");
        assertEquals("Failed to get the correct nimbus hosts with latest blob version", (set.iterator().next()).getHost(), "nimbus2");
        zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1");
        zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2");
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework) ExponentialBackoffRetry(org.apache.storm.shade.org.apache.curator.retry.ExponentialBackoffRetry) NimbusInfo(org.apache.storm.nimbus.NimbusInfo) Test(org.junit.Test)

Aggregations

CuratorFramework (org.apache.storm.shade.org.apache.curator.framework.CuratorFramework)8 ArrayList (java.util.ArrayList)3 List (java.util.List)3 DefaultWatcherCallBack (org.apache.storm.callback.DefaultWatcherCallBack)2 ZookeeperAuthInfo (org.apache.storm.utils.ZookeeperAuthInfo)2 Test (org.junit.Test)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Subject (javax.security.auth.Subject)1 TestingServer (org.apache.curator.test.TestingServer)1 BlobStore (org.apache.storm.blobstore.BlobStore)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 NimbusInfo (org.apache.storm.nimbus.NimbusInfo)1 NimbusPrincipal (org.apache.storm.security.auth.NimbusPrincipal)1 ExponentialBackoffRetry (org.apache.storm.shade.org.apache.curator.retry.ExponentialBackoffRetry)1 WatchedEvent (org.apache.storm.shade.org.apache.zookeeper.WatchedEvent)1 ACL (org.apache.storm.shade.org.apache.zookeeper.data.ACL)1 Id (org.apache.storm.shade.org.apache.zookeeper.data.Id)1