当前位置: 首页>>代码示例>>Java>>正文


Java TestingCluster类代码示例

本文整理汇总了Java中org.apache.curator.test.TestingCluster的典型用法代码示例。如果您正苦于以下问题:Java TestingCluster类的具体用法?Java TestingCluster怎么用?Java TestingCluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestingCluster类属于org.apache.curator.test包,在下文中一共展示了TestingCluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doEvaluate

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
void doEvaluate(Statement base) throws Throwable {
  try {
    cluster = new TestingCluster(3);
    cluster.start();

    client = newClient(cluster.getConnectString(), new RetryOneTime(200 /* ms */));
    client.start();

    checkState(client.blockUntilConnected(5, TimeUnit.SECONDS),
        "failed to connect to zookeeper in 5 seconds");

    base.evaluate();
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new IllegalStateException("Interrupted while connecting to ZooKeeper", e);
  } finally {
    client.close();
    cluster.close();
  }
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:21,代码来源:ZooKeeperRule.java

示例2: beforeTest

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
/**
 * Before test.
 *
 * @throws Exception
 */
@Override public void beforeTest() throws Exception {
    super.beforeTest();

    // remove stale system properties
    System.getProperties().remove(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING);

    // disable JMX for tests
    System.setProperty("zookeeper.jmx.log4j.disable", "true");

    // start the ZK cluster
    zkCluster = new TestingCluster(ZK_CLUSTER_SIZE);
    zkCluster.start();

    // start the Curator client so we can perform assertions on the ZK state later
    zkCurator = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), new RetryNTimes(10, 1000));
    zkCurator.start();
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:ZookeeperIpFinderTest.java

示例3: Client

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
private Client(int id, TestingCluster cluster, Set<TaskId> executedTasks, CountDownLatch executedTasksLatch)
{
    curator = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(10, 3)).build();
    curator.start();

    TestTaskExecutor taskExecutor = new TestTaskExecutor(6) {
        @Override
        protected void doRun(ExecutableTask task) throws InterruptedException
        {
            executedTasks.add(task.getTaskId());
            timing.forWaiting().sleepABit();
            executedTasksLatch.countDown();
        }
    };

    workflowManager = WorkflowManagerBuilder.builder()
        .addingTaskExecutor(taskExecutor, 10, taskType)
        .withCurator(curator, "test", "1")
        .withInstanceName("i-" + id)
        .build();
    workflowManager.start();
}
 
开发者ID:NirmataOSS,项目名称:workflow,代码行数:23,代码来源:TestDisruptedScheduler.java

