Search in sources :

Example 1 with MasterNotRunningException

use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.

the class ConnectionImplementation method checkIfBaseNodeAvailable.

private void checkIfBaseNodeAvailable(ZooKeeperWatcher zkw) throws MasterNotRunningException {
    String errorMsg;
    try {
        if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {
            errorMsg = "The node " + zkw.znodePaths.baseZNode + " is not in ZooKeeper. " + "It should have been written by the master. " + "Check the value configured in 'zookeeper.znode.parent'. " + "There could be a mismatch with the one configured in the master.";
            LOG.error(errorMsg);
            throw new MasterNotRunningException(errorMsg);
        }
    } catch (KeeperException e) {
        errorMsg = "Can't get connection to ZooKeeper: " + e.getMessage();
        LOG.error(errorMsg);
        throw new MasterNotRunningException(errorMsg, e);
    }
}
Also used : MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) KeeperException(org.apache.zookeeper.KeeperException)

Example 2 with MasterNotRunningException

use of org.apache.hadoop.hbase.MasterNotRunningException in project hbase by apache.

the class TestClientTimeouts method testAdminTimeout.

/**
   * Test that a client that fails an RPC to the master retries properly and
   * doesn't throw any unexpected exceptions.
   * @throws Exception
   */
@Test
public void testAdminTimeout() throws Exception {
    boolean lastFailed = false;
    int initialInvocations = RandomTimeoutBlockingRpcChannel.invokations.get();
    RandomTimeoutRpcClient rpcClient = (RandomTimeoutRpcClient) RpcClientFactory.createClient(TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey());
    try {
        for (int i = 0; i < 5 || (lastFailed && i < 100); ++i) {
            lastFailed = false;
            // Ensure the HBaseAdmin uses a new connection by changing Configuration.
            Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration());
            conf.set(HConstants.HBASE_CLIENT_INSTANCE_ID, String.valueOf(-1));
            Admin admin = null;
            Connection connection = null;
            try {
                connection = ConnectionFactory.createConnection(conf);
                admin = connection.getAdmin();
                // run some admin commands
                HBaseAdmin.available(conf);
                admin.setBalancerRunning(false, false);
            } catch (MasterNotRunningException ex) {
                // Since we are randomly throwing SocketTimeoutExceptions, it is possible to get
                // a MasterNotRunningException.  It's a bug if we get other exceptions.
                lastFailed = true;
            } finally {
                if (admin != null) {
                    admin.close();
                    if (admin.getConnection().isClosed()) {
                        rpcClient = (RandomTimeoutRpcClient) RpcClientFactory.createClient(TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey());
                    }
                }
                if (connection != null) {
                    connection.close();
                }
            }
        }
        // Ensure the RandomTimeoutRpcEngine is actually being used.
        assertFalse(lastFailed);
        assertTrue(RandomTimeoutBlockingRpcChannel.invokations.get() > initialInvocations);
    } finally {
        rpcClient.close();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) Test(org.junit.Test)

Example 3 with MasterNotRunningException

use of org.apache.hadoop.hbase.MasterNotRunningException 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 4 with MasterNotRunningException

use of org.apache.hadoop.hbase.MasterNotRunningException 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 5 with MasterNotRunningException

use of org.apache.hadoop.hbase.MasterNotRunningException 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)

Aggregations

MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)10 IOException (java.io.IOException)5 ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)5 Configuration (org.apache.hadoop.conf.Configuration)4 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 BiMap (com.google.common.collect.BiMap)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 KeyRange (com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeyRange)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 NavigableMap (java.util.NavigableMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ServerName (org.apache.hadoop.hbase.ServerName)2 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)2 HTable (org.apache.hadoop.hbase.client.HTable)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1