本文整理了Java中org.apache.hadoop.hbase.net.Address.getPort()
方法的一些代码示例,展示了Address.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getPort()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.net.Address
类名称:Address
方法名:getPort
暂无
代码示例来源:origin: apache/hbase
public int getPort() {
return this.address.getPort();
}
代码示例来源:origin: apache/hbase
@Override
public int compareTo(Address that) {
int compare = this.getHostname().compareTo(that.getHostname());
if (compare != 0) return compare;
return this.getPort() - that.getPort();
}
}
代码示例来源:origin: apache/hbase
@Override
// Don't use HostAndPort equals... It is wonky including
// ipv6 brackets
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other instanceof Address) {
Address that = (Address)other;
return this.getHostname().equals(that.getHostname()) &&
this.getPort() == that.getPort();
}
return false;
}
代码示例来源:origin: apache/hbase
@Override
public int hashCode() {
return this.getHostname().hashCode() ^ getPort();
}
代码示例来源:origin: apache/hbase
private ServerName(final Address address, final long startcode) {
// Use HostAndPort to host port and hostname. Does validation and can do ipv6
this.address = address;
this.startcode = startcode;
this.servername = getServerName(this.address.getHostname(),
this.address.getPort(), startcode);
}
代码示例来源:origin: apache/hbase
/**
* Remove the servername whose hostname and port portion matches from the passed array of servers.
* Returns as side-effect the servername removed.
* @return server removed from list of Region Servers
*/
private ServerName stripServer(List<ServerName> regionServers, String hostname, int port) {
for (Iterator<ServerName> iter = regionServers.iterator(); iter.hasNext();) {
ServerName server = iter.next();
if (server.getAddress().getHostname().equalsIgnoreCase(hostname) &&
server.getAddress().getPort() == port) {
iter.remove();
return server;
}
}
return null;
}
代码示例来源:origin: apache/hbase
/**
* @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());
}
代码示例来源:origin: apache/hbase
/**
* If hostname is a.b.c and the port is 123, return a:123 instead of a.b.c:123.
* @return if host looks like it is resolved -- not an IP -- then strip the domain portion
* otherwise returns same as {@link #toString()}}
*/
public String toStringWithoutDomain() {
String hostname = getHostname();
String [] parts = hostname.split("\\.");
if (parts.length > 1) {
for (String part: parts) {
if (!StringUtils.isNumeric(part)) {
return Address.fromParts(parts[0], getPort()).toString();
}
}
}
return toString();
}
代码示例来源:origin: apache/hbase
static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
List<HBaseProtos.TableName> tables = new ArrayList<>(pojo.getTables().size());
for(TableName arg: pojo.getTables()) {
tables.add(ProtobufUtil.toProtoTableName(arg));
}
List<HBaseProtos.ServerName> hostports = new ArrayList<>(pojo.getServers().size());
for(Address el: pojo.getServers()) {
hostports.add(HBaseProtos.ServerName.newBuilder()
.setHostName(el.getHostname())
.setPort(el.getPort())
.build());
}
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName())
.addAllServers(hostports)
.addAllTables(tables).build();
}
}
代码示例来源:origin: apache/hbase
@Override
public void removeServers(Set<Address> servers) throws IOException {
Set<HBaseProtos.ServerName> hostPorts = Sets.newHashSet();
for(Address el: servers) {
hostPorts.add(HBaseProtos.ServerName.newBuilder()
.setHostName(el.getHostname())
.setPort(el.getPort())
.build());
}
RemoveServersRequest request = RemoveServersRequest.newBuilder()
.addAllServers(hostPorts)
.build();
try {
stub.removeServers(null, request);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void moveServers(Set<Address> servers, String targetGroup) throws IOException {
Set<HBaseProtos.ServerName> hostPorts = Sets.newHashSet();
for(Address el: servers) {
hostPorts.add(HBaseProtos.ServerName.newBuilder()
.setHostName(el.getHostname())
.setPort(el.getPort())
.build());
}
MoveServersRequest request = MoveServersRequest.newBuilder()
.setTargetGroup(targetGroup)
.addAllServers(hostPorts)
.build();
try {
stub.moveServers(null, request);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
代码示例来源:origin: apache/hbase
@Override
public RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException {
GetRSGroupInfoOfServerRequest request = GetRSGroupInfoOfServerRequest.newBuilder()
.setServer(HBaseProtos.ServerName.newBuilder()
.setHostName(hostPort.getHostname())
.setPort(hostPort.getPort())
.build())
.build();
try {
GetRSGroupInfoOfServerResponse resp = stub.getRSGroupInfoOfServer(null, request);
if (resp.hasRSGroupInfo()) {
return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
}
return null;
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
代码示例来源:origin: apache/hbase
@Override
public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String targetGroup)
throws IOException {
MoveServersAndTablesRequest.Builder builder =
MoveServersAndTablesRequest.newBuilder().setTargetGroup(targetGroup);
for(Address el: servers) {
builder.addServers(HBaseProtos.ServerName.newBuilder()
.setHostName(el.getHostname())
.setPort(el.getPort())
.build());
}
for(TableName tableName: tables) {
builder.addTableName(ProtobufUtil.toProtoTableName(tableName));
if (!admin.tableExists(tableName)) {
throw new TableNotFoundException(tableName);
}
}
try {
stub.moveServersAndTables(null, builder.build());
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
代码示例来源:origin: org.apache.hbase/hbase-common
@Override
public int hashCode() {
return this.getHostname().hashCode() ^ getPort();
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
@Override
public int compareTo(Address that) {
int compare = this.getHostname().compareTo(that.getHostname());
if (compare != 0) return compare;
return this.getPort() - that.getPort();
}
}
代码示例来源:origin: org.apache.hbase/hbase-common
@Override
public int compareTo(Address that) {
int compare = this.getHostname().compareTo(that.getHostname());
if (compare != 0) return compare;
return this.getPort() - that.getPort();
}
}
代码示例来源:origin: org.apache.hbase/hbase-common
private ServerName(final Address address, final long startcode) {
// Use HostAndPort to host port and hostname. Does validation and can do ipv6
this.address = address;
this.startcode = startcode;
this.servername = getServerName(this.address.getHostname(),
this.address.getPort(), startcode);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
private ServerName(final Address address, final long startcode) {
// Use HostAndPort to host port and hostname. Does validation and can do ipv6
this.address = address;
this.startcode = startcode;
this.servername = getServerName(this.address.getHostname(),
this.address.getPort(), startcode);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
/**
* @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());
}
代码示例来源:origin: org.apache.hbase/hbase-common
/**
* @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());
}
内容来源于网络,如有侵权,请联系作者删除!