com.datastax.driver.core.exceptions.AuthenticationException Java Examples
The following examples show how to use
com.datastax.driver.core.exceptions.AuthenticationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryCassandra.java From localization_nifi with Apache License 2.0 | 6 votes |
@OnScheduled public void onScheduled(final ProcessContext context) { ComponentLog log = getLogger(); try { connectToCassandra(context); final int fetchSize = context.getProperty(FETCH_SIZE).asInteger(); if (fetchSize > 0) { synchronized (cluster.get()) { cluster.get().getConfiguration().getQueryOptions().setFetchSize(fetchSize); } } } catch (final NoHostAvailableException nhae) { log.error("No host in the Cassandra cluster can be contacted successfully to execute this query", nhae); // Log up to 10 error messages. Otherwise if a 1000-node cluster was specified but there was no connectivity, // a thousand error messages would be logged. However we would like information from Cassandra itself, so // cap the error limit at 10, format the messages, and don't include the stack trace (it is displayed by the // logger message above). log.error(nhae.getCustomMessage(10, true, false)); throw new ProcessException(nhae); } catch (final AuthenticationException ae) { log.error("Invalid username/password combination", ae); throw new ProcessException(ae); } }
Example #2
Source File: PutCassandraQL.java From localization_nifi with Apache License 2.0 | 6 votes |
@OnScheduled public void onScheduled(final ProcessContext context) { ComponentLog log = getLogger(); try { connectToCassandra(context); } catch (final NoHostAvailableException nhae) { log.error("No host in the Cassandra cluster can be contacted successfully to execute this statement", nhae); // Log up to 10 error messages. Otherwise if a 1000-node cluster was specified but there was no connectivity, // a thousand error messages would be logged. However we would like information from Cassandra itself, so // cap the error limit at 10, format the messages, and don't include the stack trace (it is displayed by the // logger message above). log.error(nhae.getCustomMessage(10, true, false)); throw new ProcessException(nhae); } catch (final AuthenticationException ae) { log.error("Invalid username/password combination", ae); throw new ProcessException(ae); } }
Example #3
Source File: CassandraTarget.java From datacollector with Apache License 2.0 | 6 votes |
private boolean checkCassandraReachable(List<ConfigIssue> issues) { boolean isReachable = true; try (Cluster validationCluster = getCluster()) { Session validationSession = validationCluster.connect(); validationSession.close(); } catch (NoHostAvailableException | AuthenticationException | IllegalStateException | StageException e) { isReachable = false; Target.Context context = getContext(); LOG.error(Errors.CASSANDRA_05.getMessage(), e.toString(), e); issues.add( context.createConfigIssue( Groups.CASSANDRA.name(), CONTACT_NODES_LABEL, Errors.CASSANDRA_05, e.toString() ) ); } return isReachable; }
Example #4
Source File: UserPassConnectionTest.java From jmeter-cassandra with Apache License 2.0 | 6 votes |
@Test public void testNoUsername() { CassandraConnection cc = new CassandraConnection(); cc.setProperty("contactPoints", NODE_1_IP); cc.setProperty("sessionName", "testsession2"); Boolean exeptionCaught=false; try { cc.testStarted(); } catch (AuthenticationException e) { exeptionCaught = true; } assertTrue(exeptionCaught, "AuthenticationException did not occur."); }
Example #5
Source File: AbstractCassandraProcessor.java From nifi with Apache License 2.0 | 6 votes |
@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); } }
Example #6
Source File: ErrorResultIntegrationTest.java From simulacron with Apache License 2.0 | 5 votes |
@Test public void testShouldReturnAuthenticationError() throws Exception { String message = "Invalid password, man!"; server.prime(when(query).then(authenticationError(message))); thrown.expect(AuthenticationException.class); thrown.expectMessage(endsWith(message)); query(); }
Example #7
Source File: CassandraCqlMapState.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
protected void checkCassandraException(Exception e) { _mexceptions.incr(); if (e instanceof AlreadyExistsException || e instanceof AuthenticationException || e instanceof DriverException || e instanceof DriverInternalError || e instanceof InvalidConfigurationInQueryException || e instanceof InvalidQueryException || e instanceof InvalidTypeException || e instanceof QueryExecutionException || e instanceof QueryValidationException || e instanceof ReadTimeoutException || e instanceof SyntaxError || e instanceof TraceRetrievalException || e instanceof TruncateException || e instanceof UnauthorizedException || e instanceof UnavailableException || e instanceof ReadTimeoutException || e instanceof WriteTimeoutException || e instanceof ReadFailureException || e instanceof WriteFailureException || e instanceof FunctionExecutionException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }