• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RetryUntilElapsed类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: increment

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
public void increment() throws Exception {
	int tempoMaximoDeTentativasMilissegundos = 1000;
	int intervaloEntreTentativasMilissegundos = 100;
	try {
		RetryPolicy rp = new RetryUntilElapsed(tempoMaximoDeTentativasMilissegundos, 
				intervaloEntreTentativasMilissegundos);
		this.counter = new DistributedAtomicLong(this.client,
                this.counterPath,
                rp);
		logger.debug("## INCREMENT WILL BEGIN");
		if (this.counter.get().succeeded()) {
			logger.debug("## INCREMENT GET COUNTER (BEFORE): " + this.counter.get().postValue());
			if(this.counter.increment().succeeded()) {
				logger.debug("## INCREMENT COUNTER AFTER: " + this.counter.get().postValue());
			}
		}
		this.counter.increment();			
	}
	catch(Exception ex) {
		logger.error("********* INCREMENT COUNTER ERROR: " + ex.getMessage());
	}

}
 
开发者ID:cleuton,项目名称:servkeeper,代码行数:24,代码来源:Increment.java


示例2: init

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Override
public void init() throws IOException {
	logger.info("Initializing Zookeeper storage: {}", connectionString);

	curator = CuratorFrameworkFactory.newClient(
			connectionString, sessionTimeout, connectionTimeout,
			new RetryUntilElapsed(retryDuration, retryInterval)
	);
	curator.start();
	initialized = true;
	// Strip slash suffixes
	this.root = PathUtil.stripPostSlash(root);

	try {
		ZKPaths.mkdirs(curator.getZookeeperClient().getZooKeeper(), ZKPaths.makePath(root, type));
	} catch (Exception e) {
		throw new IOException(e);
	}
}
 
开发者ID:turn,项目名称:sorcerer,代码行数:20,代码来源:ZookeeperStatusStorage.java


