Java Code Examples for org.apache.cassandra.hadoop.ConfigHelper#getOutputKeyspace()

The following examples show how to use org.apache.cassandra.hadoop.ConfigHelper#getOutputKeyspace() . 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: CqlBulkRecordWriter.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private void setConfigs() throws IOException
{
    // if anything is missing, exceptions will be thrown here, instead of on write()
    keyspace = ConfigHelper.getOutputKeyspace(conf);
    columnFamily = ConfigHelper.getOutputColumnFamily(conf);
    schema = CqlBulkOutputFormat.getColumnFamilySchema(conf, columnFamily);
    insertStatement = CqlBulkOutputFormat.getColumnFamilyInsertStatement(conf, columnFamily);
    outputDir = getColumnFamilyDirectory();
    deleteSrc = CqlBulkOutputFormat.getDeleteSourceOnSuccess(conf);
}
 
Example 2
Source File: CqlRecordWriter.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/** retrieve the key validator from system.schema_columnfamilies table */
private void retrievePartitionKeyValidator(Cassandra.Client client) throws Exception
{
    String keyspace = ConfigHelper.getOutputKeyspace(conf);
    String cfName = ConfigHelper.getOutputColumnFamily(conf);
    String query = "SELECT key_validator," +
    		       "       key_aliases," +
    		       "       column_aliases " +
                   "FROM system.schema_columnfamilies " +
                   "WHERE keyspace_name='%s' and columnfamily_name='%s'";
    String formatted = String.format(query, keyspace, cfName);
    CqlResult result = client.execute_cql3_query(ByteBufferUtil.bytes(formatted), Compression.NONE, ConsistencyLevel.ONE);

    Column rawKeyValidator = result.rows.get(0).columns.get(0);
    String validator = ByteBufferUtil.string(ByteBuffer.wrap(rawKeyValidator.getValue()));
    keyValidator = parseType(validator);
    
    Column rawPartitionKeys = result.rows.get(0).columns.get(1);
    String keyString = ByteBufferUtil.string(ByteBuffer.wrap(rawPartitionKeys.getValue()));
    logger.debug("partition keys: {}", keyString);

    List<String> keys = FBUtilities.fromJsonList(keyString);
    partitionKeyColumns = new String[keys.size()];
    int i = 0;
    for (String key : keys)
    {
        partitionKeyColumns[i] = key;
        i++;
    }

    Column rawClusterColumns = result.rows.get(0).columns.get(2);
    String clusterColumnString = ByteBufferUtil.string(ByteBuffer.wrap(rawClusterColumns.getValue()));

    logger.debug("cluster columns: {}", clusterColumnString);
    clusterColumns = FBUtilities.fromJsonList(clusterColumnString);
}
 
Example 3
Source File: CrunchBulkRecordWriter.java    From hdfs2cass with Apache License 2.0 5 votes vote down vote up
private void prepareWriter() {
  String columnFamily = CrunchConfigHelper.getOutputColumnFamily(conf);
  String keyspace = ConfigHelper.getOutputKeyspace(conf);

  if (outputdir == null) {
    // dir must be named by ks/cf for the loader
    outputdir = Paths.get(getOutputLocation(), keyspace, columnFamily).toFile();
    outputdir.mkdirs();
  }

  if (writer == null) {
    AbstractType<?> subcomparator = null;

    if (cfType == CFType.SUPER)
      subcomparator = BytesType.instance;

    this.writer = new SSTableSimpleWriter(
        outputdir, ConfigHelper.getOutputPartitioner(conf),
        keyspace, columnFamily,
        BytesType.instance, subcomparator);

    ExternalSSTableLoaderClient externalClient = new ExternalSSTableLoaderClient(
        ConfigHelper.getOutputInitialAddress(conf),
        ConfigHelper.getOutputRpcPort(conf),
        ConfigHelper.getOutputKeyspaceUserName(conf),
        ConfigHelper.getOutputKeyspacePassword(conf));

    this.loader = new SSTableLoader(outputdir, externalClient,
        new OutputHandler.SystemOutput(true, true));
  }
}
 
Example 4
Source File: CrunchCqlBulkRecordWriter.java    From hdfs2cass with Apache License 2.0 5 votes vote down vote up
private void setConfigs()
{
  // if anything is missing, exceptions will be thrown here, instead of on write()
  keyspace = ConfigHelper.getOutputKeyspace(conf);
  columnFamily = CrunchConfigHelper.getOutputColumnFamily(conf);
  schema = CrunchCqlBulkOutputFormat.getColumnFamilySchema(conf, columnFamily);
  insertStatement = CrunchCqlBulkOutputFormat.getColumnFamilyInsertStatement(conf, columnFamily);
  outputDir = getColumnFamilyDirectory();
}