org.jgroups.util.Util.shortName()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(167)

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

Util.shortName介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static String generateLocalName() {
  String retval=null;
  try {
    retval=shortName(InetAddress.getLocalHost().getHostName());
  }
  catch(Throwable ignored) {
  }
  if(retval == null) {
    try {
      retval=shortName(InetAddress.getByName(null).getHostName());
    }
    catch(Throwable e) {
      retval="localhost";
    }
  }
  long counter=Util.random((long)Short.MAX_VALUE * 2);
  return retval + "-" + counter;
}

代码示例来源:origin: wildfly/wildfly

public String toString() {
  Socket tmp_sock=sock;
  if(tmp_sock == null)
    return "<null socket>";
  InetAddress local=tmp_sock.getLocalAddress(), remote=tmp_sock.getInetAddress();
  String local_str=local != null? Util.shortName(local) : "<null>";
  String remote_str=remote != null? Util.shortName(remote) : "<null>";
  return String.format("%s:%s --> %s:%s (%d secs old) [%s] [recv_buf=%d]",
             local_str, tmp_sock.getLocalPort(), remote_str, tmp_sock.getPort(),
             TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS),
             status(), receiver != null? receiver.bufferSize() : 0);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static String generateLocalName() {
  String retval=null;
  try {
    retval=shortName(InetAddress.getLocalHost().getHostName());
  }
  catch(Throwable e) {
  }
  if(retval == null) {
    try {
      retval=shortName(InetAddress.getByName(null).getHostName());
    }
    catch(Throwable e) {
      retval="localhost";
    }
  }
  long counter=Util.random((long)Short.MAX_VALUE * 2);
  return retval + "-" + counter;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public String toString() {
  Socket tmp_sock=sock;
  if(tmp_sock == null)
    return "<null socket>";
  InetAddress local=tmp_sock.getLocalAddress(), remote=tmp_sock.getInetAddress();
  String local_str=local != null? Util.shortName(local) : "<null>";
  String remote_str=remote != null? Util.shortName(remote) : "<null>";
  return String.format("%s:%s --> %s:%s (%d secs old) [%s] [recv_buf=%d]",
             local_str, tmp_sock.getLocalPort(), remote_str, tmp_sock.getPort(),
             TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS),
             status(), receiver != null? receiver.bufferSize() : 0);
}

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

public String toString() {
  StringBuilder ret=new StringBuilder();
  InetAddress local=null, remote=null;
  String local_str, remote_str;
  if(sock == null)
    ret.append("<null socket>");
  else {
    //since the sock variable gets set to null we want to make
    //make sure we make it through here without a nullpointer exception
    Socket tmp_sock=sock;
    local=tmp_sock.getLocalAddress();
    remote=tmp_sock.getInetAddress();
    local_str=local != null ? Util.shortName(local) : "<null>";
    remote_str=remote != null ? Util.shortName(remote) : "<null>";
    ret.append('<' + local_str + ':' + tmp_sock.getLocalPort() +
         " --> " + remote_str + ':' + tmp_sock.getPort() + "> (" +
         ((System.currentTimeMillis() - last_access) / 1000) + " secs old)");
    tmp_sock=null;
  }
  return ret.toString();
}

相关文章

Util类方法