示例3: registerZK

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
public void registerZK() {
  LOG.info("Registring Operations Server in ZK {}:{}", thriftHost, thriftPort);
  OperationsNodeInfo nodeInfo = new OperationsNodeInfo();
  ByteBuffer keyData = ByteBuffer.wrap(new byte[]{45, 45, 45, 45, 45});
  ConnectionInfo connectionInfo = new ConnectionInfo(thriftHost, thriftPort, keyData);
  nodeInfo.setConnectionInfo(connectionInfo);
  nodeInfo.setLoadInfo(new LoadInfo(1, 1.0));
  nodeInfo.setTransports(new ArrayList<TransportMetaData>());
  String zkHostPortList = "localhost:" + ZK_PORT;
  CuratorFramework zkClient = CuratorFrameworkFactory.newClient(zkHostPortList, new RetryUntilElapsed(3000, 1000));
  operationsNode = new OperationsNode(nodeInfo, zkClient);
  try {
    operationsNode.start();
    eventService.setZkNode(operationsNode);
    LOG.info("Operations Server {}:{} Zk node set in Config", thriftHost, thriftPort);
  } catch (Exception e) {
    LOG.error("Exception: ", e);
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:20,代码来源:EventServiceThriftTestIT.java


示例4: startZooKeeper

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void startZooKeeper() throws Exception {
    zkServer = new TestingServer(new InstanceSpec(
            zkDataDir.newFolder(), -1, -1, -1, true, -1, -1, -1), true);
    curator = CuratorFrameworkFactory.newClient(zkServer.getConnectString(),
                                                new RetryUntilElapsed(10000, 100));
    curator.start();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:9,代码来源:ReplicatedLoginAndLogoutTest.java


示例5: alpha

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void alpha() throws Exception {
    zkServer = new TestingServer(PORT);

    zkServer.start();
    client = CuratorFrameworkFactory.newClient(CONNECT_STRING, new RetryUntilElapsed(1, 250));
    client.start();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:9,代码来源:ZooKeeperLockHandlerTest.java


示例6: createCounter

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
public void createCounter(String path) throws Exception {
	int tempoMaximoDeTentativasMilissegundos = 1000;
	int intervaloEntreTentativasMilissegundos = 100;
	this.counterPath = path;
	RetryPolicy rp = new RetryUntilElapsed(tempoMaximoDeTentativasMilissegundos, 
			intervaloEntreTentativasMilissegundos);
	this.counter = new DistributedAtomicLong(this.curatorFramework,
               this.counterPath,
               rp);
	this.counter.initialize((long) 0);
}
 
开发者ID:cleuton,项目名称:servkeeper,代码行数:12,代码来源:ZookeeperWrapper.java


示例7: testDeserializeRetryUntilElapsed

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Test
public void testDeserializeRetryUntilElapsed() {
    ZooKeeperConfiguration config = parse(ImmutableMap.of("retryPolicy",
            ImmutableMap.builder()
                    .put("type", "untilElapsed")
                    .put("maxElapsedTimeMs", 1000)
                    .put("sleepMsBetweenRetries", 50)
                    .build()));
    assertTrue(config.getRetryPolicy().get() instanceof RetryUntilElapsed);
}
 
开发者ID:bazaarvoice,项目名称:curator-extensions,代码行数:11,代码来源:ZooKeeperConfigurationTest.java


示例8: run

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Override
public void run() {
  while (true) {
    List<String> copy;
    synchronized (paths) {
      copy = Lists.newArrayList(paths);
      paths.clear();
    }

    // merge additions
    Map<String, AtomicLong> mutations = Maps.newHashMap();
    for (String path : copy) {
      if (mutations.containsKey(path)) {
        mutations.get(path).incrementAndGet();
      } else {
        mutations.put(path, new AtomicLong(1));
      }
    }
    for (Map.Entry<String, AtomicLong> entry : mutations.entrySet()) {
      try {
        DistributedAtomicLong dal = new DistributedAtomicLong(client, entry.getKey(),
          new RetryUntilElapsed((int) TimeUnit.MINUTES.toMillis(5), (int) TimeUnit.MILLISECONDS.toMillis(25)));
        AtomicValue<Long> result = dal.add(entry.getValue().get());
        if (!result.succeeded()) {
          LOG.warn("Counter updates are failing and we've exhausted retry - counts will be wrong");
        }
      } catch (Exception e) {
        LOG.warn("Failed to update DALs during flush - counts will be wrong", e);
      }
    }
    try {
      Thread.sleep(flushFrequencyMsecs); // not a true time of course
    } catch (InterruptedException e1) {
      break; // really?
    }
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:38,代码来源:BatchingDalWrapper.java


示例9: alpha

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void alpha() throws Exception {
    client = CuratorFrameworkFactory.newClient(CONNECT_STRING, new RetryUntilElapsed(1, 250));
    client.start();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:6,代码来源:ZooKeeperLockHandlerIntegrationTest.java


示例10: loadAndPersistConfiguration

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Test
public void loadAndPersistConfiguration() throws Exception {
    final String configFilePath = Resources.getResource("scheduler.yml").getFile();
    MutableSchedulerConfiguration mutableConfig = configurationFactory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            configFilePath);
    final CassandraSchedulerConfiguration original  = mutableConfig.createConfig();
    final CuratorFrameworkConfig curatorConfig = mutableConfig.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    StateStore stateStore = new CuratorStateStore(
            original.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            original.getServiceConfig().getName(),
            connectString,
            original,
            new ConfigValidator(),
            stateStore);
    ConfigurationManager manager = new ConfigurationManager(taskFactory, configurationManager);
    CassandraSchedulerConfiguration targetConfig = (CassandraSchedulerConfiguration)configurationManager.getTargetConfig();
    assertEquals("cassandra", original.getServiceConfig().getName());
    assertEquals("cassandra-role", original.getServiceConfig().getRole());
    assertEquals("cassandra-cluster", original.getServiceConfig().getCluster());
    assertEquals("cassandra-principal",
            original.getServiceConfig().getPrincipal());
    assertEquals("", original.getServiceConfig().getSecret());

    manager.start();

    assertEquals(original.getCassandraConfig(), targetConfig.getCassandraConfig());
    assertEquals(original.getExecutorConfig(), targetConfig.getExecutorConfig());
    assertEquals(original.getServers(), targetConfig.getServers());
    assertEquals(original.getSeeds(), targetConfig.getSeeds());
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:47,代码来源:ConfigurationManagerTest.java


示例11: serializeDeserializeExecutorConfig

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Test
public void serializeDeserializeExecutorConfig() throws Exception {
    MutableSchedulerConfiguration mutable = configurationFactory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());
    final CassandraSchedulerConfiguration original = mutable.createConfig();
    final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig();

    mutable.setCassandraConfig(
            mutable.getCassandraConfig()
                    .mutable().setJmxPort(8000).setCpus(0.6).setMemoryMb(10000).build());

    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    StateStore stateStore = new CuratorStateStore(
            original.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);

    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
                    original.getServiceConfig().getName(),
                    connectString,
                    original,
                    new ConfigValidator(),
                    stateStore);

    configurationManager.store(original);
    ConfigurationManager manager = new ConfigurationManager(taskFactory, configurationManager);
    CassandraSchedulerConfiguration targetConfig =
            (CassandraSchedulerConfiguration)configurationManager.getTargetConfig();

    ExecutorConfig expectedExecutorConfig = new ExecutorConfig(
            "export LD_LIBRARY_PATH=$MESOS_SANDBOX/libmesos-bundle/lib:$LD_LIBRARY_PATH && export MESOS_NATIVE_JAVA_LIBRARY=$(ls $MESOS_SANDBOX/libmesos-bundle/lib/libmesos-*.so) && ./executor/bin/cassandra-executor server executor/conf/executor.yml",
            new ArrayList<>(),
            0.1,
            768,
            512,
            9000,
            "./jre",
            URI.create("https://downloads.mesosphere.com/java/jre-8u121-linux-x64.tar.gz"),
            URI.create("https://s3-us-west-2.amazonaws.com/cassandra-framework-dev/testing/executor.zip"),
            URI.create("https://s3-us-west-2.amazonaws.com/cassandra-framework-dev/testing/apache-cassandra-2.2.5-bin.tar.gz"),
            URI.create("http://downloads.mesosphere.com/libmesos-bundle/libmesos-bundle-1.8.8-1.0.3-rc1-1.tar.gz"),
            false);

    manager.start();

    assertEquals(original.getCassandraConfig(), targetConfig.getCassandraConfig());

    assertEquals(expectedExecutorConfig, targetConfig.getExecutorConfig());

    manager.stop();
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:64,代码来源:ConfigurationManagerTest.java


示例12: failOnBadServersCount

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Test
public void failOnBadServersCount() throws Exception {
    MutableSchedulerConfiguration mutable = configurationFactory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());
    CassandraSchedulerConfiguration originalConfig = mutable.createConfig();
    final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    StateStore stateStore = new CuratorStateStore(
            originalConfig.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            originalConfig.getServiceConfig().getName(),
            connectString,
            originalConfig,
            new ConfigValidator(),
            stateStore);
    ConfigurationManager manager = new ConfigurationManager(taskFactory, configurationManager);
    CassandraSchedulerConfiguration targetConfig = (CassandraSchedulerConfiguration)configurationManager.getTargetConfig();

    manager.start();

    assertEquals(originalConfig.getCassandraConfig(), targetConfig.getCassandraConfig());
    assertEquals(originalConfig.getExecutorConfig(), targetConfig.getExecutorConfig());
    assertEquals(originalConfig.getServers(), targetConfig.getServers());
    assertEquals(originalConfig.getSeeds(), targetConfig.getSeeds());

    manager.stop();

    int updatedServers = originalConfig.getServers() - 1;
    mutable.setServers(updatedServers);

    configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            originalConfig.getServiceConfig().getName(),
            connectString,
            mutable.createConfig(),
            new ConfigValidator(),
            stateStore);
    manager = new ConfigurationManager(taskFactory, configurationManager);

    manager.start();

    assertEquals(1, configurationManager.getErrors().size());
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:58,代码来源:ConfigurationManagerTest.java


示例13: failOnBadSeedsCount

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Test
public void failOnBadSeedsCount() throws Exception {
    MutableSchedulerConfiguration mutableSchedulerConfiguration = configurationFactory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());
    CassandraSchedulerConfiguration originalConfig = mutableSchedulerConfiguration.createConfig();
    final CuratorFrameworkConfig curatorConfig = mutableSchedulerConfiguration.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    StateStore stateStore = new CuratorStateStore(
            originalConfig.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    DefaultConfigurationManager configurationManager
            = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            originalConfig.getServiceConfig().getName(),
            connectString,
            originalConfig,
            new ConfigValidator(),
            stateStore);
    ConfigurationManager manager = new ConfigurationManager(taskFactory, configurationManager);
    CassandraSchedulerConfiguration targetConfig = (CassandraSchedulerConfiguration)configurationManager.getTargetConfig();

    manager.start();

    assertEquals(originalConfig.getCassandraConfig(), targetConfig.getCassandraConfig());
    assertEquals(originalConfig.getExecutorConfig(), targetConfig.getExecutorConfig());
    assertEquals(originalConfig.getServers(), targetConfig.getServers());
    assertEquals(originalConfig.getSeeds(), targetConfig.getSeeds());

    manager.stop();

    int updatedSeeds = originalConfig.getServers() + 1;
    mutableSchedulerConfiguration.setSeeds(updatedSeeds);

    configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            originalConfig.getServiceConfig().getName(),
            connectString,
            mutableSchedulerConfiguration.createConfig(),
            new ConfigValidator(),
            stateStore);
    manager = new ConfigurationManager(taskFactory, configurationManager);
    manager.start();
    assertEquals(1, configurationManager.getErrors().size());
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:56,代码来源:ConfigurationManagerTest.java


示例14: beforeEach

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Before
public void beforeEach() throws Exception {
    server = new TestingServer();

    server.start();

    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");

    config = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());

    ServiceConfig initial = config.createConfig().getServiceConfig();

    final CassandraSchedulerConfiguration targetConfig = config.createConfig();
    clusterTaskConfig = targetConfig.getClusterTaskConfig();

    final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    stateStore = new CuratorStateStore(
            targetConfig.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build());
    identity = new IdentityManager(
            initial,stateStore);

    identity.register("test_id");

    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            config.createConfig().getServiceConfig().getName(),
            server.getConnectString(),
            config.createConfig(),
            new ConfigValidator(),
            stateStore);

    Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
    when(mockCapabilities.supportsNamedVips()).thenReturn(true);
    configuration = new ConfigurationManager(
            new CassandraDaemonTask.Factory(mockCapabilities),
            configurationManager);

    cassandraState = new CassandraState(
            configuration,
            clusterTaskConfig,
            stateStore);
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:66,代码来源:CassandraStateTest.java


示例15: beforeAll

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void beforeAll() throws Exception {

    server = new TestingServer();

    server.start();

    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");

    config = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());

    final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    stateStore = new CuratorStateStore(
            config.createConfig().getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);

    final CassandraSchedulerConfiguration configuration = config.createConfig();
    try {
        final ConfigValidator configValidator = new ConfigValidator();
        final DefaultConfigurationManager defaultConfigurationManager =
                new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
                configuration.getServiceConfig().getName(),
                server.getConnectString(),
                configuration,
                configValidator,
                stateStore);
        Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
        when(mockCapabilities.supportsNamedVips()).thenReturn(true);
        configurationManager = new ConfigurationManager(
                new CassandraDaemonTask.Factory(mockCapabilities),
                defaultConfigurationManager);
    } catch (ConfigStoreException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:57,代码来源:ServiceConfigResourceTest.java


示例16: beforeAll

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void beforeAll() throws Exception {
    server = new TestingServer();
    server.start();
    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");
    MutableSchedulerConfiguration mutable = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());
    config = mutable.createConfig();

    final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    StateStore stateStore = new CuratorStateStore(
            config.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            config.getServiceConfig().getName(),
            server.getConnectString(),
            config,
            new ConfigValidator(),
            stateStore);
    config = (CassandraSchedulerConfiguration) configurationManager.getTargetConfig();
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:43,代码来源:ConfigurationResourceTest.java


示例17: beforeEach

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    server = new TestingServer();
    server.start();

    Capabilities mockCapabilities = mock(Capabilities.class);
    when(mockCapabilities.supportsNamedVips()).thenReturn(true);
    taskFactory = new CassandraDaemonTask.Factory(mockCapabilities);

    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");

    config = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());

    final CassandraSchedulerConfiguration targetConfig = config.createConfig();
    clusterTaskConfig = targetConfig.getClusterTaskConfig();

    final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    stateStore = new CuratorStateStore(
            targetConfig.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build());

    configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
                    config.createConfig().getServiceConfig().getName(),
                    server.getConnectString(),
                    config.createConfig(),
                    new ConfigValidator(),
                    stateStore);

    cassandraState = new CassandraState(
            new ConfigurationManager(taskFactory, configurationManager),
            clusterTaskConfig,
            stateStore);
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:57,代码来源:CassandraDaemonStepTest.java


示例18: beforeAll

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@BeforeClass
public static void beforeAll() throws Exception {

    server = new TestingServer();

    server.start();

    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");

    MutableSchedulerConfiguration mutable = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());

    config = mutable.createConfig();
    ServiceConfig initial = config.getServiceConfig();

    clusterTaskConfig = config.getClusterTaskConfig();

    final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    stateStore = new CuratorStateStore(
            config.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build());

    identity = new IdentityManager(
            initial,stateStore);

    identity.register("test_id");

    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
            config.getServiceConfig().getName(),
            server.getConnectString(),
            config,
            new ConfigValidator(),
            stateStore);
    Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
    when(mockCapabilities.supportsNamedVips()).thenReturn(true);
    configuration = new ConfigurationManager(
            new CassandraDaemonTask.Factory(mockCapabilities),
            configurationManager);

    provider = new ClusterTaskOfferRequirementProvider();
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:64,代码来源:ClusterTaskOfferRequirementProviderTest.java


