private void alterEndpointProfileTable() { try { cassandraSession.execute("ALTER TABLE ep_profile ADD eps_cf_hash blob;"); } catch (InvalidQueryException ex) { LOG.warn("Failed to alter ep_profile table: {}", ex.getMessage()); } }
/** * Checks if Cassandra table absence error occur. * * @param e Exception to check. * @return {@code true} in case of table absence error. */ public static boolean isTableAbsenceError(Throwable e) { while (e != null) { if (e instanceof InvalidQueryException && (TABLE_EXIST_ERROR1.matcher(e.getMessage()).matches() || TABLE_EXIST_ERROR3.matcher(e.getMessage()).matches() || KEYSPACE_EXIST_ERROR1.matcher(e.getMessage()).matches() || KEYSPACE_EXIST_ERROR2.matcher(e.getMessage()).matches())) return true; if (e instanceof NoHostAvailableException && ((NoHostAvailableException) e).getErrors() != null) { NoHostAvailableException ex = (NoHostAvailableException)e; for (Map.Entry<InetSocketAddress, Throwable> entry : ex.getErrors().entrySet()) { Throwable error = entry.getValue(); if (error instanceof DriverException && (error.getMessage().contains(TABLE_EXIST_ERROR2) || KEYSPACE_EXIST_ERROR3.matcher(error.getMessage()).matches())) return true; } } e = e.getCause(); } return false; }
@Override public InvalidTypeException copy() { return new InvalidTypeException(getMessage(), this); } }
@Override public CodecNotFoundException copy() { return new CodecNotFoundException(getMessage(), getCause(), getCqlType(), getJavaType()); } }
@Override public InvalidConfigurationInQueryException copy() { return new InvalidConfigurationInQueryException(getAddress(), getMessage()); } }
logger.error(nae.getMessage()); throw nae; logger.error(ue.getMessage()); throw ue;
@Override public TraceRetrievalException copy() { return new TraceRetrievalException(getMessage(), this); } }
logger.error(nae.getMessage()); throw nae;
@Override public DriverException copy() { return new AuthenticationException(address, getMessage(), this); } }
private <T> T executeWithSession(SessionCallable<T> sessionCallable) { ReconnectionPolicy reconnectionPolicy = cluster.getConfiguration().getPolicies().getReconnectionPolicy(); ReconnectionSchedule schedule = reconnectionPolicy.newSchedule(); long deadline = System.currentTimeMillis() + noHostAvailableRetryTimeout.toMillis(); while (true) { try { return sessionCallable.executeWithSession(session.get()); } catch (NoHostAvailableException e) { long timeLeft = deadline - System.currentTimeMillis(); if (timeLeft <= 0) { throw e; } else { long delay = Math.min(schedule.nextDelayMs(), timeLeft); log.warn(e.getCustomMessage(10, true, true)); log.warn("Reconnecting in %dms", delay); try { Thread.sleep(delay); } catch (InterruptedException interrupted) { Thread.currentThread().interrupt(); throw new RuntimeException("interrupted", interrupted); } } } } }
@Override public OperationTimedOutException copy() { return new OperationTimedOutException(address, getRawMessage(), this); } }
@Override public DriverException copy() { return new FunctionExecutionException(address, getMessage(), this); } }
@Override public ProtocolError copy() { return new ProtocolError(address, getMessage(), this); } }
@Override public FrameTooLongException copy() { return new FrameTooLongException(streamId, this); } }
@Override public BusyConnectionException copy() { return new BusyConnectionException(address, this); } }
@Override public UnsupportedProtocolVersionException copy() { return new UnsupportedProtocolVersionException( address, unsupportedVersion, serverVersion, this); } }
if (!e.getMessage().startsWith("unconfigured columnfamily row_key"))
@OnScheduled public void onScheduled(ProcessContext context) { final boolean connectionProviderIsSet = context.getProperty(CONNECTION_PROVIDER_SERVICE).isSet(); if (connectionProviderIsSet) { CassandraSessionProviderService sessionProvider = context.getProperty(CONNECTION_PROVIDER_SERVICE).asControllerService(CassandraSessionProviderService.class); cluster.set(sessionProvider.getCluster()); cassandraSession.set(sessionProvider.getCassandraSession()); return; } try { connectToCassandra(context); } catch (NoHostAvailableException nhae) { getLogger().error("No host in the Cassandra cluster can be contacted successfully to execute this statement", nhae); getLogger().error(nhae.getCustomMessage(10, true, false)); throw new ProcessException(nhae); } catch (AuthenticationException ae) { getLogger().error("Invalid username/password combination", ae); throw new ProcessException(ae); } }
getLogger().error(nhae.getCustomMessage(10, true, false)); flowFile = session.penalize(flowFile); session.transfer(flowFile, REL_RETRY);
getLogger().error(nhae.getCustomMessage(10, true, false)); fileToProcess = session.penalize(fileToProcess); session.transfer(fileToProcess, REL_RETRY);