Search in sources :

Example 1 with ZooKeeperConnectionException

use of org.apache.hadoop.hbase.ZooKeeperConnectionException in project titan by thinkaurelius.

the class HBaseStoreManager method getLocalKeyPartition.

@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    List<KeyRange> result = new LinkedList<KeyRange>();
    HTable table = null;
    try {
        ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
        table = new HTable(hconf, tableName);
        Map<KeyRange, ServerName> normed = normalizeKeyBounds(table.getRegionLocations());
        for (Map.Entry<KeyRange, ServerName> e : normed.entrySet()) {
            if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
                result.add(e.getKey());
                logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
            } else {
                logger.debug("Discarding remote {}", e.getValue());
            }
        }
    } catch (MasterNotRunningException e) {
        logger.warn("Unexpected MasterNotRunningException", e);
    } catch (ZooKeeperConnectionException e) {
        logger.warn("Unexpected ZooKeeperConnectionException", e);
    } catch (IOException e) {
        logger.warn("Unexpected IOException", e);
    } finally {
        IOUtils.closeQuietly(table);
    }
    return result;
}
Also used : KeyRange(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeyRange) ServerName(org.apache.hadoop.hbase.ServerName) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) HTable(org.apache.hadoop.hbase.client.HTable) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) LinkedList(java.util.LinkedList)

Example 2 with ZooKeeperConnectionException

use of org.apache.hadoop.hbase.ZooKeeperConnectionException in project honeycomb by altamiracorp.

the class TableCreator method createTable.

/**
 * Creates a table in HBase to store all Honeycomb tables
 *
 * @param configuration Configuration of the HTable
 * @throws IOException
 */
public static void createTable(Configuration configuration) throws IOException {
    HTableDescriptor tableDescriptor;
    try {
        HBaseAdmin.checkHBaseAvailable(configuration);
    } catch (MasterNotRunningException e) {
        logger.fatal(String.format("HMaster doesn't appear to be running. Zookeeper quorum: %s", configuration.get("hbase.zookeeper.quorum")), e);
        throw e;
    } catch (ZooKeeperConnectionException e) {
        logger.fatal("Failed to connect to zookeeper when checking HBase. Zookeeper quorum: " + configuration.get("hbase.zookeeper.quorum"), e);
        throw e;
    }
    String columnFamily = configuration.get(ConfigConstants.COLUMN_FAMILY);
    byte[] tableName = configuration.get(ConfigConstants.TABLE_NAME).getBytes();
    HColumnDescriptor columnDescriptor = new HColumnDescriptor(columnFamily);
    HBaseAdmin admin = new HBaseAdmin(configuration);
    columnDescriptor.setBloomFilterType(StoreFile.BloomType.ROW).setDataBlockEncoding(DataBlockEncoding.PREFIX).setMaxVersions(1);
    if (!admin.tableExists(tableName)) {
        logger.info("Creating HBase table");
        tableDescriptor = new HTableDescriptor(tableName);
        tableDescriptor.addFamily(columnDescriptor);
        admin.createTable(tableDescriptor);
    }
    tableDescriptor = admin.getTableDescriptor(tableName);
    if (!tableDescriptor.hasFamily(columnFamily.getBytes())) {
        logger.info("Adding column family to HBase table");
        if (!admin.isTableDisabled(tableName)) {
            logger.info("Disabling HBase table");
            admin.disableTable(tableName);
        }
        admin.addColumn(tableName, columnDescriptor);
    }
    if (admin.isTableDisabled(tableName)) {
        logger.info("Enabling HBase table");
        admin.enableTable(tableName);
    }
    try {
        admin.flush(tableName);
    } catch (InterruptedException e) {
        logger.warn("HBaseAdmin flush was interrupted. Retrying.");
        try {
            admin.flush(tableName);
        } catch (InterruptedException e1) {
            throw new RuntimeException(e1);
        }
    }
    logger.info("HBase table successfully initialized.");
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 3 with ZooKeeperConnectionException

use of org.apache.hadoop.hbase.ZooKeeperConnectionException in project atlas by apache.

the class HBaseStoreManager method getLocalKeyPartition.

@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    List<KeyRange> result = new LinkedList<>();
    TableMask table = null;
    try {
        ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
        table = cnx.getTable(tableName);
        HTable hTable = (HTable) table.getTableObject();
        Map<KeyRange, ServerName> normed = normalizeKeyBounds(hTable.getRegionLocations());
        for (Map.Entry<KeyRange, ServerName> e : normed.entrySet()) {
            if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
                result.add(e.getKey());
                logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
            } else {
                logger.debug("Discarding remote {}", e.getValue());
            }
        }
    } catch (MasterNotRunningException e) {
        logger.warn("Unexpected MasterNotRunningException", e);
    } catch (ZooKeeperConnectionException e) {
        logger.warn("Unexpected ZooKeeperConnectionException", e);
    } catch (IOException e) {
        logger.warn("Unexpected IOException", e);
    } finally {
        IOUtils.closeQuietly(table);
    }
    return result;
}
Also used : KeyRange(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeyRange) ServerName(org.apache.hadoop.hbase.ServerName) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) HTable(org.apache.hadoop.hbase.client.HTable) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) LinkedList(java.util.LinkedList)

