• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RecoveryPolicies类的典型用法和代码示例

java 2次浏览

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

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

示例1: createConnection

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
public static Connection createConnection(final ProcessContext context) throws IOException, TimeoutException {

        Config config = new Config();
        final String rabbitHost = context.getProperty(RABBITMQ_HOST).getValue();
        final int rabbitPort = context.getProperty(RABBITMQ_PORT).asInteger();
        final String rabbitVirtualHost = context.getProperty(RABBITMQ_VIRTUALHOST).getValue();
        final String rabbitUsername = context.getProperty(RABBITMQ_USERNAME).getValue();
        final String rabbitPassword = context.getProperty(RABBITMQ_PASSWORD).getValue();


        config = config.withRecoveryPolicy(RecoveryPolicies.recoverAlways())
                .withRetryPolicy(new RetryPolicy()
                        .withMaxAttempts(200)
                        .withInterval(Duration.seconds(1))
                        .withMaxDuration(Duration.minutes(5)));

        ConnectionOptions options = new ConnectionOptions()
                .withHost(rabbitHost)
                .withPort(rabbitPort)
                .withVirtualHost(rabbitVirtualHost)
                .withUsername(rabbitUsername)
                .withPassword(rabbitPassword);

        return Connections.create(options, config);
    }
 

开发者ID:MDL,
项目名称:nifi-rabbitmq-bundle,
代码行数:26,
代码来源:RabbitMQFactory.java

示例2: createAmqpConnection

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
public static Connection createAmqpConnection(final ExecutorService executor, Config config) throws IOException
{
    final ConnectionOptions options = new ConnectionOptions()
            .withConsumerExecutor(executor)
            .withPort(config.getInt("amqp.port"))
            .withHost(config.getString("amqp.host"))
            .withUsername(config.getString("amqp.user"))
            .withPassword(config.getString("amqp.pass"))
            .withVirtualHost(config.getString("amqp.vhost"));

    final net.jodah.lyra.config.Config c = new net.jodah.lyra.config.Config()
        .withRecoveryPolicy(RecoveryPolicies.recoverAlways())
        .withRetryPolicy(new RetryPolicy().withBackoff(Duration.seconds(1), Duration.seconds(30)));

    return Connections.create(options, c);
}
 

开发者ID:instaclick,
项目名称:amqp-to-hdfs-shovel,
代码行数:17,
代码来源:ShovelConfig.java

示例3: shouldThrowImmediatelyOnInvocationFailureWithNoRetryPolicy

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that a failed invocation results in the failure being rethrown immediately if retries
 * are not configured while recovery takes place in the background.
 */
public void shouldThrowImmediatelyOnInvocationFailureWithNoRetryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryNever()).withRecoveryPolicy(
      RecoveryPolicies.recoverAlways());
  performThrowableInvocation(retryableConnectionShutdownSignal());

  // Assert that the connection is recovered asynchronously
  assertTrue(connectionHandler.circuit.await(Duration.secs(1)));
  verifyCxnCreations(2);
  verifyChannelCreations(1, 2);
  verifyChannelCreations(2, 2);
  verifyConsumerCreations(1, 1, 2);
  verifyConsumerCreations(1, 2, 2);
  verifyConsumerCreations(2, 5, 2);
  verifyConsumerCreations(2, 6, 2);
  verifyInvocations(1);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:21,
代码来源:ConnectionInvocationTest.java

示例4: shouldOverrideGlobalConfig

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that channel specific configuration overrides global config.
 */
