本文整理汇总了Java中org.apache.curator.test.TestingCluster类的典型用法代码示例。如果您正苦于以下问题:Java TestingCluster类的具体用法?Java TestingCluster怎么用?Java TestingCluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestingCluster类属于org.apache.curator.test包,在下文中一共展示了TestingCluster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: checkStarted
import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
/**
* Check started.
*
* @param kaaNodeInitializationService the kaa node initialization service
* @throws Exception the exception
*/
public static void checkStarted(KaaNodeInitializationService kaaNodeInitializationService) throws Exception {
if (!kaaNodeServerStarted) {
zkCluster = new TestingCluster(new InstanceSpec(null, 2185, -1, -1, true, -1, -1, -1));
zkCluster.start();
BootstrapNodeInfo bootstrapNodeInfo = buildBootstrapNodeInfo();
CuratorFramework zkClient = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), buildDefaultRetryPolicy());
bootstrapNode = new BootstrapNode(bootstrapNodeInfo, zkClient);
bootstrapNode.start();
OperationsNodeInfo endpointNodeInfo = buildEndpointNodeInfo();
endpointNode = new OperationsNode(endpointNodeInfo, zkClient);
endpointNode.start();
kaaNodeInstance = kaaNodeInitializationService;
kaaNodeServerThread = new Thread(new Runnable() {
@Override
public void run() {
LOG.info("Kaa Node Started.");
kaaNodeInstance.start();
LOG.info("Kaa Node Stoped.");
}
});
kaaNodeServerThread.start();
Thread.sleep(3000);
kaaNodeServerStarted = true;
}
}
开发者ID:kaaproject,项目名称:kaa,代码行数:43,代码来源:TestCluster.java
示例17: checkStarted
import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
/**
* Start.
*
* @throws Exception the exception
*/
public static void checkStarted() throws Exception {
zkCluster = new TestingCluster(new InstanceSpec(null, EventServiceThriftTestIT.ZK_PORT, -1, -1, true, -1, -1, -1));
zkCluster.start();
LOG.info("ZK Cluster started");
OperationsNodeInfo endpointNodeInfo = buildOperationsNodeInfo();
CuratorFramework zkClient = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), buildDefaultRetryPolicy());
operationsNode = new OperationsNode(endpointNodeInfo, zkClient);
operationsNode.start();
}
开发者ID:kaaproject,项目名称:kaa,代码行数:16,代码来源:TestCluster.java
示例18: startTestCluster
import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Before
public void startTestCluster() throws Exception {
objectMapper = new ObjectMapper();
testingCluster = new TestingCluster(3);
testingCluster.start();
}
开发者ID:flipkart-incubator,项目名称:ranger,代码行数:7,代码来源:ServiceProviderBuilderTest.java
示例19: testMissedDelete
import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
@Test(enabled = false) // this test is very flakey - it needs to be re-written at some point
public void testMissedDelete() throws Exception
{
Timing timing = new Timing();
PathChildrenCache cache = null;
CuratorFramework client1 = null;
CuratorFramework client2 = null;
TestingCluster cluster = new TestingCluster(3);
try
{
cluster.start();
// client 1 only connects to 1 server
InstanceSpec client1Instance = cluster.getInstances().iterator().next();
client1 = CuratorFrameworkFactory.newClient(client1Instance.getConnectString(), 1000, 1000, new RetryOneTime(1));
cache = new PathChildrenCache(client1, "/test", true);
final BlockingQueue<PathChildrenCacheEvent.Type> events = Queues.newLinkedBlockingQueue();
PathChildrenCacheListener listener = new PathChildrenCacheListener()
{
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
{
events.add(event.getType());
}
};
cache.getListenable().addListener(listener);
client2 = CuratorFrameworkFactory.newClient(cluster.getConnectString(), 1000, 1000, new RetryOneTime(1));
client1.start();
client2.start();
cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
client2.create().creatingParentsIfNeeded().forPath("/test/node", "first".getBytes());
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
cluster.killServer(client1Instance);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_SUSPENDED);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_LOST);
client2.delete().forPath("/test/node");
client2.create().forPath("/test/node", "second".getBytes());
cluster.restartServer(client1Instance);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
Assert.assertEquals(events.poll(timing.milliseconds(), TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED); // "/test/node" is different - should register as updated
}
finally
{
CloseableUtils.closeQuietly(client1);
CloseableUtils.closeQuietly(client2);
CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(cluster);
}
}
开发者ID:apache,项目名称:curator,代码行数:58,代码来源:TestPathChildrenCacheInCluster.java
示例20: AbstractZookeeperClusterTest
import org.apache.curator.test.TestingCluster; //导入依赖的package包/类
public AbstractZookeeperClusterTest(final int clusterSize, final long testTime, final TimeUnit unit) {
timeout = new Timeout(testTime, unit);
testingCluster = new TestingCluster(clusterSize);
}
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:6,代码来源:AbstractZookeeperClusterTest.java
注:本文中的org.apache.curator.test.TestingCluster类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论