private void addKeyspace (Cluster cluster, String keyspaceName) throws Exception { try { keyspaces.put( keyspaceName, cluster.getKeyspace( keyspaceName ) ); } catch (ConnectionException e) { logger.error("Unable to get keyspace client for keyspace: {}, detail: {}", keyspaceName, e.getMessage()); throw e; } }
private void informException(ConnectionException connectionException) throws ConnectionException { connectionException .setHost(getCurrentHost()) .setLatency(System.currentTimeMillis() - startTime) .setAttempt(this.attemptCounter) .setLatencyWithPool(System.currentTimeMillis() - poolStartTime); if (connectionException instanceof IsRetryableException) { if (!canRetry()) { throw connectionException; } } else { // Most likely an operation error throw connectionException; } } }
try { JSONObject json = jParser.makeHttpRequest(url_list_rs, "GET", params); catch(ConnectionException ex) { ex.printStackTrace(); }
.setLatency(System.currentTimeMillis() - startTime); throw new InterruptedOperationException("Thread interrupted waiting for connection") .setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime);
pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), System.nanoTime()); closeClient(); ConnectionException ce = ThriftConverter.ToConnectionPoolException(e).setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime); monitor.incConnectionCreateFailed(getHost(), ce); throw ce; pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), System.nanoTime()); closeClient(); ConnectionException ce = ThriftConverter.ToConnectionPoolException(new RuntimeException("Error openning connection", t)).setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime); monitor.incConnectionCreateFailed(getHost(), ce); throw ce;
} catch (ConnectionException e) { Assert.fail(); LOG.info(e.getMessage()); e.printStackTrace();
@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; } }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }
private void informException(ConnectionException connectionException) throws ConnectionException { connectionException .setHost(getCurrentHost()) .setLatency(System.currentTimeMillis() - startTime) .setAttempt(this.attemptCounter) .setLatencyWithPool(System.currentTimeMillis() - poolStartTime); if (connectionException instanceof IsRetryableException) { if (!canRetry()) { throw connectionException; } } else { // Most likely an operation error throw connectionException; } } }
try { BluetoothDiscoverer.findPrinters(this, new DiscoveryHandler() { public void foundPrinter(DiscoveredPrinter printer) { String macAddress = printer.address; //I found a printer! I can use the properties of a Discovered printer (address) to make a Bluetooth Connection } public void discoveryFinished() { //Discovery is done } public void discoveryError(String message) { //Error during discovery } }); } catch (ConnectionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); }
.setLatency(System.currentTimeMillis() - startTime); throw new InterruptedOperationException("Thread interrupted waiting for connection") .setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime);
pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), System.nanoTime()); closeClient(); ConnectionException ce = ThriftConverter.ToConnectionPoolException(e).setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime); monitor.incConnectionCreateFailed(getHost(), ce); throw ce; pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), System.nanoTime()); closeClient(); ConnectionException ce = ThriftConverter.ToConnectionPoolException(new RuntimeException("Error openning connection", t)).setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime); monitor.incConnectionCreateFailed(getHost(), ce); throw ce;
@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; } }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }
@Override public boolean failure(ConnectionException e) { LOG.error(e.getMessage(), e); return false; } });
throw new PoolTimeoutException("Fast fail waiting for connection from pool") .setHost(getHost()) .setLatency(System.currentTimeMillis() - startTime);
monitor.incOperationFailure(e.getHost(), e); throw e;
MutationBatch m = CassandraAstyanaxConnection.getInstance().getKeyspace().prepareMutationBatch(); ColumnListMutation<String> clm = m.withRow(CassandraAstyanaxConnection.getInstance().getEmp_cf(), userId); for(String key: attributeMap.keySet()){ clm.putColumn(key, attributeMap.get(key), null); } try { m.execute(); } catch (ConnectionException e) { e.printStackTrace(); }
@Override public boolean onException(ConnectionException e) { Assert.fail(e.getMessage()); return true; } }).execute();