Package reactor.net

Examples of reactor.net.Reconnect


  public ListenableFuture<Void> connect(final TcpConnectionHandler<P> connectionHandler,
      final ReconnectStrategy reconnectStrategy) {

    Assert.notNull(reconnectStrategy, "ReconnectStrategy must not be null");

    Reconnect reconnect = new Reconnect() {
      @Override
      public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress address, int attempt) {
        return Tuple.of(address, reconnectStrategy.getTimeToNextAttempt(attempt));
      }
    };
View Full Code Here


    new TcpClientSpec<Buffer, Buffer>(NettyTcpClient.class)
        .env(env)
        .connect("localhost", abortServerPort + 3)
        .get()
        .open(new Reconnect() {
          @Override
          public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress currentAddress, int attempt) {
            switch (attempt) {
              case 1:
                totalDelay.addAndGet(100);
View Full Code Here

    final CountDownLatch reconnectionLatch = new CountDownLatch(1);
    new TcpClientSpec<Buffer, Buffer>(NettyTcpClient.class)
        .env(env)
        .connect("localhost", abortServerPort)
        .get()
        .open(new Reconnect() {
          @Override
          public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress currentAddress, int attempt) {
            reconnectionLatch.countDown();
            return null;
          }
View Full Code Here

@Ignore
public class IncrementalBackoffReconnectTest {
    @Test
    public void testDefaultReconnect() {
        Reconnect rec = new IncrementalBackoffReconnectSpec().get();

        InetSocketAddress a1 = new InetSocketAddress("129.168.0.1",1001);
        Tuple2<InetSocketAddress, Long> t1 = rec.reconnect(a1, 0);

        assertEquals(IncrementalBackoffReconnectSpec.DEFAULT_INTERVAL,t1.getT2().longValue());
        assertEquals(a1,t1.getT1());

        InetSocketAddress a2 = new InetSocketAddress("129.168.0.1",1001);
        Tuple2<InetSocketAddress, Long> t2 = rec.reconnect(a1, 0);

        assertEquals(IncrementalBackoffReconnectSpec.DEFAULT_INTERVAL,t2.getT2().longValue());
        assertEquals(a2,t2.getT1());
    }
View Full Code Here

    @Test
    public void testReconnectIntervalWithCap() {
        InetSocketAddress addr1 = new InetSocketAddress("129.168.0.1",1001);

        Reconnect rec = new IncrementalBackoffReconnectSpec()
            .address(addr1)
            .interval(5000)
            .maxInterval(10000)
            .multiplier(2)
            .get();

        assertEquals(    0L,(long)rec.reconnect(addr1,0).getT2());
        assertEquals( 5000L,(long)rec.reconnect(addr1,1).getT2());
        assertEquals(10000L,(long)rec.reconnect(addr1,2).getT2());
        assertEquals(10000L,(long)rec.reconnect(addr1,3).getT2());
    }
View Full Code Here

    public void testRoundRobinAddresses() {
        InetSocketAddress addr1 = new InetSocketAddress("129.168.0.1",1001);
        InetSocketAddress addr2 = new InetSocketAddress("129.168.0.2",1002);
        InetSocketAddress addr3 = new InetSocketAddress("129.168.0.3",1003);

        Reconnect rec = new IncrementalBackoffReconnectSpec()
            .address(addr1)
            .address(addr2)
            .address(addr3)
            .get();

        assertEquals(addr1,rec.reconnect(addr1,0).getT1());
        assertEquals(addr2,rec.reconnect(addr2,1).getT1());
        assertEquals(addr3,rec.reconnect(addr3,2).getT1());
    }
View Full Code Here

    @Override
    public Reconnect get() {
        final Supplier<InetSocketAddress> endpoints =
            Suppliers.roundRobin(addresses.toArray(new InetSocketAddress[]{}));

        return new Reconnect() {
            public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress currentAddress, int attempt) {
                Tuple2<InetSocketAddress, Long> rv = null;
                synchronized(IncrementalBackoffReconnectSpec.this) {
                    if(!addresses.isEmpty()) {
                        if(IncrementalBackoffReconnectSpec.this.maxAttempts == -1       ||
View Full Code Here

TOP

Related Classes of reactor.net.Reconnect

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.