示例4: setup

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@BeforeMethod
public void setup() throws Exception
{
    timing = new Timing();

    cluster = new TestingCluster(3);
    cluster.start();
    client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:11,代码来源:TestZookeeperConfigProvider.java

示例5: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    //registerService("localhost-1", 9000, 1);
    //registerService("localhost-2", 9000, 1);
    //registerService("localhost-3", 9000, 2);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:10,代码来源:ServiceNoProviderTest.java

示例6: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    registerService("localhost-1", 9000, 1);
    //registerService("localhost-2", 9000, 1);
    registerService("localhost-3", 9000, 2);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:10,代码来源:ServiceProviderHealthcheckTest.java

示例7: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    registerService("localhost-1", 9000, 1);
    registerService("localhost-2", 9000, 1);
    registerService("localhost-3", 9000, 1);
    registerService("localhost-4", 9000, 2);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:11,代码来源:ServiceProviderTest.java

示例8: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    registerService("localhost-1", 9000, 1, 2);
    registerService("localhost-2", 9000, 1, 3);
    registerService("localhost-3", 9000, 2, 3);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:10,代码来源:CustomShardSelectorTest.java

示例9: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    curatorFramework = CuratorFrameworkFactory.builder()
            .namespace("test")
            .connectString(testingCluster.getConnectString())
            .retryPolicy(new ExponentialBackoffRetry(1000, 100)).build();
    curatorFramework.start();
    registerService("localhost-1", 9000, 1);
    registerService("localhost-2", 9000, 1);
    registerService("localhost-3", 9000, 2);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:15,代码来源:ServiceProviderExtCuratorTest.java

示例10: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();
    registerService("localhost-1", 9000, 1);
    registerService("localhost-2", 9000, 1);
    registerService("localhost-3", 9000, 2);
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:10,代码来源:SimpleServiceProviderTest.java

示例11: startTestCluster

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
    objectMapper = new ObjectMapper();
    testingCluster = new TestingCluster(3);
    testingCluster.start();

    /* registering 3 with RotationMonitor on file and 1 on anotherFile */
    registerService("localhost-1", 9000, 1, file);
    registerService("localhost-2", 9000, 1, file);
    registerService("localhost-3", 9000, 2, file);

    registerService("localhost-4", 9000, 2, anotherFile);

    serviceFinder = ServiceFinderBuilders.unshardedFinderBuilder()
            .withConnectionString(testingCluster.getConnectString())
            .withNamespace("test")
            .withServiceName("test-service")
            .withDeserializer(new Deserializer<UnshardedClusterInfo>() {
                @Override
                public ServiceNode<UnshardedClusterInfo> deserialize(byte[] data) {
                    try {
                        return objectMapper.readValue(data,
                                new TypeReference<ServiceNode<UnshardedClusterInfo>>() {
                                });
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            })
            .build();
    serviceFinder.start();
}
 
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:34,代码来源:ServiceProviderIntegrationTest.java

示例12: setup

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@BeforeMethod
@Override
public void setup() throws Exception
{
    super.setup();

    QuorumPeerConfig.setReconfigEnabled(true);
    System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest", superUserPasswordDigest);

    CloseableUtils.closeQuietly(server);
    server = null;
    cluster = new TestingCluster(3);
    cluster.start();
}
 
开发者ID:apache,项目名称:curator,代码行数:15,代码来源:TestReconfiguration.java

示例13: testAdd

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Test
public void testAdd() throws Exception
{
    try ( CuratorFramework client = newClient())
    {
        client.start();

        QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
        assertConfig(oldConfig, cluster.getInstances());

        CountDownLatch latch = setChangeWaiter(client);
        try ( TestingCluster newCluster = new TestingCluster(TestingCluster.makeSpecs(1, false)) )
        {
            newCluster.start();

            client.reconfig().joining(toReconfigSpec(newCluster.getInstances())).fromConfig(oldConfig.getVersion()).forEnsemble();

            Assert.assertTrue(timing.awaitLatch(latch));

            byte[] newConfigData = client.getConfig().forEnsemble();
            QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
            List<InstanceSpec> newInstances = Lists.newArrayList(cluster.getInstances());
            newInstances.addAll(newCluster.getInstances());
            assertConfig(newConfig, newInstances);
            Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
        }
    }
}
 
开发者ID:apache,项目名称:curator,代码行数:29,代码来源:TestReconfiguration.java

示例14: setup

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@BeforeMethod
public void setup() throws Exception
{
    cluster = new TestingCluster(3);
    cluster.start();

    clients = Lists.newArrayList();
    executedTasks = Sets.newConcurrentHashSet();
    executedTasksLatch = new CountDownLatch(6);
}
 
开发者ID:NirmataOSS,项目名称:workflow,代码行数:11,代码来源:TestDisruptedScheduler.java

示例15: beforeTest

import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void beforeTest() {
  try {
    cluster = new TestingCluster(3);
    cluster.start();
    zkClient = CuratorFrameworkFactory.newClient(cluster.getConnectString(), buildDefaultRetryPolicy());
    zkClient.start();
  } catch (Exception e) {
    System.err.println("Unable to initialize cluster before test! " + e);
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:12,代码来源:OperationsNodeIT.java


注:本文中的org.apache.curator.test.TestingCluster类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。