本文整理汇总了Java中java.net.InetSocketAddress.toString方法的典型用法代码示例。如果您正苦于以下问题:Java InetSocketAddress.toString方法的具体用法?Java InetSocketAddress.toString怎么用?Java InetSocketAddress.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.InetSocketAddress
的用法示例。
在下文中一共展示了InetSocketAddress.toString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProxy
import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override
public synchronized ProxyInfo<T> getProxy() {
// Create a non-ha proxy if not already created.
if (nnProxyInfo == null) {
try {
// Create a proxy that is not wrapped in RetryProxy
InetSocketAddress nnAddr = NameNode.getAddress(nameNodeUri);
nnProxyInfo = new ProxyInfo<T>(NameNodeProxies.createNonHAProxy(
conf, nnAddr, xface, UserGroupInformation.getCurrentUser(),
false).getProxy(), nnAddr.toString());
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
return nnProxyInfo;
}
示例2: AsyncRpcChannel
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* Constructor for netty RPC channel
*
* @param bootstrap to construct channel on
* @param client to connect with
* @param ticket of user which uses connection
* @param serviceName name of service to connect to
* @param address to connect to
*/
public AsyncRpcChannel(Bootstrap bootstrap, final AsyncRpcClient client, User ticket, String
serviceName, InetSocketAddress address) {
this.client = client;
this.ticket = ticket;
this.serviceName = serviceName;
this.address = address;
this.channel = connect(bootstrap).channel();
name = ("IPC Client (" + channel.hashCode() + ") to " +
address.toString() +
((ticket == null) ?
" from unknown user" :
(" from " + ticket.getName())));
}
示例3: isFailedServer
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* Check if the server should be considered as bad. Clean the old entries of the list.
*
* @return true if the server is in the failed servers list
*/
public synchronized boolean isFailedServer(final InetSocketAddress address) {
if (failedServers.isEmpty()) {
return false;
}
final String lookup = address.toString();
final long now = EnvironmentEdgeManager.currentTime();
// iterate, looking for the search entry and cleaning expired entries
Iterator<Pair<Long, String>> it = failedServers.iterator();
while (it.hasNext()) {
Pair<Long, String> cur = it.next();
if (cur.getFirst() < now) {
it.remove();
} else {
if (lookup.equals(cur.getSecond())) {
return true;
}
}
}
return false;
}
示例4: handleConnectionException
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* @param retries current retried times.
* @param maxAttmpts max attempts
* @param protocol protocol interface
* @param addr address of remote service
* @param ce ConnectException
* @throws RetriesExhaustedException
*/
private static void handleConnectionException(int retries, int maxAttmpts, Class<?> protocol,
InetSocketAddress addr, ConnectException ce) throws RetriesExhaustedException {
if (maxAttmpts >= 0 && retries >= maxAttmpts) {
LOG.info("Server at " + addr + " could not be reached after " + maxAttmpts
+ " tries, giving up.");
throw new RetriesExhaustedException("Failed setting up proxy " + protocol + " to "
+ addr.toString() + " after attempts=" + maxAttmpts, ce);
}
}
示例5: create
import java.net.InetSocketAddress; //导入方法依赖的package包/类
static <T extends HttpServer> T create(HttpProtocolType protocol)
throws IOException {
final int max = addresses.size() + MAX;
final List<HttpServer> toClose = new ArrayList<>();
try {
for (int i = 1; i <= max; i++) {
HttpServer server = newHttpServer(protocol);
server.bind(new InetSocketAddress("127.0.0.1", 0), 0);
InetSocketAddress address = server.getAddress();
String key = address.toString();
if (addresses.addIfAbsent(key)) {
System.out.println("Server bound to: " + key
+ " after " + i + " attempt(s)");
return (T) server;
}
System.out.println("warning: address " + key
+ " already used. Retrying bind.");
// keep the port bound until we get a port that we haven't
// used already
toClose.add(server);
}
} finally {
// if we had to retry, then close the servers we're not
// going to use.
for (HttpServer s : toClose) {
try { s.stop(1); } catch (Exception x) { /* ignore */ }
}
}
throw new IOException("Couldn't bind servers after " + max + " attempts: "
+ "addresses used before: " + addresses);
}
示例6: getDescription
import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override
public String
getDescription()
{
InetSocketAddress address = getAddress();
if ( address == null ){
return( "not connected" );
}else{
return( address.toString());
}
}
示例7: serialize
import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override
public String serialize(InetSocketAddress data)
{
String str = data.toString();
int indexOf = str.indexOf('/');
if (indexOf >= 0)
{
return str.substring(str.indexOf('/') + 1);
}
return str;
}
示例8: ServerOfflineException
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* Constructs a <code>ServerOfflineException</code> with the specified
* <code>RakNetClient</code> and address.
*
* @param client the <code>RakNetClient</code> that threw the exception.
* @param address the address of the offline server.
*/
public ServerOfflineException(RakNetClient client, InetSocketAddress address) {
super(client, "Server at address " + address.toString() + " is offline");
this.address = address;
}
示例9: getFileName
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* File name to print when accessing a block directly (from servlets)
* @param s Address of the block location
* @param poolId Block pool ID of the block
* @param blockId Block ID of the block
* @return string that has a file name for debug purposes
*/
public static String getFileName(final InetSocketAddress s,
final String poolId, final long blockId) {
return s.toString() + ":" + poolId + ":" + blockId;
}