Package com.netflix.astyanax.connectionpool.exceptions

Examples of com.netflix.astyanax.connectionpool.exceptions.UnknownException


                } catch (Exception e) {
                    long now = System.nanoTime();
                    latency = now - startTime;
                    ConnectionException connectionException;
                    if (!(e instanceof ConnectionException))
                        connectionException = new UnknownException(e);
                    else
                        connectionException = (ConnectionException)e;
                    connectionException.setLatency(latency);
                   
                    if (!(connectionException instanceof IsTimeoutException)) {
                        pool.addLatencySample(latency, now);
                    }
                    else {
                        pool.addLatencySample(TimeUnit.NANOSECONDS.convert(config.getSocketTimeout(), TimeUnit.MILLISECONDS), System.nanoTime());
                    }
                    lastException = connectionException;
                    throw lastException;
                }
            }

            @Override
            public void close() {
                if (isOpen) {
                    monitor.incConnectionClosed(getHost(), lastException);
                    executor.submit(new Runnable() {
                        @Override
                        public void run() {
                            final TestHostType type = TestHostType
                                    .get(getHost().getPort());
                            type.close();
                            isOpen = false;
                        }
                    });
                }
            }

            @Override
            public HostConnectionPool<TestClient> getHostConnectionPool() {
                return pool;
            }

            @Override
            public ConnectionException getLastException() {
                return lastException;
            }

            @Override
            public void open() throws ConnectionException {
                TestHostType type = TestHostType.get(getHost().getPort());
                try {
                    type.open(0);
                    isOpen = true;
                    monitor.incConnectionCreated(getHost());
                } catch (ConnectionException e) {
                    lastException = e;
                    e.setHost(getHost());
                    monitor.incConnectionCreateFailed(getHost(), e);
                    throw e;
                }
            }

            @Override
            public void openAsync(final AsyncOpenCallback<TestClient> callback) {
                final Connection<TestClient> This = this;
                executor.submit(new Runnable() {
                    @Override
                    public void run() {
                        Thread.currentThread().setName("MockConnectionFactory");
                        try {
                            open();
                            callback.success(This);
                        } catch (ConnectionException e) {
                            callback.failure(This, e);
                        } catch (Exception e) {
                            callback.failure(This, new UnknownException(
                                    "Error openning async connection", e));
                        }
                    }
                });
            }
View Full Code Here


            }
            return new TransportException(e);
        }
        else {
            // e.getCause().printStackTrace();
            return new UnknownException(e);
        }
    }
View Full Code Here

            throw e;
        }
        catch (Throwable t) {
            failedOpenConnections.incrementAndGet();
            activeCount.decrementAndGet();
            ConnectionException ce = new UnknownException(t);
            noteError(ce);
            throw ce;
        }
    }
View Full Code Here

                monitor.incOperationSuccess(getCurrentHost(), result.getLatency());
                return result;
            }
            catch (Exception e) {
                ConnectionException ce = (e instanceof ConnectionException) ? (ConnectionException) e
                        : new UnknownException(e);
              try {
                informException(ce);
                    monitor.incFailover(ce.getHost(), ce);
              }
              catch (ConnectionException ex) {
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.connectionpool.exceptions.UnknownException

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.