org.apache.hadoop.hbase.zookeeper.ZKUtil.applyClusterKeyToConf()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.applyClusterKeyToConf()方法的一些代码示例,展示了ZKUtil.applyClusterKeyToConf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.applyClusterKeyToConf()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:applyClusterKeyToConf

ZKUtil.applyClusterKeyToConf介绍

[英]Apply the settings in the given key to the given configuration, this is used to communicate with distant clusters
[中]将给定键中的设置应用于给定配置,这用于与远程集群通信

代码示例

代码示例来源:origin: twitter/ambrose

  1. static Configuration initHBaseConfiguration(Configuration jobConf) {
  2. // setup hraven hbase connection information
  3. Configuration hbaseConf = null;
  4. String hravenDir = System.getenv(HRAVEN_HBASE_CONF_DIR_ENV);
  5. if (hravenDir != null && !hravenDir.isEmpty()) {
  6. hbaseConf = new Configuration(false);
  7. Path hbaseConfFile = new Path(hravenDir, HRAVEN_HBASE_CONF_FILE);
  8. LOG.info("Loading hRaven HBase configuration from " + hbaseConfFile.toString());
  9. hbaseConf.addResource(hbaseConfFile);
  10. } else {
  11. hbaseConf = HBaseConfiguration.create();
  12. // override any hRaven connection properties from the job
  13. String hbaseZKQuorum = jobConf.get(HRAVEN_ZOOKEEPER_QUORUM);
  14. if (hbaseZKQuorum != null && !hbaseZKQuorum.isEmpty()) {
  15. try {
  16. LOG.info("Applying hRaven Zookeeper quorum information from job conf: " + hbaseZKQuorum);
  17. ZKUtil.applyClusterKeyToConf(hbaseConf, hbaseZKQuorum);
  18. } catch (IOException ioe) {
  19. throw new RuntimeException("Invalid cluster configuration for "
  20. + HRAVEN_ZOOKEEPER_QUORUM + " (\"" + hbaseZKQuorum + "\")");
  21. }
  22. } else if (LOG.isDebugEnabled()) {
  23. LOG.debug("No cluster configuration found for " + HRAVEN_ZOOKEEPER_QUORUM
  24. + ", continuing with default");
  25. }
  26. }
  27. return hbaseConf;
  28. }

代码示例来源:origin: XiaoMi/themis

  1. @Override
  2. public void setConf(Configuration otherConf) {
  3. this.conf = HBaseConfiguration.create(otherConf);
  4. String tableName = this.conf.get(OUTPUT_TABLE);
  5. if(tableName == null || tableName.length() <= 0) {
  6. throw new IllegalArgumentException("Must specify table name");
  7. }
  8. String address = this.conf.get(QUORUM_ADDRESS);
  9. int zkClientPort = conf.getInt(QUORUM_PORT, 0);
  10. String serverClass = this.conf.get(REGION_SERVER_CLASS);
  11. String serverImpl = this.conf.get(REGION_SERVER_IMPL);
  12. try {
  13. if (address != null) {
  14. ZKUtil.applyClusterKeyToConf(this.conf, address);
  15. }
  16. if (serverClass != null) {
  17. this.conf.set(HConstants.REGION_SERVER_CLASS, serverClass);
  18. this.conf.set(HConstants.REGION_SERVER_IMPL, serverImpl);
  19. }
  20. if (zkClientPort != 0) {
  21. conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort);
  22. }
  23. this.tableName = Bytes.toBytes(tableName);
  24. LOG.info("Do Themis Write for table: " + tableName);
  25. } catch(IOException e) {
  26. LOG.error(e);
  27. throw new RuntimeException(e);
  28. }
  29. }
  30. }

代码示例来源:origin: co.cask.hbase/hbase

  1. try {
  2. if (address != null) {
  3. ZKUtil.applyClusterKeyToConf(this.conf, address);

代码示例来源:origin: co.cask.hbase/hbase

  1. /**
  2. * Helper method to connect to a peer
  3. * @param peerId peer's identifier
  4. * @return object representing the peer
  5. * @throws IOException
  6. * @throws KeeperException
  7. */
  8. public ReplicationPeer getPeer(String peerId) throws IOException, KeeperException{
  9. String znode = ZKUtil.joinZNode(this.peersZNode, peerId);
  10. byte [] data = ZKUtil.getData(this.zookeeper, znode);
  11. String otherClusterKey = Bytes.toString(data);
  12. if (this.ourClusterKey.equals(otherClusterKey)) {
  13. LOG.debug("Not connecting to " + peerId + " because it's us");
  14. return null;
  15. }
  16. // Construct the connection to the new peer
  17. Configuration otherConf = new Configuration(this.conf);
  18. try {
  19. ZKUtil.applyClusterKeyToConf(otherConf, otherClusterKey);
  20. } catch (IOException e) {
  21. LOG.error("Can't get peer because:", e);
  22. return null;
  23. }
  24. ReplicationPeer peer = new ReplicationPeer(otherConf, peerId,
  25. otherClusterKey);
  26. peer.startStateTracker(this.zookeeper, this.getPeerStateNode(peerId));
  27. return peer;
  28. }

相关文章