use of com.datastax.driver.core.exceptions.NoHostAvailableException in project cassandra by apache.
the class AuditLoggerTest method testCqlPrepareQueryError.
@Test
public void testCqlPrepareQueryError() {
createTable("CREATE TABLE %s (id int primary key, v1 text, v2 text)");
String cql = "INSERT INTO " + KEYSPACE + '.' + currentTable() + " (id, v1, v2) VALUES (?,?,?)";
try {
Session session = sessionNet();
PreparedStatement pstmt = session.prepare(cql);
AuditLogEntry logEntry = ((InMemoryAuditLogger) AuditLogManager.instance.getLogger()).inMemQueue.poll();
assertLogEntry(cql, AuditLogEntryType.PREPARE_STATEMENT, logEntry, false);
dropTable("DROP TABLE %s");
ResultSet rs = session.execute(pstmt.bind(1, "insert_audit", "test"));
Assert.fail("should not succeed");
} catch (NoHostAvailableException e) {
// nop
}
AuditLogEntry logEntry = ((InMemoryAuditLogger) AuditLogManager.instance.getLogger()).inMemQueue.poll();
assertLogEntry(logEntry, null);
logEntry = ((InMemoryAuditLogger) AuditLogManager.instance.getLogger()).inMemQueue.poll();
assertLogEntry(logEntry, cql);
assertEquals(0, ((InMemoryAuditLogger) AuditLogManager.instance.getLogger()).inMemQueue.size());
}
use of com.datastax.driver.core.exceptions.NoHostAvailableException in project cassandra by apache.
the class BulkLoaderTest method testBulkLoader_WithArgs.
@Test
public void testBulkLoader_WithArgs() throws Exception {
ToolResult tool = ToolRunner.invokeClass(BulkLoader.class, "-d", "127.9.9.1", OfflineToolUtils.sstableDirName("legacy_sstables", "legacy_ma_simple"));
assertEquals(-1, tool.getExitCode());
if (!(tool.getException().getCause() instanceof BulkLoadException))
throw tool.getException();
if (!(tool.getException().getCause().getCause() instanceof NoHostAvailableException))
throw tool.getException();
assertNoUnexpectedThreadsStarted(new String[] { "ObjectCleanerThread", "globalEventExecutor-[1-9]-[1-9]", "globalEventExecutor-[1-9]-[1-9]", "Shutdown-checker", "cluster[0-9]-connection-reaper-[0-9]" });
assertSchemaNotLoaded();
assertCLSMNotLoaded();
assertSystemKSNotLoaded();
assertKeyspaceNotLoaded();
assertServerNotLoaded();
}
use of com.datastax.driver.core.exceptions.NoHostAvailableException in project storm by apache.
the class BaseCassandraBolt method prepare.
/**
* {@inheritDoc}
*/
@Override
public void prepare(Map<String, Object> topoConfig, TopologyContext topologyContext, OutputCollector outputCollector) {
this.outputCollector = outputCollector;
this.topoConfig = topoConfig;
Map<String, Object> cassandraClientConfig = cassandraConfig != null ? cassandraConfig : topoConfig;
this.cassandraConf = new CassandraConf(cassandraClientConfig);
this.client = clientProvider.getClient(cassandraClientConfig);
try {
session = client.connect();
} catch (NoHostAvailableException e) {
outputCollector.reportError(e);
throw e;
}
}
Aggregations