public EC2MultiRegionAddressTranslator() { Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); try { ctx = new InitialDirContext(env); } catch (NamingException e) { throw new DriverException("Could not create translator", e); } }
/** * Copy the exception. * * <p>This returns a new exception, equivalent to the original one, except that because a new * object is created in the current thread, the top-most element in the stacktrace of the * exception will refer to the current thread (this is mainly intended for internal use by the * driver). The cause of the copied exception will be the original exception. * * @return a copy/clone of this exception. */ public DriverException copy() { return new DriverException(getMessage(), this); } }
logError( connection.address, new DriverException("Got unexpected response to prepare message: " + response)); retry(false, null); logError( connection.address, new DriverException("Error preparing query, got " + response)); if (metricsEnabled()) metrics().getErrorMetrics().getOthers().inc(); retry(false, null);
errors = logError(host, new DriverException("Connection thread interrupted"), errors, iter); while (iter.hasNext()) errors = logError( iter.next(), new DriverException("Connection thread interrupted"), errors, iter);
new DriverException( "Aborting attempt to set keyspace to '" + keyspace
@Test(groups = "unit") public void should_not_log_error_if_level_higher_than_DEBUG() throws Exception { // given normal.setLevel(INFO); slow.setLevel(INFO); error.setLevel(INFO); // when queryLogger = QueryLogger.builder().build(); queryLogger.onRegister(mock(Cluster.class)); queryLogger.update(null, mock(BoundStatement.class), new DriverException("booh"), 0); // then assertThat(normalAppender.get()).isEmpty(); assertThat(slowAppender.get()).isEmpty(); assertThat(errorAppender.get()).isEmpty(); }
@Override public void onTimeout(Connection connection, long latency) { logError(connection.address, new DriverException("Timeout waiting for response to prepare message")); retry(false, null); } };
public EC2MultiRegionAddressTranslator() { Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); try { ctx = new InitialDirContext(env); } catch (NamingException e) { throw new DriverException("Could not create translator", e); } }
public EC2MultiRegionAddressTranslator() { Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); try { ctx = new InitialDirContext(env); } catch (NamingException e) { throw new DriverException("Could not create translator", e); } }
public EC2MultiRegionAddressTranslator() { Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); try { ctx = new InitialDirContext(env); } catch (NamingException e) { throw new DriverException("Could not create translator", e); } }
/** * Copy the exception. * <p/> * This returns a new exception, equivalent to the original one, except that * because a new object is created in the current thread, the top-most * element in the stacktrace of the exception will refer to the current * thread (this is mainly intended for internal use by the driver). The cause of * the copied exception will be the original exception. * * @return a copy/clone of this exception. */ public DriverException copy() { return new DriverException(getMessage(), this); } }
/** * Copy the exception. * <p/> * This returns a new exception, equivalent to the original one, except that * because a new object is created in the current thread, the top-most * element in the stacktrace of the exception will refer to the current * thread (this is mainly intended for internal use by the driver). The cause of * the copied exception will be the original exception. * * @return a copy/clone of this exception. */ public DriverException copy() { return new DriverException(getMessage(), this); } }
/** * Copy the exception. * <p/> * This returns a new exception, equivalent to the original one, except that * because a new object is created in the current thread, the top-most * element in the stacktrace of the exception will refer to the current * thread (this is mainly intended for internal use by the driver). The cause of * the copied exception will be the original exception. * * @return a copy/clone of this exception. */ public DriverException copy() { return new DriverException(getMessage(), this); } }
/** * Copy the exception. * <p> * This return a new exception, equivalent to the original one, except that * because a new object is created in the current thread, the top-most * element in the stacktrace of the exception will refer to the current * thread (this mainly use for internal use by the driver). The cause of * the copied exception will be the original exception. * * @return a copy/clone of this exception. */ public DriverException copy() { return new DriverException(getMessage(), this); } }
public static GraphStatement getStatementFromBytecodeRemoteSource(Bytecode bytecode) { try { String serializedBytecode = writeValueAsString(bytecode); return new RemoteSourceSimpleGraphStatement(serializedBytecode); } catch (IOException e) { throw new DriverException("Could not serialize Traversal's bytecode.", e); } } }
public static GraphStatement getStatementFromBytecode(Bytecode bytecode) { try { String serializedBytecode = writeValueAsString(bytecode); GraphStatement simpleGraphStatement = new SimpleGraphStatement(serializedBytecode); simpleGraphStatement.setGraphLanguage(BYTECODE_GRAPHSON_GRAPH_LANGUAGE); return simpleGraphStatement; } catch (IOException e) { throw new DriverException("Could not serialize Traversal's bytecode.", e); } }
public static GraphStatement getStatementFromBytecodes(Collection<GraphTraversal> traversals) { try { String serializedBytecode = writeValueAsString(traversals); GraphStatement simpleGraphStatement = new SimpleGraphStatement(serializedBytecode); simpleGraphStatement.setGraphLanguage(BYTECODE_GRAPHSON_GRAPH_LANGUAGE); return simpleGraphStatement; } catch (IOException e) { throw new DriverException("Could not serialize traversals.", e); } }
private Session checkSession() { Session s = rwl.read(() -> { lastUse = System.currentTimeMillis(); return session != null && !session.isClosed() ? session : null; }); if (s != null) return s; try { return rwl.writeEx(() -> { if (session != null && !session.isClosed()) return session; if (cluster == null || cluster.isClosed()) throw new DriverException("The cluster is closed"); logger.finest(() -> "Create session " + keySpace == null ? StringUtils.EMPTY : keySpace); session = keySpace == null ? cluster.connect() : cluster.connect(keySpace); return session; }); } catch (ReadWriteLock.InsideLockException e) { if (e.exception instanceof RuntimeException) throw (RuntimeException) e.exception; throw e; } }
@Override public void onTimeout(Connection connection, long latency) { Host queriedHost = current; try { if (connection instanceof PooledConnection) ((PooledConnection)connection).release(); logError(connection.address, new DriverException("Timeout during read")); retry(false, null); } catch (Exception e) { // This shouldn't happen, but if it does, we want to signal the callback, not let him hang indefinitively setFinalException(null, new DriverInternalError("An unexpected error happened while handling timeout", e)); } finally { if (queriedHost != null) manager.cluster.manager.reportLatency(queriedHost, latency); } }
@Test(groups = "unit") public void should_not_log_error_if_level_higher_than_DEBUG() throws Exception { // given normal.setLevel(INFO); slow.setLevel(INFO); error.setLevel(INFO); // when queryLogger = QueryLogger.builder().build(); queryLogger.onRegister(mock(Cluster.class)); queryLogger.update(null, mock(BoundStatement.class), new DriverException("booh"), 0); // then assertThat(normalAppender.get()).isEmpty(); assertThat(slowAppender.get()).isEmpty(); assertThat(errorAppender.get()).isEmpty(); }