question: 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 ; }
target:  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'