Search in sources :

Example 1 with ConnectionEndpointConverter

use of org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter in project geode by apache.

the class StartJConsoleCommand method getJmxServiceUrlAsString.

protected String getJmxServiceUrlAsString(final String member) {
    if (StringUtils.isNotBlank(member)) {
        ConnectionEndpointConverter converter = new ConnectionEndpointConverter();
        try {
            ConnectionEndpoint connectionEndpoint = converter.convertFromText(member, ConnectionEndpoint.class, null);
            String hostAndPort = connectionEndpoint.getHost() + ":" + connectionEndpoint.getPort();
            return String.format("service:jmx:rmi://%s/jndi/rmi://%s/jmxrmi", hostAndPort, hostAndPort);
        } catch (Exception e) {
            throw new IllegalArgumentException(CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE);
        }
    } else {
        if (isConnectedAndReady() && (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) {
            JmxOperationInvoker jmxOperationInvoker = (JmxOperationInvoker) getGfsh().getOperationInvoker();
            return ObjectUtils.toString(jmxOperationInvoker.getJmxServiceUrl());
        }
    }
    return null;
}
Also used : ConnectionEndpointConverter(org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter) ConnectionEndpoint(org.apache.geode.management.internal.cli.util.ConnectionEndpoint) JmxOperationInvoker(org.apache.geode.management.internal.cli.shell.JmxOperationInvoker) IOException(java.io.IOException) GemFireException(org.apache.geode.GemFireException)

Aggregations

IOException (java.io.IOException)1 GemFireException (org.apache.geode.GemFireException)1 ConnectionEndpointConverter (org.apache.geode.management.internal.cli.converters.ConnectionEndpointConverter)1 JmxOperationInvoker (org.apache.geode.management.internal.cli.shell.JmxOperationInvoker)1 ConnectionEndpoint (org.apache.geode.management.internal.cli.util.ConnectionEndpoint)1