public void shouldOverrideGlobalConfig() throws Throwable {
  mockConnection();
  MockChannel mc = mockChannel(1);
  ((ConfigurableChannel) mc.proxy).withChannelRecoveryPolicy(RecoveryPolicies.recoverNever())
      .withChannelRecoveryPolicy(RecoveryPolicies.recoverNever());

  when(mc.delegate.basicConsume(anyString(), any(Consumer.class))).thenThrow(
      retryableChannelShutdownSignal());

  try {
    mc.proxy.basicConsume("foo", null);
    fail();
  } catch (Exception e) {
    verify(mc.delegate).basicConsume(anyString(), any(Consumer.class));
  }
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:20,
代码来源:ChannelConfigTest.java

示例5: shouldThrowOnChannelShutdownWithNoRetryPolicy

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that a failed invocation results in the failure being rethrown immediately if retries
 * are not configured while recovery takes place in the background.
 */
public void shouldThrowOnChannelShutdownWithNoRetryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryNever()).withRecoveryPolicy(
      RecoveryPolicies.recoverAlways());
  performThrowableInvocation(retryableChannelShutdownSignal());

  // Assert that the channel is recovered asynchronously
  assertTrue(mockChannel(1).channelHandler.circuit.await(Duration.secs(1)));
  verifyCxnCreations(1);
  verifyChannelCreations(1, 2);
  verifyChannelCreations(2, 1);
  verifyConsumerCreations(1, 1, 2);
  verifyConsumerCreations(1, 2, 2);
  verifyConsumerCreations(2, 5, 1);
  verifyConsumerCreations(2, 6, 1);
  verifyInvocations(1);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:21,
代码来源:ChannelInvocationTest.java

示例6: shouldThrowOnConnectionShutdownWithNoRetryPolicy

点赞 3

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a connection is shutdown and a retry policy
 * is not set, but the connection and channel should still be recovered.
 */
public void shouldThrowOnConnectionShutdownWithNoRetryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryNever()).withRecoveryPolicy(
      RecoveryPolicies.recoverAlways());
  performThrowableInvocation(retryableConnectionShutdownSignal());

  // Assert that the channel is recovered asynchronously
  assertTrue(mockChannel(1).channelHandler.circuit.await(Duration.secs(1)));
  verifyCxnCreations(2);
  verifyChannelCreations(1, 2);
  verifyChannelCreations(2, 2);
  verifyConsumerCreations(1, 1, 2);
  verifyConsumerCreations(1, 2, 2);
  verifyConsumerCreations(2, 5, 2);
  verifyConsumerCreations(2, 6, 2);
  verifyInvocations(1);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:21,
代码来源:ChannelInvocationTest.java

示例7: mockConnection

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
protected void mockConnection() throws IOException, TimeoutException {
  if (connectionFactory == null) {
    mockConnectionOnly();
    connectionFactory = mock(ConnectionFactory.class);
    when(connectionFactory.getVirtualHost()).thenReturn("/");
    when(connectionFactory.newConnection(any(ExecutorService.class), any(Address[].class), anyString()))
        .thenReturn(connection);
  }

  if (options == null)
    options = new ConnectionOptions().withHost("test-host");
  options.withConnectionFactory(connectionFactory);
  if (config == null)
    config =
        new Config().withRetryPolicy(
            RetryPolicies.retryAlways().withInterval(Duration.millis(10))).withRecoveryPolicy(
            RecoveryPolicies.recoverAlways());

  if (connectionHandler == null) {
    connectionHandler = new ConnectionHandler(options, config, Connection.class.getClassLoader());
    connectionProxy =
        (ConfigurableConnection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
            new Class<?>[] {ConfigurableConnection.class}, connectionHandler);
    connectionHandler.createConnection(connectionProxy);
    channels = new HashMap<Integer, MockChannel>();
  }
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:28,
代码来源:AbstractFunctionalTest.java

示例8: shouldThrowOnInvocationFailureWithNoRecoveryPolicy

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a connection is shutdown and a recovery
 * policy is not set.
 */
public void shouldThrowOnInvocationFailureWithNoRecoveryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryAlways()).withRecoveryPolicy(
      RecoveryPolicies.recoverNever());
  performThrowableInvocation(retryableConnectionShutdownSignal());
  verifyCxnCreations(1);
  verifyChannelCreations(1, 1);
  verifyChannelCreations(2, 1);
  verifyConsumerCreations(1, 1, 1);
  verifyConsumerCreations(1, 2, 1);
  verifyConsumerCreations(2, 5, 1);
  verifyConsumerCreations(2, 6, 1);
  verifyInvocations(1);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:18,
代码来源:ConnectionInvocationTest.java

示例9: shouldHandleRecoveryFailureFromChannelListener

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that a failure from a channel listener during recovery results in the channel being
 * recovered.
 */
