Package com.netflix.astyanax.test

Examples of com.netflix.astyanax.test.TestOperation


                try {
                    Assert.assertEquals(1,     pool.getActiveConnectionCount());
                    Assert.assertEquals(false, pool.isReconnecting());
                    Assert.assertEquals(0,     pool.getIdleConnectionCount());
                   
                    connection.execute(new TestOperation() {
                        @Override
                        public String execute(TestClient client, ConnectionContext context) throws ConnectionException {
                            throw new TimeoutException("Test");
                        }
                    });
                   
                    Assert.fail();
                }
                catch (Throwable t) {
                }
                finally {
                    pool.returnConnection(connection);
                }
                Assert.assertEquals(i+1,     pool.getErrorsSinceLastSuccess());
                Assert.assertEquals(0,     pool.getActiveConnectionCount());
                Assert.assertEquals(false, pool.isReconnecting());
                Assert.assertEquals(0,     pool.getIdleConnectionCount());
            }
           
            Connection<TestClient> connection = pool.borrowConnection(WAIT_TIMEOUT);
            try {
                Assert.assertEquals(1,     pool.getActiveConnectionCount());
                Assert.assertEquals(false, pool.isReconnecting());
                Assert.assertEquals(0,     pool.getIdleConnectionCount());
               
                connection.execute(new TestOperation() {
                    @Override
                    public String execute(TestClient client, ConnectionContext context) throws ConnectionException {
                        throw new TimeoutException("Test");
                    }
                });
View Full Code Here


//            .withFutures(100, TimeUnit.MILLISECONDS)
            .withCallback(new Function<TestDriver, Void>() {
                public Void apply(final TestDriver driver) {
                    long startTime = System.nanoTime();
                    try {
                        pool.executeWithFailover(new TestOperation() {
                            public String execute(TestClient client) throws ConnectionException, OperationException {
                                try {
                                    function.apply(driver);
                                    return null;
                                }
View Full Code Here

                true);

        OperationResult<String> result;

        try {
            result = pool.executeWithFailover(new TestOperation() {
                @Override
                public String execute(TestClient client, ConnectionContext context)
                        throws ConnectionException, OperationException {
                    throw new RuntimeException("Unkecked Exception");
                }
View Full Code Here

        cp.addHost(host, true);

        OperationResult<String> result;

        try {
            result = cp.executeWithFailover(new TestOperation(), RunOnce.get());
        } catch (ConnectionException e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }

        HostConnectionPool<TestClient> pool = cp.getHostPool(host);
        Assert.assertNotNull(pool);

        pool.markAsDown(null);
        try {
            result = cp.executeWithFailover(new TestOperation(), RunOnce.get());
            Assert.fail();
        } catch (NoAvailableHostsException e) {

        } catch (ConnectionException e) {
            LOG.info(e);
            Assert.fail();
        }

        this.think(1000);

        try {
            result = cp.executeWithFailover(new TestOperation(), RunOnce.get());
        } catch (ConnectionException e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
    }
View Full Code Here

        OperationResult<String> result;

        for (int i = 0; i < 2; i++) {
            try {
                result = cp.executeWithFailover(new TestOperation(), RunOnce.get());
                Assert.fail("Failed iteration " + i);
            } catch (ConnectionException e) {
                LOG.info(e);
            }
        }

        try {
            result = cp.executeWithFailover(new TestOperation(), RunOnce.get());
        } catch (ConnectionException e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
    }
View Full Code Here

                true);

        OperationResult<String> result;

        try {
            result = pool.executeWithFailover(new TestOperation() {

                @Override
                public String execute(TestClient client, ConnectionContext context)
                        throws ConnectionException, OperationException {
                    throw new RuntimeException("Unkecked Exception");
View Full Code Here

        }

        for (int i = 0; i < 5; i++) {
            try {
                OperationResult<String> result = pool.executeWithFailover(
                        new TestOperation() {
                            @Override
                            public String execute(TestClient client, ConnectionContext context)
                                    throws ConnectionException,
                                    OperationException {
                                throw new TransportException("He's dead jim");
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.test.TestOperation

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.