Package net.jodah.lyra.config

Examples of net.jodah.lyra.config.Config


  /**
   * Asserts that invocation failures are rethrown when a retry policy is not set.
   */
  public void shouldThrowOnInvocationFailureWithNoRetryPolicy() throws Throwable {
    config = new Config().withRetryPolicy(RetryPolicies.retryNever());
    connectionFactory = mock(ConnectionFactory.class);
    connection = mock(Connection.class);
    when(connectionFactory.newConnection(any(ExecutorService.class), any(Address[].class))).thenAnswer(
        failNTimes(3, new ConnectException("fail"), connection, connectionHandler));

View Full Code Here


    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);
View Full Code Here

   * 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) {
View Full Code Here

  /**
   * 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)));
View Full Code Here

  /**
   * 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);
View Full Code Here

            @Override
            public Object call() throws Exception {
              if ("createChannel".equals(method.getName())) {
                Channel channel = (Channel) Reflection.invoke(delegate, method, args);
                ChannelHandler channelHandler =
                    new ChannelHandler(ConnectionHandler.this, channel, new Config(config));
                Channel channelProxy =
                    (Channel) Proxy.newProxyInstance(Connection.class.getClassLoader(),
                        CHANNEL_TYPES, channelHandler);
                channelHandler.proxy = channelProxy;
                channels.put(Integer.valueOf(channel.getChannelNumber()).toString(), channelHandler);
View Full Code Here

  /**
   * 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)));
View Full Code Here

  /**
   * 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();
  }
View Full Code Here

  /**
   * 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)));
View Full Code Here

  /**
   * 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();
  }
View Full Code Here

TOP

Related Classes of net.jodah.lyra.config.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.