I've got JBAS-5161 ready to be committed. There's a small change though that I
wanted to pass through the forum before committing it:
Instead of parsing host:port manually by searching for colon and then calling substring, I
thought it'll be easier and less cumbersome to parse it via an URI. To do this, I
create a new URI from "cluster://" + preferredMaster, i.e.
/**
| * Create a URI instance from the given preferred master.
| *
| * @param str contains the String format of the preferred master.
| * @return an instance of URI, or null if the str cannot be parsed.
| */
| protected URI createUri(String str)
| {
| try
| {
| return new URI("cluster://" + preferredMaster);
| }
| catch (URISyntaxException use)
| {
| log.debug("Cannot extract URI from " + preferredMaster, use);
| }
|
| return null;
| }
and then call getHost() and getPort() on the URI instance to get the host/ip and port
values.
Even though a new URI is inmutable, I haven't cached it cos preferred master can be
changed at runtime. URI is just an identifier in comparison to URL, so I don't expect
creation of URI instances to be costly.
To make sure I didn't introduce any bugs with this, I've also created
PreferredMasterElectionPolicyUnitTestCase that contains several standalone tests that
probe different inputs for preferred master.
Brian, I'll send you a patch before committing in case you wanna have a look to it.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128202#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...