• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MetaRegionServer类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.MetaRegionServer的典型用法代码示例。如果您正苦于以下问题:Java MetaRegionServer类的具体用法?Java MetaRegionServer怎么用?Java MetaRegionServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MetaRegionServer类属于org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos包,在下文中一共展示了MetaRegionServer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setMetaLocation

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.MetaRegionServer; //导入依赖的package包/类
/**
 * 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.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.getZNodeForReplica(replicaId), data);
  }
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:32,
代码来源:MetaTableLocator.java

示例2: setMetaLocation

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.MetaRegionServer; //导入依赖的package包/类
/**
 * Sets the location of <code>hbase:meta</code> in ZooKeeper to the
 * specified server address.
 * @param zookeeper zookeeper reference
 * @param serverName The server hosting <code>hbase:meta</code>
 * @param state The region transition state
 * @throws KeeperException unexpected zookeeper exception
 */
public static void setMetaLocation(ZooKeeperWatcher zookeeper,
    ServerName serverName, 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.metaServerZNode, data);
  } catch(KeeperException.NoNodeException nne) {
    LOG.debug("META region location doesn't existed, create it");
    ZKUtil.createAndWatch(zookeeper, zookeeper.metaServerZNode, data);
  }
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:26,
代码来源:MetaTableLocator.java

示例3: parseFrom

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.MetaRegionServer; //导入依赖的package包/类
/**
 * Get a ServerName from the passed in data bytes.
 * @param data Data with a serialize server name in it; can handle the old style
 * servername where servername was host and port.  Works too with data that
 * begins w/ the pb 'PBUF' magic and that is then followed by a protobuf that
 * has a serialized {@link ServerName} in it.
 * @return Returns null if <code>data</code> is null else converts passed data
 * to a ServerName instance.
 * @throws DeserializationException 
 */
public static ServerName parseFrom(final byte [] data) throws DeserializationException {
  if (data == null || data.length <= 0) return null;
  if (ProtobufUtil.isPBMagicPrefix(data)) {
    int prefixLen = ProtobufUtil.lengthOfPBMagic();
    try {
      MetaRegionServer rss =
        MetaRegionServer.PARSER.parseFrom(data, prefixLen, data.length - prefixLen);
      org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName sn = rss.getServer();
      return valueOf(sn.getHostName(), sn.getPort(), sn.getStartCode());
    } catch (InvalidProtocolBufferException e) {
      // A failed parse of the znode is pretty catastrophic. Rather than loop
      // retrying hoping the bad bytes will changes, and rather than change
      // the signature on this method to add an IOE which will send ripples all
      // over the code base, throw a RuntimeException.  This should "never" happen.
      // Fail fast if it does.
      throw new DeserializationException(e);
    }
  }
  // The str returned could be old style -- pre hbase-1502 -- which was
  // hostname and port seperated by a colon rather than hostname, port and
  // startcode delimited by a ','.
  String str = Bytes.toString(data);
  int index = str.indexOf(ServerName.SERVERNAME_SEPARATOR);
  if (index != -1) {
    // Presume its ServerName serialized with versioned bytes.
    return ServerName.parseVersionedServerName(data);
  }
  // Presume it a hostname:port format.
  String hostname = Addressing.parseHostname(str);
  int port = Addressing.parsePort(str);
  return valueOf(hostname, port, -1L);
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:43,
代码来源:ServerName.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)