本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.applyClusterKeyToConf()
方法的一些代码示例,展示了ZKUtil.applyClusterKeyToConf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.applyClusterKeyToConf()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:applyClusterKeyToConf
[英]Apply the settings in the given key to the given configuration, this is used to communicate with distant clusters
[中]将给定键中的设置应用于给定配置,这用于与远程集群通信
代码示例来源:origin: twitter/ambrose
static Configuration initHBaseConfiguration(Configuration jobConf) {
// setup hraven hbase connection information
Configuration hbaseConf = null;
String hravenDir = System.getenv(HRAVEN_HBASE_CONF_DIR_ENV);
if (hravenDir != null && !hravenDir.isEmpty()) {
hbaseConf = new Configuration(false);
Path hbaseConfFile = new Path(hravenDir, HRAVEN_HBASE_CONF_FILE);
LOG.info("Loading hRaven HBase configuration from " + hbaseConfFile.toString());
hbaseConf.addResource(hbaseConfFile);
} else {
hbaseConf = HBaseConfiguration.create();
// override any hRaven connection properties from the job
String hbaseZKQuorum = jobConf.get(HRAVEN_ZOOKEEPER_QUORUM);
if (hbaseZKQuorum != null && !hbaseZKQuorum.isEmpty()) {
try {
LOG.info("Applying hRaven Zookeeper quorum information from job conf: " + hbaseZKQuorum);
ZKUtil.applyClusterKeyToConf(hbaseConf, hbaseZKQuorum);
} catch (IOException ioe) {
throw new RuntimeException("Invalid cluster configuration for "
+ HRAVEN_ZOOKEEPER_QUORUM + " (\"" + hbaseZKQuorum + "\")");
}
} else if (LOG.isDebugEnabled()) {
LOG.debug("No cluster configuration found for " + HRAVEN_ZOOKEEPER_QUORUM
+ ", continuing with default");
}
}
return hbaseConf;
}
代码示例来源:origin: XiaoMi/themis
@Override
public void setConf(Configuration otherConf) {
this.conf = HBaseConfiguration.create(otherConf);
String tableName = this.conf.get(OUTPUT_TABLE);
if(tableName == null || tableName.length() <= 0) {
throw new IllegalArgumentException("Must specify table name");
}
String address = this.conf.get(QUORUM_ADDRESS);
int zkClientPort = conf.getInt(QUORUM_PORT, 0);
String serverClass = this.conf.get(REGION_SERVER_CLASS);
String serverImpl = this.conf.get(REGION_SERVER_IMPL);
try {
if (address != null) {
ZKUtil.applyClusterKeyToConf(this.conf, address);
}
if (serverClass != null) {
this.conf.set(HConstants.REGION_SERVER_CLASS, serverClass);
this.conf.set(HConstants.REGION_SERVER_IMPL, serverImpl);
}
if (zkClientPort != 0) {
conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort);
}
this.tableName = Bytes.toBytes(tableName);
LOG.info("Do Themis Write for table: " + tableName);
} catch(IOException e) {
LOG.error(e);
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: co.cask.hbase/hbase
try {
if (address != null) {
ZKUtil.applyClusterKeyToConf(this.conf, address);
代码示例来源:origin: co.cask.hbase/hbase
/**
* Helper method to connect to a peer
* @param peerId peer's identifier
* @return object representing the peer
* @throws IOException
* @throws KeeperException
*/
public ReplicationPeer getPeer(String peerId) throws IOException, KeeperException{
String znode = ZKUtil.joinZNode(this.peersZNode, peerId);
byte [] data = ZKUtil.getData(this.zookeeper, znode);
String otherClusterKey = Bytes.toString(data);
if (this.ourClusterKey.equals(otherClusterKey)) {
LOG.debug("Not connecting to " + peerId + " because it's us");
return null;
}
// Construct the connection to the new peer
Configuration otherConf = new Configuration(this.conf);
try {
ZKUtil.applyClusterKeyToConf(otherConf, otherClusterKey);
} catch (IOException e) {
LOG.error("Can't get peer because:", e);
return null;
}
ReplicationPeer peer = new ReplicationPeer(otherConf, peerId,
otherClusterKey);
peer.startStateTracker(this.zookeeper, this.getPeerStateNode(peerId));
return peer;
}
内容来源于网络,如有侵权,请联系作者删除!