Search in sources :

Example 1 with HBaseConfiguration

use of org.apache.hadoop.hbase.HBaseConfiguration in project siena by mandubian.

the class HBaseDdlGenerator method dropTables.

public void dropTables() {
    HBaseConfiguration config = new HBaseConfiguration();
    try {
        HBaseAdmin admin = new HBaseAdmin(config);
        HTableDescriptor[] descriptors = admin.listTables();
        for (HTableDescriptor hTableDescriptor : descriptors) {
            String name = hTableDescriptor.getNameAsString();
            admin.disableTable(name);
            admin.deleteTable(name);
        }
    } catch (IOException e) {
        throw new SienaException(e);
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) IOException(java.io.IOException) SienaException(siena.SienaException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 2 with HBaseConfiguration

use of org.apache.hadoop.hbase.HBaseConfiguration in project flink by apache.

the class HBaseConfigurationUtil method getHBaseConfiguration.

public static Configuration getHBaseConfiguration() {
    // Instantiate an HBaseConfiguration to load the hbase-default.xml and hbase-site.xml from
    // the classpath.
    Configuration result = HBaseConfiguration.create();
    boolean foundHBaseConfiguration = false;
    // We need to load both hbase-default.xml and hbase-site.xml to the hbase configuration
    // The properties of a newly added resource will override the ones in previous resources, so
    // a configuration
    // file with higher priority should be added later.
    // Approach 1: HBASE_HOME environment variables
    String possibleHBaseConfPath = null;
    final String hbaseHome = System.getenv("HBASE_HOME");
    if (hbaseHome != null) {
        LOG.debug("Searching HBase configuration files in HBASE_HOME: {}", hbaseHome);
        possibleHBaseConfPath = hbaseHome + "/conf";
    }
    if (possibleHBaseConfPath != null) {
        foundHBaseConfiguration = addHBaseConfIfFound(result, possibleHBaseConfPath);
    }
    // Approach 2: HBASE_CONF_DIR environment variable
    String hbaseConfDir = System.getenv("HBASE_CONF_DIR");
    if (hbaseConfDir != null) {
        LOG.debug("Searching HBase configuration files in HBASE_CONF_DIR: {}", hbaseConfDir);
        foundHBaseConfiguration = addHBaseConfIfFound(result, hbaseConfDir) || foundHBaseConfiguration;
    }
    if (!foundHBaseConfiguration) {
        LOG.warn("Could not find HBase configuration via any of the supported methods " + "(Flink configuration, environment variables).");
    }
    return result;
}
Also used : HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) Configuration(org.apache.hadoop.conf.Configuration)

Example 3 with HBaseConfiguration

use of org.apache.hadoop.hbase.HBaseConfiguration in project Solbase by Photobucket.

the class CSVFileImporter method main.

public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java example.CSVFileImporter <csv filename>");
        System.exit(0);
    }
    @SuppressWarnings("deprecation") HBaseConfiguration conf = new HBaseConfiguration();
    conf.set("hbase.zookeeper.quorum", "localhost");
    conf.set("hbase.zookeeper.property.clientPort", "2181");
    conf.setInt("hbase.client.retries.number", 7);
    conf.setInt("ipc.client.connect.max.retries", 3);
    HTablePool hTablePool = new HTablePool(conf, 10);
    try {
        BufferedReader in = new BufferedReader(new FileReader(args[0]));
        String str;
        while ((str = in.readLine()) != null) {
            process(str, hTablePool);
        }
        in.close();
    } catch (IOException e) {
    }
}
Also used : HTablePool(org.apache.hadoop.hbase.client.HTablePool) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException)

Aggregations

HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 IOException (java.io.IOException)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 Configuration (org.apache.hadoop.conf.Configuration)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)1 HTablePool (org.apache.hadoop.hbase.client.HTablePool)1 SienaException (siena.SienaException)1