private static InetAddress findLocalAddressListeningOnPort(String pHost, int pPort) throws UnknownHostException, SocketException { InetAddress address = InetAddress.getByName(pHost); if (address.isLoopbackAddress()) { // First check local address InetAddress localAddress = getLocalAddress(); if (!localAddress.isLoopbackAddress() && isPortOpen(localAddress, pPort)) { return localAddress; } // Then try all addresses attache to all interfaces localAddress = getLocalAddressFromNetworkInterfacesListeningOnPort(pPort); if (localAddress != null) { return localAddress; } } return address; }
public static String getAgentId(int objectId, String type) { String address; try { address = getLocalAddress().getHostAddress(); } catch (IOException exp) { address = "local"; } return address + "-" + getProcessId() + "-" + Integer.toHexString(objectId) + "-" + type; }
/** * Description including agent URL * * @return agent url */ @Override public String getDescription() { String hostDescr = host; try { if (hostDescr == null) { hostDescr = NetworkUtil.getLocalAddress().getHostName(); } } catch (IOException e) { hostDescr = "localhost"; } return "Jolokia Agent: http://" + hostDescr + ":" + getPort() + "/jolokia"; }
private static InetAddress findLocalAddressListeningOnPort(String pHost, int pPort) throws UnknownHostException, SocketException { InetAddress address = InetAddress.getByName(pHost); if (address.isLoopbackAddress()) { // First check local address InetAddress localAddress = getLocalAddress(); if (!localAddress.isLoopbackAddress() && isPortOpen(localAddress, pPort)) { return localAddress; } // Then try all addresses attache to all interfaces localAddress = getLocalAddressFromNetworkInterfacesListeningOnPort(pPort); if (localAddress != null) { return localAddress; } } return address; }
String value; if (var.equalsIgnoreCase("host")) { value = getLocalAddress().getHostName(); } else if (var.equalsIgnoreCase("ip")) { value = getLocalAddress().getHostAddress(); } else { String key = extractKey(var,"env");
private static InetAddress findLocalAddressListeningOnPort(String pHost, int pPort) throws UnknownHostException, SocketException { InetAddress address = InetAddress.getByName(pHost); if (address.isLoopbackAddress()) { // First check local address InetAddress localAddress = getLocalAddress(); if (!localAddress.isLoopbackAddress() && isPortOpen(localAddress, pPort)) { return localAddress; } // Then try all addresses attache to all interfaces localAddress = getLocalAddressFromNetworkInterfacesListeningOnPort(pPort); if (localAddress != null) { return localAddress; } } return address; }
private String detectAgentUrl(HttpServer pServer, JolokiaServerConfig pConfig, String pContextPath) { serverAddress= pServer.getAddress(); InetAddress realAddress; int port; if (serverAddress != null) { realAddress = serverAddress.getAddress(); if (realAddress.isAnyLocalAddress()) { try { realAddress = NetworkUtil.getLocalAddress(); } catch (IOException e) { try { realAddress = InetAddress.getLocalHost(); } catch (UnknownHostException e1) { // Ok, ok. We take the original one realAddress = serverAddress.getAddress(); } } } port = serverAddress.getPort(); } else { realAddress = pConfig.getAddress(); port = pConfig.getPort(); } return String.format("%s://%s:%d%s", pConfig.getProtocol(),realAddress.getHostAddress(),port, pContextPath); }
public static String getAgentId(int objectId, String type) { String address; try { address = getLocalAddress().getHostAddress(); } catch (IOException exp) { address = "local"; } return address + "-" + getProcessId() + "-" + Integer.toHexString(objectId) + "-" + type; }
public static String getAgentId(int objectId, String type) { String address; try { address = getLocalAddress().getHostAddress(); } catch (IOException exp) { address = "local"; } return address + "-" + getProcessId() + "-" + Integer.toHexString(objectId) + "-" + type; }
/** * Description including agent URL * * @return agent url */ @Override public String getDescription() { String hostDescr = host; try { if (hostDescr == null) { hostDescr = NetworkUtil.getLocalAddress().getHostName(); } } catch (IOException e) { hostDescr = "localhost"; } return "Jolokia Agent: http://" + hostDescr + ":" + getPort() + "/jolokia"; }
String value; if (var.equalsIgnoreCase("host")) { value = getLocalAddress().getHostName(); } else if (var.equalsIgnoreCase("ip")) { value = getLocalAddress().getHostAddress(); } else { String key = extractKey(var,"env");
String value; if (var.equalsIgnoreCase("host")) { value = getLocalAddress().getHostName(); } else if (var.equalsIgnoreCase("ip")) { value = getLocalAddress().getHostAddress(); } else { String key = extractKey(var,"env");