public BigDataExtractor(ConfigTree config) throws ConfigurationException { super(config); if (configuration.getDataStore().equals(DataStore.CASSANDRA)) { // init is in static block } else if (configuration.getDataStore().equals(DataStore.HBASE)) { messagePersister = new MessagePersister(); } }
private void writePayload(String messageKey, byte[] messageBodyBytes) throws ActionProcessingException { if (configuration.getDataStore().equals(DataStore.CASSANDRA)) { ColumnFamilyUpdater<String, String> updater = cfTemplate.createUpdater(messageKey); updater.setByteArray("body", messageBodyBytes); updater.setLong("timestamp", System.currentTimeMillis()); try { cfTemplate.update(updater); } catch (HectorException ex) { throw new ActionProcessingException( "Got HectorException writing " + "message to data storage: " + ex.getMessage()); } } else if (configuration.getDataStore().equals(DataStore.HBASE)) { try { // TODO need to write timestamp too? messagePersister.writeMessage(messageKey, messageBodyBytes); } catch (HBaseException ex) { throw new ActionProcessingException( "Got HBaseException writing " + "message to data storage: " + ex.getMessage()); } } }
static { if (configuration.getDataStore().equals(DataStore.CASSANDRA)) { // TODO make a CassandraFacade class that encapsulates all the cassandra stuff dataCluster = HFactory.getOrCreateCluster("data-cluster", tuskCassConf.getCluster()); LOG.debug("Hector dataCluster=" + dataCluster); // This is the keyspace to use for the data we are storing KeyspaceDefinition keyspaceDef = dataCluster.describeKeyspace(tuskCassConf.getKeyspace()); LOG.debug("Hector keyspaceDef=" + keyspaceDef); ksp = HFactory.createKeyspace(tuskCassConf.getKeyspace(), dataCluster); LOG.debug("Hector keyspace=" + ksp); cfTemplate = new ThriftColumnFamilyTemplate<String, String>( ksp, tuskCassConf.getColumnFamily(), StringSerializer.get(), StringSerializer.get()); LOG.debug("Hector cfTemplate=" + cfTemplate); } else if (configuration.getDataStore().equals(DataStore.HBASE)) { // init is in ctor } // System.setProperty("java.net.preferIPv4Stack", "true"); // ispnService = new InfinispanService(); }