Example 4 with ZooKeeperConnectionException

use of org.apache.hadoop.hbase.ZooKeeperConnectionException in project incubator-atlas by apache.

the class HBaseStoreManager method getLocalKeyPartition.

@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    List<KeyRange> result = new LinkedList<>();
    TableMask table = null;
    try {
        ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
        table = cnx.getTable(tableName);
        HTable hTable = (HTable) table.getTableObject();
        Map<KeyRange, ServerName> normed = normalizeKeyBounds(hTable.getRegionLocations());
        for (Map.Entry<KeyRange, ServerName> e : normed.entrySet()) {
            if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
                result.add(e.getKey());
                logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
            } else {
                logger.debug("Discarding remote {}", e.getValue());
            }
        }
    } catch (MasterNotRunningException e) {
        logger.warn("Unexpected MasterNotRunningException", e);
    } catch (ZooKeeperConnectionException e) {
        logger.warn("Unexpected ZooKeeperConnectionException", e);
    } catch (IOException e) {
        logger.warn("Unexpected IOException", e);
    } finally {
        IOUtils.closeQuietly(table);
    }
    return result;
}
Also used : KeyRange(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeyRange) ServerName(org.apache.hadoop.hbase.ServerName) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) HTable(org.apache.hadoop.hbase.client.HTable) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) LinkedList(java.util.LinkedList)

Example 5 with ZooKeeperConnectionException

use of org.apache.hadoop.hbase.ZooKeeperConnectionException in project janusgraph by JanusGraph.

the class HBaseStoreManager method getLocalKeyPartition.

@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    List<KeyRange> result = new LinkedList<>();
    try {
        if (skipSchemaCheck) {
            logger.debug("Skipping schema check");
            if (!exists())
                throw new PermanentBackendException("Table " + tableName + " doesn't exist in HBase!");
        } else {
            logger.debug("Performing schema check");
            ensureTableExists(tableName, getCfNameForStoreName(GraphDatabaseConfiguration.SYSTEM_PROPERTIES_STORE_NAME), 0);
        }
        Map<KeyRange, ServerName> normed = normalizeKeyBounds(getRegionLocations(tableName));
        for (Map.Entry<KeyRange, ServerName> e : normed.entrySet()) {
            if (NetworkUtil.isLocalConnection(e.getValue().getHostname())) {
                result.add(e.getKey());
                logger.debug("Found local key/row partition {} on host {}", e.getKey(), e.getValue());
            } else {
                logger.debug("Discarding remote {}", e.getValue());
            }
        }
    } catch (MasterNotRunningException e) {
        logger.warn("Unexpected MasterNotRunningException", e);
    } catch (ZooKeeperConnectionException e) {
        logger.warn("Unexpected ZooKeeperConnectionException", e);
    } catch (IOException e) {
        logger.warn("Unexpected IOException", e);
    }
    return result;
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) KeyRange(org.janusgraph.diskstorage.keycolumnvalue.KeyRange) ServerName(org.apache.hadoop.hbase.ServerName) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) LinkedList(java.util.LinkedList)

Aggregations

ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)12 IOException (java.io.IOException)9 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)7 BiMap (com.google.common.collect.BiMap)4 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)4 Configuration (org.apache.hadoop.conf.Configuration)4 ServerName (org.apache.hadoop.hbase.ServerName)4 KeeperException (org.apache.zookeeper.KeeperException)4 KeyRange (com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeyRange)3 NavigableMap (java.util.NavigableMap)3 HTable (org.apache.hadoop.hbase.client.HTable)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)2 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)2 InterruptedIOException (java.io.InterruptedIOException)1