示例19: beforeEach

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    server = new TestingServer();
    server.start();

    final ConfigurationFactory<MutableSchedulerConfiguration> factory =
            new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper().registerModule(
                            new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");

    config = factory.build(
            new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new EnvironmentVariableSubstitutor(false, true)),
            Resources.getResource("scheduler.yml").getFile());

    ServiceConfig initial = config.createConfig().getServiceConfig();

    final CassandraSchedulerConfiguration targetConfig = config.createConfig();
    clusterTaskConfig = targetConfig.getClusterTaskConfig();

    final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig();
    RetryPolicy retryPolicy =
            (curatorConfig.getOperationTimeout().isPresent()) ?
                    new RetryUntilElapsed(
                            curatorConfig.getOperationTimeoutMs()
                                    .get()
                                    .intValue()
                            , (int) curatorConfig.getBackoffMs()) :
                    new RetryForever((int) curatorConfig.getBackoffMs());

    stateStore = new CuratorStateStore(
            targetConfig.getServiceConfig().getName(),
            server.getConnectString(),
            retryPolicy);
    stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build());
    identity = new IdentityManager(initial,stateStore);

    identity.register("test_id");

    DefaultConfigurationManager configurationManager =
            new DefaultConfigurationManager(CassandraSchedulerConfiguration.class,
                    config.createConfig().getServiceConfig().getName(),
                    server.getConnectString(),
                    config.createConfig(),
                    new ConfigValidator(),
                    stateStore);

    Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
    when(mockCapabilities.supportsNamedVips()).thenReturn(true);
    configuration = new ConfigurationManager(
            new CassandraDaemonTask.Factory(mockCapabilities),
            configurationManager);

    cassandraState = new CassandraState(
            configuration,
            clusterTaskConfig,
            stateStore);

    taskFactory = new CassandraTaskFactory(executorDriver);
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:67,代码来源:CassandraTaskFactoryTest.java


示例20: build

import org.apache.curator.retry.RetryUntilElapsed; //导入依赖的package包/类
@Override
RetryPolicy build(Config config) {
  return new RetryUntilElapsed(
      getMillis(config, "maxElapsedDuration"), getMillis(config, "sleepDuration"));
}
 
开发者ID:xjdr,项目名称:xio,代码行数:6,代码来源:ZooKeeperClientFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebServicesTestUtils类代码示例发布时间:2022-05-22
下一篇:
Java EnvironmentUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap