本文整理汇总了Java中org.apache.hadoop.hbase.util.Addressing.createHostAndPortStr方法的典型用法代码示例。如果您正苦于以下问题:Java Addressing.createHostAndPortStr方法的具体用法?Java Addressing.createHostAndPortStr怎么用?Java Addressing.createHostAndPortStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.Addressing
的用法示例。
在下文中一共展示了Addressing.createHostAndPortStr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHostnamePort
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return String made of hostname and port formatted as per {@link Addressing#createHostAndPortStr(String, int)}
*/
public synchronized String getHostnamePort() {
if (this.cachedHostnamePort == null) {
this.cachedHostnamePort =
Addressing.createHostAndPortStr(this.hostname, this.port);
}
return this.cachedHostnamePort;
}
示例2: getHostnamePort
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return String made of hostname and port formatted as per {@link Addressing#createHostAndPortStr(String, int)}
*/
public String getHostnamePort() {
return Addressing.createHostAndPortStr(this.getHostname(), this.getPort());
}
示例3: getHRegionConnection
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* Either the passed <code>isa</code> is null or <code>hostname</code>
* can be but not both.
* @param hostname
* @param port
* @param isa
* @param master
* @return Proxy.
* @throws IOException
*/
HRegionInterface getHRegionConnection(final String hostname, final int port,
final InetSocketAddress isa, final boolean master)
throws IOException {
if (master) getMaster();
HRegionInterface server;
String rsName = null;
if (isa != null) {
rsName = Addressing.createHostAndPortStr(isa.getHostName(),
isa.getPort());
} else {
rsName = Addressing.createHostAndPortStr(hostname, port);
}
ensureZookeeperTrackers();
// See if we already have a connection (common case)
server = this.servers.get(rsName);
if (server == null) {
// create a unique lock for this RS (if necessary)
this.connectionLock.putIfAbsent(rsName, rsName);
// get the RS lock
synchronized (this.connectionLock.get(rsName)) {
// do one more lookup in case we were stalled above
server = this.servers.get(rsName);
if (server == null) {
try {
// Only create isa when we need to.
InetSocketAddress address = isa != null? isa:
new InetSocketAddress(hostname, port);
// definitely a cache miss. establish an RPC for this RS
server = HBaseRPC.waitForProxy(this.rpcEngine,
serverInterfaceClass, HRegionInterface.VERSION,
address, this.conf,
this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout);
this.servers.put(Addressing.createHostAndPortStr(
address.getHostName(), address.getPort()), server);
} catch (RemoteException e) {
LOG.warn("RemoteException connecting to RS", e);
// Throw what the RemoteException was carrying.
throw e.unwrapRemoteException();
}
}
}
}
return server;
}
示例4: getProtocol
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* Either the passed <code>isa</code> is null or <code>hostname</code>
* can be but not both.
* @param hostname
* @param port
* @param protocolClass
* @param version
* @return Proxy.
* @throws IOException
*/
IpcProtocol getProtocol(final String hostname,
final int port, final Class <? extends IpcProtocol> protocolClass)
throws IOException {
String rsName = Addressing.createHostAndPortStr(hostname, port);
// See if we already have a connection (common case)
Map<String, IpcProtocol> protocols = this.servers.get(rsName);
if (protocols == null) {
protocols = new HashMap<String, IpcProtocol>();
Map<String, IpcProtocol> existingProtocols =
this.servers.putIfAbsent(rsName, protocols);
if (existingProtocols != null) {
protocols = existingProtocols;
}
}
String protocol = protocolClass.getName();
IpcProtocol server = protocols.get(protocol);
//@Daidong This is an obvious double check strategy to reduce the
//contentions.
if (server == null) {
// create a unique lock for this RS + protocol (if necessary)
String lockKey = protocol + "@" + rsName;
this.connectionLock.putIfAbsent(lockKey, lockKey);
// get the RS lock
synchronized (this.connectionLock.get(lockKey)) {
// do one more lookup in case we were stalled above
server = protocols.get(protocol);
if (server == null) {
try {
// Only create isa when we need to.
InetSocketAddress address = new InetSocketAddress(hostname, port);
// definitely a cache miss. establish an RPC for this RS
server = HBaseClientRPC.waitForProxy(
protocolClass, address, this.conf,
this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout);
protocols.put(protocol, server);
} catch (RemoteException e) {
LOG.warn("RemoteException connecting to RS", e);
// Throw what the RemoteException was carrying.
throw e.unwrapRemoteException();
}
}
}
}
return server;
}
示例5: toShortString
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return Return a SHORT version of {@link ServerName#toString()}, one that has the host only,
* minus the domain, and the port only -- no start code; the String is for us internally mostly
* tying threads to their server. Not for external use. It is lossy and will not work in
* in compares, etc.
*/
public String toShortString() {
return Addressing.createHostAndPortStr(getHostNameMinusDomain(this.hostnameOnly), this.port);
}
示例6: getHostAndPort
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return Hostname and port formatted as described at
* {@link Addressing#createHostAndPortStr(String, int)}
*/
public String getHostAndPort() {
return Addressing.createHostAndPortStr(this.hostnameOnly, this.port);
}
示例7: getHostAndPort
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return Hostname and port formatted as described at
* {@link Addressing#createHostAndPortStr(String, int)}
*/
public String getHostAndPort() {
return Addressing.createHostAndPortStr(this.hostname, this.port);
}
示例8: getHostnamePort
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return String made of hostname and port formatted as
* per {@link Addressing#createHostAndPortStr(String, int)}
*/
public String getHostnamePort() {
return Addressing.createHostAndPortStr(this.getHostname(), this.getPort());
}
示例9: toShortString
import org.apache.hadoop.hbase.util.Addressing; //导入方法依赖的package包/类
/**
* @return Return a SHORT version of {@link ServerName#toString()}, one that has the host only,
* minus the domain, and the port only -- no start code; the String is for us internally mostly
* tying threads to their server. Not for external use. It is lossy and will not work in
* in compares, etc.
*/
public String toShortString() {
return Addressing.createHostAndPortStr(
getHostNameMinusDomain(this.address.getHostname()),
this.address.getPort());
}