I raised the same concern in dev@ "Can't start BAM 2.0.2 server and a MB
2.0.1 server in a single machine (with different port offsets)" :-)

Great, if you guys could fix.


On Tue, Apr 2, 2013 at 3:42 PM, Sinthuja Ragendran <[email protected]>wrote:

> Thanks for detailed explanation. I'll update all BAM related components
> (data-bridge, cassandra) to use the above CarbonUtil method to get the port
> offset.
>
> Thanks,
> Sinthuja.
>
>
> On Tue, Apr 2, 2013 at 3:38 PM, Afkham Azeez <[email protected]> wrote:
>
>> When defining any ports in Carbon, there is a recommended way of doing
>> it. Some time back, we decided that it should be possible for a user to
>> change all relevant ports from a single location. That is why we have the
>> Ports section in the carbon.xml file. Once you define a new port, it should
>> be overridable from the carbon.xml.
>>
>> Here is the ports section
>>
>> <Ports>
>> 106
>> 107         <!-- Ports offset. This entry will set the value of the ports
>> defined below to
>> 108          the define value + Offset.
>> 109          e.g. Offset=2 and HTTPS port=9443 will set the effective
>> HTTPS port to 9445
>> 110          -->
>> 111         <Offset>0</Offset>
>> 112
>> 113         <!-- The JMX Ports -->
>> 114         <JMX>
>> 115             <!--The port RMI registry is exposed-->
>> 116             <RMIRegistryPort>9999</RMIRegistryPort>
>> 117             <!--The port RMI server should be exposed-->
>> 118             <RMIServerPort>11111</RMIServerPort>
>> 119         </JMX>
>> 120
>> 121         <!-- Embedded LDAP server specific ports -->
>> 122         <EmbeddedLDAP>
>> 123             <!-- Port which embedded LDAP server runs -->
>> 124             <LDAPServerPort>10389</LDAPServerPort>
>> 125             <!-- Port which KDC (Kerberos Key Distribution Center)
>> server runs -->
>> 126             <KDCServerPort>8000</KDCServerPort>
>> 127         </EmbeddedLDAP>
>> 128
>> 129             <!-- Embedded Qpid broker ports -->
>> 130         <EmbeddedQpid>
>> 131             <!-- Broker TCP Port -->
>> 132             <BrokerPort>5672</BrokerPort>
>> 133             <!-- SSL Port -->
>> 134             <BrokerSSLPort>8672</BrokerSSLPort>
>> 135         </EmbeddedQpid>
>> 136
>> 137         <!--
>> 138              Override datasources JNDIproviderPort defined in bps.xml
>> and datasources.properties files
>> 139         -->
>> 140         <!--<JNDIProviderPort>2199</JNDIProviderPort>-->
>> 141         <!--Override receive port of thrift based entitlement
>> service.-->
>> 142
>> <ThriftEntitlementReceivePort>10500</ThriftEntitlementReceivePort>
>> 143
>> 144     </Ports>
>>
>>
>> So, when these ports are defined in the relevant file, you are supposed
>> to use the keys, e.g. JMX.RMIRegistryPort is defined in the jmx.xml file,
>> instead of a hard coded port. Now you have to use the below CarbonUtil
>> method to get the proper port along with the portOffset.
>>
>> Here is the relevant method in CarbonUtils.
>>
>> /**
>>      * This is to read the port values defined in other config files, which 
>> are overridden
>>      * from those in carbon.xml.
>>      * @param property
>>      * @return
>>      */
>>     public static int getPortFromServerConfig(String property) {
>>         String port;
>>         int portNumber = -1;
>>         int indexOfStartingChars = -1;
>>         int indexOfClosingBrace;
>>
>>         ServerConfiguration serverConfiguration = 
>> ServerConfiguration.getInstance();
>>         // The following condition deals with ports specified to be read 
>> from carbon.xml.
>>         // Ports are specified as templates: eg 
>> ${Ports.EmbeddedLDAP.LDAPServerPort},
>>         if (indexOfStartingChars < property.indexOf("${") &&
>>             (indexOfStartingChars = property.indexOf("${")) != -1 &&
>>             (indexOfClosingBrace = property.indexOf('}')) != -1) { // Is 
>> this template used?
>>
>>             String portTemplate = property.substring(indexOfStartingChars + 
>> 2,
>>                                                      indexOfClosingBrace);
>>
>>             port = serverConfiguration.getFirstProperty(portTemplate);
>>
>>             if (port != null) {
>>                 portNumber = Integer.parseInt(port);
>>             }
>>
>>         }
>>         String portOffset = System.getProperty("portOffset",
>>                                                
>> serverConfiguration.getFirstProperty("Ports.Offset"));
>>         //setting up port offset properties as system global property which 
>> allows this
>>         //to available at the other context as required (fix 2011-11-30)
>>         System.setProperty("portOffset", portOffset);
>>         return portOffset == null? portNumber : portNumber + 
>> Integer.parseInt(portOffset);
>>     }
>>
>>
>>
>>
>> On Tue, Apr 2, 2013 at 3:31 PM, Afkham Azeez <[email protected]> wrote:
>>
>>> Port offset has to be obtained from the CarbonUtil class. There is a
>>> method there. If you use that standard method, it will always give the
>>> correct portOffset. This is what the well-behaved components have used.
>>>
>>> Azeez
>>>
>>>
>>> On Tue, Apr 2, 2013 at 3:28 PM, Sinthuja Ragendran <[email protected]>wrote:
>>>
>>>> I tested the BAM 2.2.0 with -DportOffset and seems like only http and
>>>> https ports are getting changed when starting with -DportOffset and thrift
>>>> port, cassandra port, etc is not getting changed.
>>>>
>>>> After further digging into the code,  I see we are getting the port
>>>> offset from ServerConfigurationService which is set as OSGI service and
>>>> that is not returning the correct offset value. Is there anything wrong
>>>> here?
>>>>
>>>> Thanks,
>>>> Sinthuja.
>>>>
>>>>
>>>> On Tue, Apr 2, 2013 at 2:47 PM, Afkham Azeez <[email protected]> wrote:
>>>>
>>>>> $subject
>>>>>
>>>>> Looks like we are forced to edit the carbon.xml file and set the
>>>>> offset. Is this crrect? If so why has this platform best practice not been
>>>>> followed?
>>>>>
>>>>> --
>>>>> *Afkham Azeez*
>>>>> Director of Architecture; WSO2, Inc.; http://wso2.com
>>>>> Member; Apache Software Foundation; http://www.apache.org/
>>>>> * <http://www.apache.org/>**
>>>>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919
>>>>> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
>>>>> twitter: 
>>>>> **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>>>>> *
>>>>> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
>>>>> *
>>>>> *
>>>>> *Lean . Enterprise . Middleware*
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Sinthuja Rajendran*
>>>> Software Engineer <http://wso2.com/>
>>>> WSO2, Inc.:http://wso2.com
>>>>
>>>> Blog: http://sinthu-rajan.blogspot.com/
>>>> Mobile: +94774273955
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> *Afkham Azeez*
>>> Director of Architecture; WSO2, Inc.; http://wso2.com
>>> Member; Apache Software Foundation; http://www.apache.org/
>>> * <http://www.apache.org/>**
>>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919
>>> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
>>> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>>> *
>>> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
>>> *
>>> *
>>> *Lean . Enterprise . Middleware*
>>>
>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>**
>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919
>> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
>> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>> *
>> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
>> *
>> *
>> *Lean . Enterprise . Middleware*
>>
>
>
>
> --
> *Sinthuja Rajendran*
> Software Engineer <http://wso2.com/>
> WSO2, Inc.:http://wso2.com
>
> Blog: http://sinthu-rajan.blogspot.com/
> Mobile: +94774273955
>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

Thanks & regards,
Nirmal

Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/

<http://nirmalfdo.blogspot.com/>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to