Search in sources :

Example 1 with MetaRegionServer

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer in project hbase by apache.

the class MetaTableLocator method setMetaLocation.

/**
   * Sets the location of <code>hbase:meta</code> in ZooKeeper to the
   * specified server address.
   * @param zookeeper
   * @param serverName
   * @param replicaId
   * @param state
   * @throws KeeperException
   */
public static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName serverName, int replicaId, RegionState.State state) throws KeeperException {
    LOG.info("Setting hbase:meta region location in ZooKeeper as " + serverName);
    // Make the MetaRegionServer pb and then get its bytes and save this as
    // the znode content.
    MetaRegionServer pbrsr = MetaRegionServer.newBuilder().setServer(ProtobufUtil.toServerName(serverName)).setRpcVersion(HConstants.RPC_CURRENT_VERSION).setState(state.convert()).build();
    byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());
    try {
        ZKUtil.setData(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
    } catch (KeeperException.NoNodeException nne) {
        if (replicaId == HRegionInfo.DEFAULT_REPLICA_ID) {
            LOG.debug("META region location doesn't exist, create it");
        } else {
            LOG.debug("META region location doesn't exist for replicaId " + replicaId + ", create it");
        }
        ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
    }
}
Also used : MetaRegionServer(org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer) KeeperException(org.apache.zookeeper.KeeperException)

Example 2 with MetaRegionServer

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer in project hbase by apache.

the class MetaTableLocator method setMetaLocation.

/**
 * Sets the location of <code>hbase:meta</code> in ZooKeeper to the specified server address.
 * @param zookeeper reference to the {@link ZKWatcher} which also contains configuration and
 *                  operation
 * @param serverName the name of the server
 * @param replicaId the ID of the replica
 * @param state the state of the region
 * @throws KeeperException if a ZooKeeper operation fails
 */
public static void setMetaLocation(ZKWatcher zookeeper, ServerName serverName, int replicaId, RegionState.State state) throws KeeperException {
    if (serverName == null) {
        LOG.warn("Tried to set null ServerName in hbase:meta; skipping -- ServerName required");
        return;
    }
    LOG.info("Setting hbase:meta replicaId={} location in ZooKeeper as {}, state={}", replicaId, serverName, state);
    // Make the MetaRegionServer pb and then get its bytes and save this as
    // the znode content.
    MetaRegionServer pbrsr = MetaRegionServer.newBuilder().setServer(ProtobufUtil.toServerName(serverName)).setRpcVersion(HConstants.RPC_CURRENT_VERSION).setState(state.convert()).build();
    byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());
    try {
        ZKUtil.setData(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId), data);
    } catch (KeeperException.NoNodeException nne) {
        if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {
            LOG.debug("hbase:meta region location doesn't exist, create it");
        } else {
            LOG.debug("hbase:meta region location doesn't exist for replicaId=" + replicaId + ", create it");
        }
        ZKUtil.createAndWatch(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId), data);
    }
}
Also used : MetaRegionServer(org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

MetaRegionServer (org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer)2 KeeperException (org.apache.zookeeper.KeeperException)2