You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by David Blevins <da...@visi.com> on 2010/01/27 14:16:14 UTC
ConnectionStrategies: Random and RoundRobin
Just added two new connection strategies for the clustering/failover
logic.
RoundRobin: As the name implies each request just goes to the next
server in the list. It does this on every request as sort of a cheap
load balancer.
Random: Similar to the above but it picks a server randomly from the
available servers, excluding the previously invoked server if
possible. So you should hit a new server, but not necessarily rolling
down the list in order.
I'd like to create some way to configure this for an individual app
(or even an individual bean). Thinking maybe some annotation and
openejb-jar.xml meta data that we can swizzle all the way to the
client code.
Thoughts?
-David
Re: ConnectionStrategies: Random and RoundRobin
Posted by David Blevins <da...@visi.com>.
On Feb 4, 2010, at 8:32 AM, David Blevins wrote:
>
> On Jan 27, 2010, at 2:16 PM, David Blevins wrote:
>
>> I'd like to create some way to configure this for an individual app (or even an individual bean). Thinking maybe some annotation and openejb-jar.xml meta data that we can swizzle all the way to the client code.
>
> Have some code for this in. Will document this a bit better, but the basic premise is that you can now attach properties to an ejb and those starting with "openejb.client." will be carried as far as the remote client. The connection strategy selection code has now been improved to check the bean's properties for an "openejb.client.connection.strategy" property, the value of which should indicate a strategy registered with the ConnectionManager, such as "sticky", "roundrobin", or "random". It is also possible to add new strategies in a client and configure beans to use those strategies.
>
> https://issues.apache.org/jira/browse/OPENEJB-1232
Added another tweak to this set of functionality. Basically gives the ability for the client to "stuff" the failover urls in the InitialContext properties rather than (or in addition to) having them discovered by the server.
So clients can do this:
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", "failover:sticky:ejbd://agwdt:9999,ejbd://127.0.0.1:4201");
Context context = new InitialContext(props);
The "sticky:" part is optional. If specified, it should be any of the ConnectionStrategy implementations we have installed (sticky, round-robin, random).
The "ejbd://agwdt:9999,ejbd://127.0.0.1:4201" part is just the critical part and is just a comma separated list of URIs to try when attempting to connect. The URIs are the same as you would use normally. Under the covers we just attempt to find a ConnectionFactory for each URI and ask it for a connection and keep trying (as per the ConnectionStrategy) till we find one that works.
https://issues.apache.org/jira/browse/OPENEJB-1281
-David
Re: ConnectionStrategies: Random and RoundRobin
Posted by David Blevins <da...@visi.com>.
On Jan 27, 2010, at 2:16 PM, David Blevins wrote:
> I'd like to create some way to configure this for an individual app
> (or even an individual bean). Thinking maybe some annotation and
> openejb-jar.xml meta data that we can swizzle all the way to the
> client code.
Have some code for this in. Will document this a bit better, but the
basic premise is that you can now attach properties to an ejb and
those starting with "openejb.client." will be carried as far as the
remote client. The connection strategy selection code has now been
improved to check the bean's properties for an
"openejb.client.connection.strategy" property, the value of which
should indicate a strategy registered with the ConnectionManager, such
as "sticky", "roundrobin", or "random". It is also possible to add
new strategies in a client and configure beans to use those strategies.
https://issues.apache.org/jira/browse/OPENEJB-1232
-David