JDK-8239831 : Add jhsdb option to specify debug server RMI connector port
  • Type: CSR
  • Component: hotspot
  • Sub-Component: svc-agent
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 15
  • Submitted: 2020-02-24
  • Updated: 2021-04-06
  • Resolved: 2020-03-23
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Add new jhsdb tool options for the debugd mode to specify a RMI connector port, RMI connector host name, and RMI registry port .

Problem
-------

When running a debug server on a remote host behind a firewall or inside a container it should be possible to specify what exact ports need to be used and what host name is returned in the remote stub object. Currently system property "sun.jvm.hotspot.rmi.port" can be used to specify the RMI registry port and system property "java.rmi.server.hostname" could be be used to specify the host name, but remote objects still communicate over random ports. An option to specify RMI connector port needs to be added. Also 2 more options to specify the RMI registry port and the host name needs to be added to the tool to simplify the command line that needs to be used to launch the tool in these cases and list these additional settings in the tool's help.

Solution
--------

Introduce 3 new options to jhsdb command for the debugd mode:
  `--rmiport` to specify RMI connector port number,
  `--registryport` to specify RMI registry port number,
  `--hostname` to specify RMI connector host name.



Specification
-------------
jhsdb tool in the debugd mode can accept `--rmiport` option to specify RMI connector port, `--registryport` option to specify RMI registry port number, and `--hostname` option to specify RMI connector host name.  The value of `--hostname` option could be a hostname or an IPv4/IPv6 address.

```    
$ jhsdb debugd  --help

  --serverid <id>   A unique identifier for this debug server.
  --rmiport <port> Sets the port number to which the RMI connector is
                   bound. If not specified a random available port is used.
  --registryport <port> Sets the RMI registry port.
                        This option overrides the system property
                        'sun.jvm.hotspot.rmi.port'.
                        If not specified, the system property is used.
                        If the system property is not set, the default port 1099 is used.
  --hostname <hostname> Sets the host name the RMI connector
                        is bound. The value could be a hostname or an 
                        IPv4/IPv6 address. This option overrides the system
                        property 'java.rmi.server.hostname'.
                        If not specified, the system property is used.
                        If the system property is not set, a system host name is used. 
  --pid <pid>       To attach to and operate on the given live process.
  --core <corefile> To operate on the given core file.
  --exe <executable for corefile>

  The --core and --exe options must be set together to give the core
  file, and associated executable, to operate on. They can use
  absolute or relative paths.
  The --pid option can be set to operate on a live process.
  --core and --pid are mutually exclusive.

  Examples: jhsdb debugd --pid 1234
        or  jhsdb debugd --core ./core.1234 --exe ./myexe
    
```
Comments
Moving to Approved.
23-03-2020

The information about hostname requirement was added to the specification. The help message for `--hostname` options was updated to add "The value could be a hostname or an IPv4/IPv6 address."
22-03-2020

Moving to Provisional, *not* Approved. What constraints are on the hostname? Must it be a name or is an IP address sufficient? If an IP address, IPV4 or IPV6? Please including more information on the hostname requirements before the request is finalized.
17-03-2020

Corrected the help message: "system property" -> "the system property"
16-03-2020

I don't think it is required. It would just make the option name more cumbersome. All options are described in the tool's help so one could easy understand what it is about.
09-03-2020

should --registryport and --hostname be --rmiregistryport and --rmihostname ?
09-03-2020

Thank you, Serguei. The changes look OK to me.
09-03-2020

[~dtitov] I've updated the CSR description a little bit and added myself as a reviewer. Please, let me know if it works for you. Also, I think, the compatibility risk description has to be added before finalizing it.
07-03-2020

I agree with disadvantages of system properties you listed. As we discussed offline, it'd be nice to add all options that we need at the same time, if possible. This way we could simplify the transition cost. If you find any problems to do it this way then we can try to break this task into steps.
26-02-2020

I believe that the system properties have the following disadvantages comparing to the command line options: - It’s hard to know about them: they are not listed in tool’s help. - They have long names that hard to remember It is easy to mistype them - in the command line and you will not get any warning about it. Having this said, I don’t think that configuring the tool through the system properties especially when we are talking about such important parameters as the ports is a right approach. The presence of “**sun.jvm.hotspot.rmi.port**" system property seems to me a shortcut that was made a long time ago. And I don’t see any benefits in introducing in addition to the command line option a new system property. Just opposite, I believe that “**sun.jvm.hotspot.rmi.port**” as well as another property “**java.rmi.server.hostname**” should become a command line options and be deprecated in the future. However, this exceeds the scope of this CSR that is aimed to the sole task : to make it possible to configure a RMI connector port.
25-02-2020

Just an observation that the jstatd has different style of options. A question is if we want them to be designed similarly.
24-02-2020

> Currently system property "sun.jvm.hotspot.rmi.port" can be used to specify the RMI registry port but remote objects still communicate over random ports. An option to specify RMI connector port needs to be added. I'm confused a little bit here. A system property is used to set the RMI registry port but you suggest to introduce an option to specify RMI connector port. Would it better to use the same mechanism for both? Does it make sense to ad an option for the RMI registry port as well. Would it be right to introduce a system property "sun.jvm.hotspot.rmi.connection-port" (right property name can be selected later) as well?
24-02-2020