Bug 745811 (EDG-86) - EDG: Anomalies in use of ServiceBindingManager
Summary: EDG: Anomalies in use of ServiceBindingManager
Keywords:
Status: CLOSED NEXTRELEASE
Alias: EDG-86
Product: JBoss Data Grid 5
Classification: JBoss
Component: Infinispan
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: EAP 5.1.0 EDG TP
Assignee: Default User
QA Contact:
URL: http://jira.jboss.org/jira/browse/EDG-86
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-19 16:35 UTC by Richard Achmatowicz
Modified: 2011-10-11 17:06 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-10-27 13:51:58 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker EDG-86 0 None None None Never

Description Richard Achmatowicz 2010-10-19 16:35:07 UTC
project_key: EDG

The file used to deploy the HotRod and MemCached server modules 

    $JBOSS_DIST/server/datagrid/deploy/datagrid.sar/META-INF/datagrid-jboss-beans.xml

permits configuration of the server modules by one of two means:
(i) by specifying a properties map defined inline
(ii) by specifying a file name of a properties file containing property key=value pairs

When properties are specified in-line, we may make use of the ServiceBindingManager to pick up values for the server module properties infinispan.server.host and infinispan.server.port.

At present, the properties file is used by default, and an example of the use of ServiceBindingManager in-line is commented out.

Some problems with this commented out version:
1. The service binding <value-factory> elements are incorrectly defined:

For example:
<value-factory bean="ServiceBindingManager" method="getStringBinding">
	<parameter>HotRodServer</parameter>
	<parameter><null /></parameter>
	<parameter><null/></parameter>
	<parameter>${jboss.bind.address}</parameter>
	<parameter>11311</parameter><
</value-factory>

should be:
<value-factory bean="ServiceBindingManager" method="getStringBinding">
	<parameter>Infinispan</parameter>
	<parameter>HotRodServer</parameter>
	<parameter><null/></parameter>
	<parameter>${jboss.bind.address}</parameter>
	<parameter>11311</parameter><
</value-factory>

and 
 <value-factory bean="ServiceBindingManager" method="getIntBinding">
	<parameter>HotRodServer</parameter>
	<parameter><null /></parameter>
	<parameter>${jboss.bind.address}</parameter>
	<parameter>11311</parameter>
</value-factory>

should be:

 <value-factory bean="ServiceBindingManager" method="getIntBinding">
        <parameter>Infinispan</parameter>
        <parameter>HotRodServer</parameter>
        <parameter>${jboss.bind.address}</parameter>
        <parameter>11311</parameter>
</value-factory>


2. The service and binding names in the ServiceBindingManager configuration file do not match up:

<bean class="org.jboss.services.binding.ServiceBindingMetadata">
    <property name="serviceName">Infinispan</property>
    <property name="bindingName">HotRodServer</property>
    <property name="hostName">${jboss.bind.address:127.0.0.1}</property>
    <property name="port">11216</property>
    <property name="description">Socket on which Infinispan's HotRod server listens</property>
</bean>

<bean class="org.jboss.services.binding.ServiceBindingMetadata">
    <property name="serviceName">Infinispan</property>
    <property name="bindingName">Memcached</property>
    <property name="hostName">${jboss.bind.address:127.0.0.1}</property>
    <property name="port">11211</property>
    <property name="description">Socket on which Infinispan's memcached server listens</property>
</bean>

Comment 1 Richard Achmatowicz 2010-10-19 16:59:05 UTC
Also, it is questionable whether using a properties file should be the default. 
Using the properties file prevents the use of SBM to configure hosts.





Comment 2 Galder Zamarreño 2010-10-26 13:58:44 UTC
Richard, not sure about the reason of using a properties file instead of embedding the properties in the -beans.xml file. Maybe to hide away internal XML details for anyone wanting to make changes to those variables?

I'll check with Manik, but I agree with you that it'd be better to have all properties within the -beans.xml file. If users want to change ports, they shouldn't have to deal with this file and instead use the port SBM. 

Comment 3 Galder Zamarreño 2010-10-26 17:44:14 UTC
Why is a getStringBinding and a getIntBinding property needed? You end up writing the same port twice, wondering how to avoid information duplication...

Any idea Richard?

Comment 4 Richard Achmatowicz 2010-10-26 18:09:36 UTC
Galder, i'm not sure I understand your question; as far as I understand it, the call to getStringBinding() returns the hostname for the given service/binding pair in SBM, and the call to getIntBinding() returns the port.


Comment 5 Galder Zamarreño 2010-10-26 18:12:56 UTC
Another q, why do you have to set bind address and port in each of the get binding calls?

