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;
}
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.");
}
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;
}
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;
}
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;
}
Aggregations