public void shouldHandleRecoveryFailureFromChannelListener() throws Throwable {
  final AtomicBoolean shutdownCalled = new AtomicBoolean();
  config = new Config().withRetryPolicy(
      RetryPolicies.retryAlways().withInterval(Duration.millis(10)))
      .withRecoveryPolicy(RecoveryPolicies.recoverAlways())
      .withChannelListeners(new DefaultChannelListener() {
        @Override
        public void onRecovery(Channel channel) {
          if (!shutdownCalled.get() && channel == mockChannel(2).proxy) {
            ShutdownSignalException e = nonRetryableChannelShutdownSignal();
            shutdownCalled.set(true);
            callShutdownListener(mockChannel(2).channelHandler, e);
            throw e;
          }
        }
      });

  performRecovery(mockChannel(2).channelHandler, mockChannel(2).channelHandler, 0, 0);
  verifyCxnCreations(1);
  verifyChannelCreations(1, 1);
  verifyConsumerCreations(1, 1, 1);
  verifyConsumerCreations(1, 2, 1);

  verifyChannelCreations(2, 3);
  verifyConsumerCreations(2, 5, 2); // Only attempted once since first attempt fails
  verifyConsumerCreations(2, 6, 2);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:32,
代码来源:ChannelRecoveryTest.java

示例10: shouldThrowOnChannelShutdownWithNoRecoveryPolicy

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a channel is shutdown and a recovery policy
 * is not set.
 */
public void shouldThrowOnChannelShutdownWithNoRecoveryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryAlways()).withRecoveryPolicy(
      RecoveryPolicies.recoverNever());
  performThrowableInvocation(retryableChannelShutdownSignal());
  verifySingleInvocation();
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:11,
代码来源:ChannelInvocationTest.java

示例11: shouldThrowOnConnectionShutdownWithNoRecoveryPolicy

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a connection is shutdown and a recovery
 * policy is not set.
 */
public void shouldThrowOnConnectionShutdownWithNoRecoveryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryAlways()).withRecoveryPolicy(
      RecoveryPolicies.recoverNever());
  performThrowableInvocation(retryableConnectionShutdownSignal());
  verifySingleInvocation();
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:11,
代码来源:ChannelInvocationTest.java

示例12: shouldThrowOnConnectionShutdownWithNoCxnRecoveryPolicy

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a connection is shutdown and a connection
 * recovery policy is not set even when a channel recovery policy is set.
 */
public void shouldThrowOnConnectionShutdownWithNoCxnRecoveryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryAlways())
      .withConnectionRecoveryPolicy(RecoveryPolicies.recoverNever())
      .withChannelRecoveryPolicy(RecoveryPolicies.recoverAlways());
  performThrowableInvocation(retryableConnectionShutdownSignal());
  verifySingleInvocation();
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:12,
代码来源:ChannelInvocationTest.java

示例13: shouldThrowOnConnectionShutdownWithNoChannelRecoveryPolicy

点赞 2

import net.jodah.lyra.config.RecoveryPolicies; //导入依赖的package包/类
/**
 * Asserts that invocation failures are rethrown when a channel is shutdown and a connection
 * recovery policy is set but a channel recovery policy is not.
 */
public void shouldThrowOnConnectionShutdownWithNoChannelRecoveryPolicy() throws Throwable {
  config = new Config().withRetryPolicy(RetryPolicies.retryAlways())
      .withConnectionRecoveryPolicy(RecoveryPolicies.recoverAlways())
      .withChannelRecoveryPolicy(RecoveryPolicies.recoverNever());
  performThrowableInvocation(retryableConnectionShutdownSignal());
  verifyCxnCreations(2);
  verifyChannelCreations(1, 1);
  verifyChannelCreations(2, 1);
  verifyConsumerCreations(1, 1, 1);
  verifyConsumerCreations(1, 2, 1);
  verifyConsumerCreations(2, 5, 1);
  verifyConsumerCreations(2, 6, 1);
  verifyInvocations(1);
}
 

开发者ID:jhalterman,
项目名称:lyra,
代码行数:19,
代码来源:ChannelInvocationTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)