Comment 6 Galder Zamarreño 2010-10-26 18:15:33 UTC
Right, so if getStringBinding() returns the host name, why put the port there as well? I mean, this should work, shouldnt it?

                     <value-factory bean="ServiceBindingManager" method="getStringBinding">
                       <parameter>Infinispan</parameter>
                       <parameter>HotRodServer</parameter>
                       <parameter>${jboss.bind.address:127.0.0.1}</parameter>
                     </value-factory>

                     <value-factory bean="ServiceBindingManager" method="getIntBinding">
                       <parameter>Infinispan</parameter>
                       <parameter>HotRodServer</parameter>
                       <parameter>11311</parameter>
                     </value-factory>

Or am I missing something?

Comment 7 Richard Achmatowicz 2010-10-26 18:32:33 UTC
Yes, you are :-)
It's a little complicated to explain. I'll work through the examples above:

<value-factory bean="ServiceBindingManager" method="getStringBinding">
<parameter>Infinispan</parameter>
<parameter>HotRodServer</parameter>
<parameter><null/></parameter>
<parameter>${jboss.bind.address}</parameter>
<parameter>11311</parameter><
</value-factory> 

(i) the first two parameters to getStringBinding, namely Infinispan/HotRodServer, serve to identify a ServiceBindingMetadata entry in the SBM configuration - that metadata entry may or may not be present
(ii) the third parameter defines an arbitrary input string, possibly containing embedded strings for ${host}, ${port} and ${hostforurl}. If an input string contains these, they will be substituted for the associated host, port or host (with surrounding square brackets for an IPv6 address - eg string = http://${hostforurl}:${port}/myContext. If the third parameter is null, the hostname is returned.
(iii) the fourth and fifth parameters are used only if the metadata entry does not exist in the SB<M configuration, and a ServiceBindingMetadata entry will be dynamically created using those host and port values.

Same situation for getIntBinding() only there is no input string paranmeter.



Comment 8 Richard Achmatowicz 2010-10-26 18:39:00 UTC
So, if you want to take the risk, you could leave off the fourth and fifth parameters of the getStringBinding() call, and the third and fourth patameters of the getIntBinding() and because we have entries in SBM for these service/binding pairs, everything should work OK. But if they are not found for some reason, the server modules may start up with incorrect host and port info.
 

Comment 9 Richard Achmatowicz 2010-10-26 18:46:32 UTC
By the way, your question  just caused me to solve a problem I had! This technique of using the third and fourth parameters in getStringBinding() can be used to make use of SBM in test case deployments (when there are no SBM entries for the test deployment in the official SBM configuration). This is something I needed for my fixing of AS 6 for IPv6. Great!

Comment 10 Galder Zamarreño 2010-10-27 10:32:12 UTC
Hmmm, I've tried what I said above but even if you use ports-01, Infinispan servers still listen in 11211 and 11311 respectively, which are the default ports.

Comment 11 Galder Zamarreño 2010-10-27 11:01:11 UTC
We have a problem here: The default ports for memcached and hot rod were defined as 11211 and 11311, so the offset is 100. Now, we'd want to carry on with same defaults, but if you're to switch to ports-01, you'd get 11311 and 11411 which might be risky, since the default hot rod port would now be the alternative memcached one.

Comment 12 Galder Zamarreño 2010-10-27 11:24:57 UTC
The other problem, why ports-01 is not picked is that even if AS passes the new port correctly, the Infinispan server ignores it due to a wrong equality comparison. This happens at least when properties are passed not via properties files.

I've also spotted that even with properties files, SBM might work fine, cos there's a little trick where the the SBM file takes the host/port and assigns it to an internal system property that the properties file seems to use. I do see an advantage of using properties file here cos you could provide more properties that the server might need such as max threads...etc in an easier away, as opposed to fiddling with the beans file. I'm double checking this as well.

Comment 13 Galder Zamarreño 2010-10-27 12:57:36 UTC
For the port thing, we're changing the default port in Infinispan Hot Rod as indicated in https://jira.jboss.org/browse/ISPN-739. 11222 will be the default port for Hot Rod in AS as well.

Now, the reason ports-01 is not being picked is cos when properties are passed via the beans file, the port value comes as an Integer. Now, since we expect Properties to be passed to use, if the value part that a getProperty() should return is anything but a String, null is returned. This is workable although I'm leaning towards properties files for the other properties we can define there, i.e. max threads...etc.

Comment 14 Galder Zamarreño 2010-10-27 13:09:51 UTC
For ports-01 to work fine, I need to implement ISPN-740 and it'll work as expected.

Comment 15 Galder Zamarreño 2010-10-27 13:25:24 UTC
Actually, ISPN-740 is not needed, different port setups work fine even with separate properties file. In fact, due to what I said in my previous comment, this is the only way in which it would work. I'm adding a comment to the properties file to highlight that it works fine with SBM and I'm also adding other properties with default values and information about them.


Note You need to log in before you can comment on or make changes to this bug.