Search in sources :

Example 81 with TestingServer

use of org.apache.curator.test.TestingServer in project hadoop by apache.

the class TestZKRMStateStore method setupCuratorServer.

public static TestingServer setupCuratorServer() throws Exception {
    TestingServer curatorTestingServer = new TestingServer();
    curatorTestingServer.start();
    return curatorTestingServer;
}
Also used : TestingServer(org.apache.curator.test.TestingServer)

Example 82 with TestingServer

use of org.apache.curator.test.TestingServer in project hadoop by apache.

the class TestRMStoreCommands method testFormatStateStoreCmdForZK.

@Test
public void testFormatStateStoreCmdForZK() throws Exception {
    StateChangeRequestInfo req = new StateChangeRequestInfo(HAServiceProtocol.RequestSource.REQUEST_BY_USER);
    try (TestingServer curatorTestingServer = TestZKRMStateStore.setupCuratorServer();
        CuratorFramework curatorFramework = TestZKRMStateStore.setupCuratorFramework(curatorTestingServer)) {
        Configuration conf = TestZKRMStateStore.createHARMConf("rm1,rm2", "rm1", 1234, false, curatorTestingServer);
        ResourceManager rm = new MockRM(conf);
        rm.start();
        rm.getRMContext().getRMAdminService().transitionToActive(req);
        String zkStateRoot = ZKRMStateStore.ROOT_ZNODE_NAME;
        assertEquals("RM State store parent path should have a child node " + zkStateRoot, zkStateRoot, curatorFramework.getChildren().forPath(YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH).get(0));
        rm.close();
        try {
            ResourceManager.deleteRMStateStore(conf);
        } catch (Exception e) {
            fail("Exception should not be thrown during format rm state store" + " operation.");
        }
        assertTrue("After store format parent path should have no child nodes", curatorFramework.getChildren().forPath(YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH).isEmpty());
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFramework(org.apache.curator.framework.CuratorFramework) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) StateChangeRequestInfo(org.apache.hadoop.ha.HAServiceProtocol.StateChangeRequestInfo) Test(org.junit.Test)

Example 83 with TestingServer

use of org.apache.curator.test.TestingServer in project storm by apache.

the class BlobSynchronizerTest method testNimbodesWithLatestVersionOfBlob.

@Test
public void testNimbodesWithLatestVersionOfBlob() throws Exception {
    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");
    zkClient.close();
    server.close();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFramework(org.apache.curator.framework.CuratorFramework) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) NimbusInfo(org.apache.storm.nimbus.NimbusInfo) Test(org.junit.Test)

Example 84 with TestingServer

use of org.apache.curator.test.TestingServer in project Mycat-Server by MyCATApache.

the class DistributedSequenceHandlerTest method initialize.

@Before
public void initialize() throws Exception {
    distributedSequenceHandler = new DistributedSequenceHandler[16];
    MycatConfig mycatConfig = new MycatConfig();
    testingServer = new TestingServer();
    testingServer.start();
    for (int i = 0; i < 16; i++) {
        distributedSequenceHandler[i] = new DistributedSequenceHandler(mycatConfig.getSystem());
        distributedSequenceHandler[i].initializeZK(testingServer.getConnectString());
        distributedSequenceHandler[i].nextId("");
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) DistributedSequenceHandler(io.mycat.route.sequence.handler.DistributedSequenceHandler) MycatConfig(io.mycat.config.MycatConfig) Before(org.junit.Before)

Example 85 with TestingServer

use of org.apache.curator.test.TestingServer in project Mycat-Server by MyCATApache.

the class IncrSequenceZKHandlerTest method initialize.

@Before
public void initialize() throws Exception {
    testingServer = new TestingServer();
    testingServer.start();
    incrSequenceZKHandler = new IncrSequenceZKHandler[MAX_CONNECTION];
    results = new ConcurrentSkipListSet();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) Before(org.junit.Before)

Aggregations

TestingServer (org.apache.curator.test.TestingServer)150 Before (org.junit.Before)38 Test (org.junit.Test)30 CuratorFramework (org.apache.curator.framework.CuratorFramework)28 File (java.io.File)27 Properties (java.util.Properties)18 KafkaConfig (kafka.server.KafkaConfig)15 RetryOneTime (org.apache.curator.retry.RetryOneTime)15 Test (org.testng.annotations.Test)15 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)14 IOException (java.io.IOException)13 Timing (org.apache.curator.test.Timing)13 HashMap (java.util.HashMap)12 ZkClient (org.I0Itec.zkclient.ZkClient)12 ServerSocket (java.net.ServerSocket)11 KafkaServerStartable (kafka.server.KafkaServerStartable)11 ZkUtils (kafka.utils.ZkUtils)11 ZkConnection (org.I0Itec.zkclient.ZkConnection)11 BeforeClass (org.junit.BeforeClass)11 TestingServerStarter (io.pravega.test.common.TestingServerStarter)9