private static String extractClientName(String clientId,String host){
  String hostExcludedId="";
  if ((isIPv6(host) || isIPv4(host)) && clientId.startsWith(host)) {
    hostExcludedId=clientId.substring(host.length());
  }
 else {
    int firstDotIndex=host.indexOf(".");
    if (firstDotIndex != -1) {
      String hostShortName=host.substring(0,firstDotIndex);
      hostExcludedId=clientId.substring(hostShortName.length());
    }
  }
  String vmPIDAndKindRegex="\\(\\w+:\\w+\\)";
  String regex="(\\<ec\\>)?:[0-9]+(:\\w+){2}+";
  String name=NOT_AVAILABLE;
  String temp=hostExcludedId;
  int openIndex=temp.indexOf("(");
  if (openIndex != -1) {
    regex=vmPIDAndKindRegex + regex;
  }
  if (temp.matches(regex)) {
    String[] splitted=temp.split(":");
    name=splitted[splitted.length - 1];
  }
  return name;
}

private static String extractClientName ( String clientId , String host ) { String hostExcludedId = "" ; if ( ( isIPv6 ( host ) || isIPv4 ( host ) ) && clientId . startsWith ( host ) ) { hostExcludedId = clientId . substring ( host . length ( ) ) ; } else { int firstDotIndex = host . indexOf ( "." ) ; if ( firstDotIndex != - 1 ) { String hostShortName = host . substring ( 0 , firstDotIndex ) ; hostExcludedId = clientId . substring ( hostShortName . length ( ) ) ; } } String vmPIDAndKindRegex = "\\(\\w+:\\w+\\)" ; String regex = "(\\<ec\\>)?:[0-9]+(:\\w+){2}+" ; String name = NOT_AVAILABLE ; String temp = hostExcludedId ; int openIndex = temp . indexOf ( "(" ) ; if ( openIndex != - 1 ) { regex = vmPIDAndKindRegex + regex ; } if ( temp . matches ( regex ) ) { String [ ] splitted = temp . split ( ":" ) ; name = splitted [ splitted . length - 1 ] ; } return name ; }
excludes the host name from the client id and returns the string . if the host name can not be detected , returns an empty string . typically , the client id looks like : host ( vm_pid : vm_kind ) : port : random_string : client_name extracts the client name from the client id . if the client id is not in the expected format , returns ' n / a '
