public CassandraClientMonitor getCassandraMonitor(HConnectionManager connectionManager) { CassandraClientMonitor cassandraClientMonitor = monitors.get(connectionManager.getClusterName()); if ( cassandraClientMonitor == null ) { try { cassandraClientMonitor = new CassandraClientMonitor(connectionManager); registerMonitor("me.prettyprint.cassandra.service_"+connectionManager.getClusterName(), "hector", cassandraClientMonitor); monitors.put(connectionManager.getClusterName(), cassandraClientMonitor); } catch (MalformedObjectNameException e) { log.error("Unable to register JMX monitor", e); } catch (InstanceAlreadyExistsException e) { log.error("Unable to register JMX monitor", e); } catch (MBeanRegistrationException e) { log.error("Unable to register JMX monitor", e); } catch (NotCompliantMBeanException e) { log.error("Unable to register JMX monitor", e); } } return cassandraClientMonitor; }
@Override public long getRecoverableErrorCount() { return getRecoverableTimedOutCount() + getRecoverableTransportExceptionCount() + getRecoverableUnavailableCount() + getRecoverableLoadBalancedConnectErrors(); }
cassandraClient = null; monitor.incCounter(Counter.RENEWED_IDLE_CONNECTIONS); cassandraClient = null; monitor.incCounter(Counter.RENEWED_TOO_LONG_CONNECTIONS);
@Test public void testBorrowAndRenew() { HClient client1 = clientPool.borrowClient(); assertEquals(1, clientPool.getNumActive()); client1.updateLastSuccessTime(); clientPool.releaseClient(client1); assertEquals(0, clientPool.getNumActive()); int count = monitor.getNumRenewedIdleConnections(); try { Thread.sleep(4 * 1000); } catch(InterruptedException ex) { fail(); } HClient client2 = clientPool.borrowClient(); assertEquals(1, clientPool.getNumActive()); assertEquals(count + 1, monitor.getNumRenewedIdleConnections()); assertNotSame(client1, client2); } }
@Test public void testBorrowAndRenew() { HClient client1 = clientPool.borrowClient(); assertEquals(1, clientPool.getNumActive()); client1.updateLastSuccessTime(); clientPool.releaseClient(client1); assertEquals(0, clientPool.getNumActive()); int count = monitor.getNumRenewedTooLongConnections(); try { Thread.sleep(4 * 1000); } catch(InterruptedException ex) { fail(); } HClient client2 = clientPool.borrowClient(); assertEquals(1, clientPool.getNumActive()); assertEquals(count + 1, monitor.getNumRenewedTooLongConnections()); assertNotSame(client1, client2); } }
retryable = op.failoverPolicy.shouldRetryFor(HectorTransportException.class); monitor.incCounter(Counter.RECOVERABLE_TRANSPORT_EXCEPTIONS); monitor.incCounter(Counter.RECOVERABLE_TIMED_OUT_EXCEPTIONS); client.close(); monitor.incCounter(Counter.POOL_EXHAUSTED); } else if ( he instanceof HPoolRecoverableException ) { retryable = op.failoverPolicy.shouldRetryFor(HPoolRecoverableException.class);; throw he; monitor.incCounter(Counter.POOL_EXHAUSTED); excludeHosts.add(pool.getCassandraHost()); } else { monitor.incCounter(Counter.SKIP_HOST_SUCCESS); sleepBetweenHostSkips(op.failoverPolicy); } finally { --retries; if ( !success ) { monitor.incCounter(op.failCounter); timer.stop(timerToken, op.stopWatchTagName, false);
@Override public long getRecoverableErrorCount() { return getRecoverableTimedOutCount() + getRecoverableTransportExceptionCount() + getRecoverableUnavailableCount() + getRecoverableLoadBalancedConnectErrors(); }
@Before public void setupTest() { setupClient(); cassandraHost = cassandraHostConfigurator.buildCassandraHosts()[0]; HClientFactory factory = new HThriftClientFactoryImpl(); clientPool = new ConcurrentHClientPool(factory, cassandraHost, new CassandraClientMonitor(connectionManager)); }
retryable = true; monitor.incCounter(Counter.RECOVERABLE_TRANSPORT_EXCEPTIONS); monitor.incCounter(Counter.RECOVERABLE_TIMED_OUT_EXCEPTIONS); client.close(); throw he; monitor.incCounter(Counter.POOL_EXHAUSTED); excludeHosts.add(pool.getCassandraHost()); } else { monitor.incCounter(Counter.SKIP_HOST_SUCCESS); sleepBetweenHostSkips(op.failoverPolicy); } finally { --retries; if ( !success ) { monitor.incCounter(op.failCounter); timer.stop(timerToken, op.stopWatchTagName, false);
@Override public long getRecoverableErrorCount() { return getRecoverableTimedOutCount() + getRecoverableTransportExceptionCount() + getRecoverableUnavailableCount() + getRecoverableLoadBalancedConnectErrors(); }
@Before public void setupTest() { setupClient(); cassandraHost = cassandraHostConfigurator.buildCassandraHosts()[0]; HClientFactory factory = new HThriftClientFactoryImpl(); clientPool = new LatencyAwareHClientPool(factory, cassandraHost, new CassandraClientMonitor(connectionManager)); }
cassandraClient = null; monitor.incCounter(Counter.RENEWED_IDLE_CONNECTIONS); cassandraClient = null; monitor.incCounter(Counter.RENEWED_TOO_LONG_CONNECTIONS);
@Before public void setupTest() { setupClient(); cassandraHost = cassandraHostConfigurator.buildCassandraHosts()[0]; HClientFactory factory = new HThriftClientFactoryImpl(); monitor = new CassandraClientMonitor(connectionManager); clientPool = new ConcurrentHClientPool(factory, cassandraHost, monitor); }
retryable = op.failoverPolicy.shouldRetryFor(HectorTransportException.class); monitor.incCounter(Counter.RECOVERABLE_TRANSPORT_EXCEPTIONS); monitor.incCounter(Counter.RECOVERABLE_TIMED_OUT_EXCEPTIONS); client.close(); monitor.incCounter(Counter.POOL_EXHAUSTED); } else if ( he instanceof HPoolRecoverableException ) { retryable = op.failoverPolicy.shouldRetryFor(HPoolRecoverableException.class);; throw he; monitor.incCounter(Counter.POOL_EXHAUSTED); excludeHosts.add(pool.getCassandraHost()); } else { monitor.incCounter(Counter.SKIP_HOST_SUCCESS); sleepBetweenHostSkips(op.failoverPolicy); } finally { --retries; if ( !success ) { monitor.incCounter(op.failCounter); timer.stop(timerToken, op.stopWatchTagName, false);
@Before public void setupTest() { setupClient(); cassandraHost = cassandraHostConfigurator.buildCassandraHosts()[0]; HClientFactory factory = new HThriftClientFactoryImpl(); monitor = new CassandraClientMonitor(connectionManager); clientPool = new ConcurrentHClientPool(factory, cassandraHost, monitor); }
public CassandraClientMonitor getCassandraMonitor(HConnectionManager connectionManager) { CassandraClientMonitor cassandraClientMonitor = monitors.get(connectionManager.getClusterName()); if ( cassandraClientMonitor == null ) { try { cassandraClientMonitor = new CassandraClientMonitor(connectionManager); registerMonitor("me.prettyprint.cassandra.service_"+connectionManager.getClusterName(), "hector", cassandraClientMonitor); monitors.put(connectionManager.getClusterName(), cassandraClientMonitor); } catch (MalformedObjectNameException e) { log.error("Unable to register JMX monitor", e); } catch (InstanceAlreadyExistsException e) { log.error("Unable to register JMX monitor", e); } catch (MBeanRegistrationException e) { log.error("Unable to register JMX monitor", e); } catch (NotCompliantMBeanException e) { log.error("Unable to register JMX monitor", e); } } return cassandraClientMonitor; }
public CassandraClientMonitor getCassandraMonitor(HConnectionManager connectionManager) { CassandraClientMonitor cassandraClientMonitor = monitors.get(connectionManager.getClusterName()); if ( cassandraClientMonitor == null ) { try { cassandraClientMonitor = new CassandraClientMonitor(connectionManager); registerMonitor("me.prettyprint.cassandra.service_"+connectionManager.getClusterName(), "hector", cassandraClientMonitor); monitors.put(connectionManager.getClusterName(), cassandraClientMonitor); } catch (MalformedObjectNameException e) { log.error("Unable to register JMX monitor", e); } catch (InstanceAlreadyExistsException e) { log.error("Unable to register JMX monitor", e); } catch (MBeanRegistrationException e) { log.error("Unable to register JMX monitor", e); } catch (NotCompliantMBeanException e) { log.error("Unable to register JMX monitor", e); } } return cassandraClientMonitor; }