當前位置: 首頁>>代碼示例>>Java>>正文


Java HConstants.ZOOKEEPER_ZNODE_PARENT屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HConstants.ZOOKEEPER_ZNODE_PARENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java HConstants.ZOOKEEPER_ZNODE_PARENT屬性的具體用法?Java HConstants.ZOOKEEPER_ZNODE_PARENT怎麽用?Java HConstants.ZOOKEEPER_ZNODE_PARENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.hbase.HConstants的用法示例。


在下文中一共展示了HConstants.ZOOKEEPER_ZNODE_PARENT屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transformClusterKey

/**
 * Separate the given key into the three configurations it should contain:
 * hbase.zookeeper.quorum, hbase.zookeeper.client.port
 * and zookeeper.znode.parent
 * @param key
 * @return the three configuration in the described order
 * @throws IOException
 */
public static ZKClusterKey transformClusterKey(String key) throws IOException {
  String[] parts = key.split(":");

  if (parts.length == 3) {
    return new ZKClusterKey(parts [0], Integer.parseInt(parts [1]), parts [2]);
  }

  if (parts.length > 3) {
    // The quorum could contain client port in server:clientport format, try to transform more.
    String zNodeParent = parts [parts.length - 1];
    String clientPort = parts [parts.length - 2];

    // The first part length is the total length minus the lengths of other parts and minus 2 ":"
    int endQuorumIndex = key.length() - zNodeParent.length() - clientPort.length() - 2;
    String quorumStringInput = key.substring(0, endQuorumIndex);
    String[] serverHosts = quorumStringInput.split(",");

    // The common case is that every server has its own client port specified - this means
    // that (total parts - the ZNodeParent part - the ClientPort part) is equal to
    // (the number of "," + 1) - "+ 1" because the last server has no ",".
    if ((parts.length - 2) == (serverHosts.length + 1)) {
      return new ZKClusterKey(quorumStringInput, Integer.parseInt(clientPort), zNodeParent);
    }

    // For the uncommon case that some servers has no port specified, we need to build the
    // server:clientport list using default client port for servers without specified port.
    return new ZKClusterKey(
        buildZKQuorumServerString(serverHosts, clientPort),
        Integer.parseInt(clientPort),
        zNodeParent);
  }

  throw new IOException("Cluster key passed " + key + " is invalid, the format should be:" +
      HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
      + HConstants.ZOOKEEPER_ZNODE_PARENT);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:44,代碼來源:ZKConfig.java


注:本文中的org.apache.hadoop.hbase.HConstants.ZOOKEEPER_ZNODE_PARENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。