本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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());
}
}
}
示例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);
}
示例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);
}
}