All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flipkart.hbaseobjectmapper.HBAdmin Maven / Gradle / Ivy

Go to download

HBase ORM is a light-weight, thread-safe and performant library that enables: [1] object-oriented access of HBase rows (Data Access Object) with minimal code and good testability. [2] reading from and/or writing to HBase tables in Hadoop MapReduce jobs. This can also be used as an ORM for Bigtable.

The newest version!
package com.flipkart.hbaseobjectmapper;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.AsyncConnection;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.TableDescriptor;

import javax.annotation.Nonnull;

import java.io.IOException;
import java.io.Serializable;

public interface HBAdmin {
    /**
     * Creates a namespace.
     *
     * @param namespace a namespace name
     * @throws IOException on hbase error
     */
    void createNamespace(String namespace) throws IOException;

    /**
     * Create table represented by the class
     *
     * @param hbRecordClass Class that represents the HBase table
     * @param            Data type of row key
     * @param            Entity type
     * @throws IOException When HBase call fails
     * @see Admin#createTable(TableDescriptor)
     */
    , T extends HBRecord> void createTable(Class hbRecordClass) throws IOException;

    /**
     * Deletes HBase table
     *
     * @param hbRecordClass Class that represents the HBase table
     * @param            Data type of row key
     * @param            Entity type
     * @throws IOException When HBase call fails
     * @see Admin#deleteTable(TableName)
     */
    , T extends HBRecord> void deleteTable(Class hbRecordClass) throws IOException;

    /**
     * Enable a
     *
     * @param hbRecordClass Class that represents the HBase table
     * @param            Data type of row key
     * @param            Entity type
     * @throws IOException When HBase call fails
     * @see Admin#enableTable(TableName)
     */
    , T extends HBRecord> void enableTable(Class hbRecordClass) throws IOException;

    /**
     * Disable a table
     *
     * @param hbRecordClass Class that represents the HBase table
     * @param            Data type of row key
     * @param            Entity type
     * @throws IOException When HBase call fails
     * @see Admin#disableTable(TableName)
     */
    , T extends HBRecord> void disableTable(Class hbRecordClass) throws IOException;

    /**
     * Checks whether table exists
     *
     * @param hbRecordClass Class that represents the HBase table
     * @param            Data type of row key
     * @param            Entity type
     * @return true if table exists
     * @throws IOException When HBase call fails
     * @see Admin#tableExists(TableName)
     */
    , T extends HBRecord> boolean tableExists(Class hbRecordClass) throws IOException;

    /**
     * Gets a HBAdmin instance given a connection.
     *
     * @param aConnection a connection instance
     * @return a HBAdmin instance
     * @throws UnsupportedOperationException if the connection class is unrecognized
     */
    static HBAdmin create(@Nonnull Object aConnection) {
        if (aConnection instanceof Connection) {
            return new SyncHBAdmin((Connection) aConnection);
        } else if (aConnection instanceof AsyncConnection) {
            return new AsyncHBAdmin((AsyncConnection) aConnection);
        } else {
            throw new UnsupportedOperationException("Unknown connection type: " + aConnection.getClass());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy