本文整理匯總了Java中org.apache.curator.test.TestingServer類的典型用法代碼示例。如果您正苦於以下問題:Java TestingServer類的具體用法?Java TestingServer怎麽用?Java TestingServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TestingServer類屬於org.apache.curator.test包,在下文中一共展示了TestingServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testServer
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
public void testServer(){
try {
TestingServer server=new TestingServer(2181,new File("/"));
server.start();
CuratorFramework curatorFramework = CuratorFrameworkFactory.
builder().
connectString(server.getConnectString()).
sessionTimeoutMs(1000).
retryPolicy(new RetryNTimes(3, 1000)).
build();
curatorFramework.start();
System.out.println(curatorFramework.getChildren().forPath("/"));
curatorFramework.close();
server.stop();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例2: getSingularityConfigurationForTestingServer
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
private static SingularityConfiguration getSingularityConfigurationForTestingServer(final TestingServer ts) {
SingularityConfiguration config = new SingularityConfiguration();
config.setLoadBalancerUri("test");
MesosConfiguration mc = new MesosConfiguration();
mc.setDefaultCpus(1);
mc.setDefaultMemory(128);
config.setMesosConfiguration(mc);
config.setSmtpConfiguration(new SMTPConfiguration());
ZooKeeperConfiguration zookeeperConfiguration = new ZooKeeperConfiguration();
zookeeperConfiguration.setQuorum(ts.getConnectString());
config.setZooKeeperConfiguration(zookeeperConfiguration);
config.setConsiderTaskHealthyAfterRunningForSeconds(0);
return config;
}
示例3: setUp
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@BeforeClass
public static void setUp() throws Exception
{
int port = 9000;
clientUrl = new URLImpl(Constants.PROTOCOL_LIGHT, "127.0.0.1", 0, service);
clientUrl.addParameter("group", "aaa");
serviceUrl = new URLImpl(Constants.PROTOCOL_LIGHT, "127.0.0.1", 8001, service);
serviceUrl.addParameter("group", "aaa");
InstanceSpec spec = new InstanceSpec(null, port, -1, -1, true, 1,-1, -1,new HashMap<>());
zookeeper = new TestingServer(spec, true);
client = (ZooKeeperClient)SingletonServiceFactory.getBean(ZooKeeperClient.class);
registry = (ZooKeeperRegistry)SingletonServiceFactory.getBean(Registry.class);
System.out.println("client = " + client + " registry = " + registry);
}
示例4: setup
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@BeforeClass
public static void setup() {
actorSystem = AkkaUtils.createDefaultActorSystem();
try {
zkServer = new TestingServer();
zkServer.start();
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Could not start ZooKeeper testing cluster.");
}
YARN_CONFIGURATION.set(YarnTestBase.TEST_CLUSTER_NAME_KEY, "flink-yarn-tests-ha");
YARN_CONFIGURATION.set(YarnConfiguration.RM_AM_MAX_ATTEMPTS, "" + numberApplicationAttempts);
startYARNWithConfig(YARN_CONFIGURATION);
}
示例5: startZookeeper
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void startZookeeper() throws Exception {
zkTestServer = new TestingServer(2181);
cli = CuratorFrameworkFactory.newClient(zkTestServer.getConnectString(), new RetryOneTime(2000));
cli.start();
discovery = ServiceDiscoveryBuilder.builder(String.class)
.client(cli)
.basePath("/discovery")
.watchInstances(true)
.build();
discovery.start();
vertx = Vertx.vertx();
sd = io.vertx.servicediscovery.ServiceDiscovery.create(vertx);
}
示例6: startZooKeeper
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void startZooKeeper() throws Exception {
testingServer = new TestingServer(true);
File serverYAMLFile = new File(SCHEMA_REGISTRY_TEST_CONFIGURATION.getServerYAMLPath());
String fileContent = FileUtils.readFileToString(serverYAMLFile,"UTF-8" );
File registryConfigFile = File.createTempFile("ha-", ".yaml");
registryConfigFile.deleteOnExit();
try (FileWriter writer = new FileWriter(registryConfigFile)) {
IOUtils.write(fileContent.replace("__zk_connect_url__", testingServer.getConnectString()), writer);
}
SchemaRegistryTestConfiguration testConfiguration = new SchemaRegistryTestConfiguration(registryConfigFile.getAbsolutePath(), SCHEMA_REGISTRY_TEST_CONFIGURATION.getClientYAMLPath());
List<SchemaRegistryTestServerClientWrapper> schemaRegistryServers = new ArrayList<>();
for (int i = 1; i < 4; i++) {
SchemaRegistryTestServerClientWrapper server = new SchemaRegistryTestServerClientWrapper(testConfiguration);
schemaRegistryServers.add(server);
server.startTestServer();
}
registryServers = Collections.unmodifiableList(schemaRegistryServers);
}
示例7: before
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void before() throws Exception {
zkTestServer = new TestingServer(2182);
zkTestServer.start();
String registerUrl = zkTestServer.getConnectString();
client = RegisterHolder.getClient(registerUrl);
servicePath = joinNodePath(namespace, serviceNode);
groupPath = joinNodePath(namespace, groupNode);
group_1_path = joinNodePath(namespace, groupNode, "group_1");
group_2_path = joinNodePath(namespace, groupNode, "group_2");
groupProxyPath = joinNodePath(namespace, proxyNode, groupProxyNode);
ipProxyPath = joinNodePath(namespace, proxyNode, ipProxyNode);
balancePath = joinNodePath(namespace, balanceNode);
client.create().forPath(servicePath);
client.create().forPath(groupPath);
client.create().forPath(group_1_path);
client.create().forPath(group_2_path);
client.create().forPath(groupProxyPath);
client.create().forPath(ipProxyPath);
client.create().forPath(balancePath);
}
示例8: beforeAll
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void beforeAll() throws Exception {
server = new TestingServer();
server.start();
Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
when(mockCapabilities.supportsNamedVips()).thenReturn(true);
taskFactory = new CassandraDaemonTask.Factory(mockCapabilities);
configurationFactory = new ConfigurationFactory<>(
MutableSchedulerConfiguration.class,
BaseValidator.newValidator(),
Jackson.newObjectMapper()
.registerModule(new GuavaModule())
.registerModule(new Jdk8Module()),
"dw");
connectString = server.getConnectString();
}
示例9: setUp
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
LifeCycleRegistry lifeCycleRegistry = mock(LifeCycleRegistry.class);
_queueService = mock(QueueService.class);
_jobHandlerRegistry = new DefaultJobHandlerRegistry();
_jobStatusDAO = new InMemoryJobStatusDAO();
_testingServer = new TestingServer();
_curator = CuratorFrameworkFactory.builder()
.connectString(_testingServer.getConnectString())
.retryPolicy(new RetryNTimes(3, 100))
.build();
_curator.start();
_service = new DefaultJobService(
lifeCycleRegistry, _queueService, "testqueue", _jobHandlerRegistry, _jobStatusDAO, _curator,
1, Duration.ZERO, 100, Duration.standardHours(1));
_store = new InMemoryDataStore(new MetricRegistry());
_dataStoreResource = new DataStoreResource1(_store, new DefaultDataStoreAsync(_store, _service, _jobHandlerRegistry));
}
示例10: setUp
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
LifeCycleRegistry lifeCycleRegistry = mock(LifeCycleRegistry.class);
_queueService = mock(QueueService.class);
_jobHandlerRegistry = new DefaultJobHandlerRegistry();
_jobStatusDAO = new InMemoryJobStatusDAO();
_testingServer = new TestingServer();
_curator = CuratorFrameworkFactory.builder()
.connectString(_testingServer.getConnectString())
.retryPolicy(new RetryNTimes(3, 100))
.build();
_curator.start();
_service = new DefaultJobService(
lifeCycleRegistry, _queueService, "testqueue", _jobHandlerRegistry, _jobStatusDAO, _curator,
1, Duration.ZERO, 100, Duration.standardHours(1));
}
示例11: init
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void init() throws Exception {
testingServer = new TestingServer();
String testConnectString = testingServer.getConnectString();
String testHost = testConnectString.split(":")[0];
int testPort = testingServer.getPort();
zkBinLogStateConfig = new ZkBinLogStateConfig.Builder("my-test-spout")
.servers(Lists.newArrayList(testHost))
.port(testPort)
.sessionTimeOutInMs(10000)
.retryTimes(5)
.sleepMsBetweenRetries(50)
.connectionTimeOutInMs(10000)
.build();
ZkConf zkConf = new ZkConf(new HashMap<String, Object>(), zkBinLogStateConfig);
zkClient = new ZkClient(zkConf);
zkClient.start();
}
示例12: testAddArtifact
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Test
public void testAddArtifact() throws Exception
{
TestingServer testingServer = new TestingServer();
index.startClient(testingServer.getConnectString());
try
{
// Add an artifact.
index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact());
// Is there an artifact?
Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey()));
// Get the artifact.
assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey()));
}
finally
{
CloseableUtils.closeQuietly(testingServer);
}
}
示例13: before
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void before() throws Exception {
testingServer = new TestingServer();
config = new Configuration();
config.setString(HighAvailabilityOptions.HA_MODE, "zookeeper");
config.setString(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM, testingServer.getConnectString());
CuratorFramework client = ZooKeeperUtils.startCuratorFramework(config);
highAvailabilityServices = new ZooKeeperHaServices(
client,
TestingUtils.defaultExecutor(),
config,
new VoidBlobStore());
}
示例14: setup
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
@Before
public void setup() throws Exception {
while(this.server == null) {
try {
this.server = new TestingServer();
} catch (BindException var2) {
System.err.println("Getting bind exception - retrying to allocate server");
this.server = null;
}
}
}
示例15: main
import org.apache.curator.test.TestingServer; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
final FakeLimitedResource resource = new FakeLimitedResource();
ExecutorService service = Executors.newFixedThreadPool(QTY);
final TestingServer server = new TestingServer();
try {
for (int i = 0; i < QTY; ++i) {
final int index = i;
Callable<Void> task = new Callable<Void>() {
@Override
public Void call() throws Exception {
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3));
try {
client.start();
final ExampleClientThatLocks example = new ExampleClientThatLocks(client, PATH, resource, "Client " + index);
for (int j = 0; j < REPETITIONS; ++j) {
example.doWork(10, TimeUnit.SECONDS);
}
} catch (Throwable e) {
e.printStackTrace();
} finally {
CloseableUtils.closeQuietly(client);
}
return null;
}
};
service.submit(task);
}
service.shutdown();
service.awaitTermination(10, TimeUnit.MINUTES);
} finally {
CloseableUtils.closeQuietly(server);
}
}