You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2017/06/09 17:42:11 UTC

[Bug 61171] New: Add port offset attribute (portOffset?) to Server configuration in server.xml

https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

            Bug ID: 61171
           Summary: Add port offset attribute (portOffset?) to Server
                    configuration in server.xml
           Product: Tomcat 9
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: csutherl@redhat.com
  Target Milestone: -----

An option that would allow users to set a port offset in the configuration (or
with a system property) would be great for creating new instances on the same
machine. Such an option would prevent the need for manually updating the
connectors, etc in the server.xml for each new installation on the same host.
With this option in place, users could simply unzip multiple installs and then
start each with a different offset out of the box rather than updating multiple
places in the server.xml.

As an example of the implementation, setting the option to 100 would
add 100 to all port bindings on the server (e.g. with a vanilla
install it would cause tomcat to run on 8105, 8180, and 8109 rather than 8005,
8180, and 8009). It should also be noted that this same offset should apply to
ALL port bindings and references, include the redirectPort.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #2 from Igal Sapir <de...@21solutions.net> ---
Comments from Mark Thomas on Github
(https://github.com/apache/tomcat/pull/63#issuecomment-307556995):

I think more discussion is required on how to approach this. Specifically, when
should the offset be applied? What is the impact on getters and setters? For
example connector.setPort (getPort ()) should be a NO-OP. What is reported via
JMX? There are all sorts of side effects that need to be thought through here
else we'll end up creating some very non-intuative behaviour.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #4 from Igal Sapir <de...@21solutions.net> ---
Can we discuss the guidelines/specification for this feature?  Anyone wants to 
contribute their thoughts?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
My suggestion is as follows:

Add a new getter for every getPort() or equivalent named getPortWithOffset()
and use it in place of getPort() whenever code needs to get the actual port
number to open. That would ensure that getPort()/setPort() (and
getOffset()/setOffset() ) remain symmetrical so they continue to work with
features like configuration saving.

portWithOffset should be exposed as a read-only JMX attribute everywhere port
is exposed.

It does mean users using an offset will need to look at a different attribute
to find the port they are actually using. That might confuse some tools but on
balance I think this is lower risk than getPort()/setPort() not being
symmetrical.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #7 from Mark Thomas <ma...@apache.org> ---
See https://github.com/apache/tomcat/pull/125

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #1 from Igal Sapir <de...@21solutions.net> ---
Please see https://github.com/apache/tomcat/pull/63

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #5 from Pradip Bhattacharya <pr...@gmail.com> ---
port offset is a good thing to have, can help a lot in having multiple
installations/resolving port conflicts.

I have tried to implement it by adding portOffset attribute in Server element.

Below is the change in server.xml, portOffset as the new attribute:

<Server port="8005" shutdown="SHUTDOWN" portOffset="1000">
...
</Server>

Added getter/setter method portOffset in org.apache.catalina.Server interface.
So StandardServer now has a member variable portOffset, and its respective
getter/setter functions.

Now in order to update all the port/redirectPort numbers mentioned in the
server.xml, I have created a Rule, i.e. AddPortOffsetRule, which is applied
after values of all the attributes have been set in the target(current) object.

For example, in Catalina::createStartDigester function,
after digester.addSetProperties("Server"); is called,
a new is being invoked by adding the below line
digester.addRule("Server", new AddPortOffsetRule("port"));

Similarly for Connector, below 2 rules are added to update port numbers:
digester.addRule("Server/Service/Connector",new AddPortOffsetRule("port"));
digester.addRule("Server/Service/Connector",new
AddPortOffsetRule("redirectPort"));

This way the port related member variables are again updated using the port
offset.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Mark Thomas <ma...@apache.org> ---
Provide patch applied (with a few changes) to 9.0.x for 9.0.13 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61171] Add port offset attribute (portOffset?) to Server configuration in server.xml

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61171

--- Comment #3 from Igal Sapir <de...@21solutions.net> ---
(moving discussion from Github to the ticket):

>I think more discussion is required on how to approach this. Specifically, when should the offset be applied?

I agree, and I was trying to find different options for this in order to
initiate a discussion, but the way that Tomcat reads the config files and
initializes objects via introspection really limits us here unless there is a
major overhaul.

Server has the value for portOffset, so a reference to it is required in order
to calculate (port + portOffset)

The process is somewhat like this:

Connectors are initialized (no reference to Service or Server)
Service is linked to the Connectors (still no reference to Server)
Server is added to Service
Point (3) is point where I took the portOffset from Server and applied it to
the Connectors.

>What is the impact on getters and setters? For example connector.setPort (getPort ()) should be a NO-OP.

At point (1) above the Connector's setPort() is called by the
IntrospectionUtils with the values from server.xml. That can not be a NO-OP at
that point as that would practically disable the Connector, but we can check if
Service and Server are null or not (which they are at initialization) and
perhaps do something different accordingly?

Is it even possible/allowed to change the port after initialization?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org