HA-JNDI

  Status: implemented,  2006-06-30 09:54:29
  • Created: 2006-06-26 10:14:18+0200
  • Categories: remote
  • Author: friebe

Scope of Change

The ability to pass a list of servers to the Remote API will be added.


Rationale

Load balancing and failover.

Functionality



Current

The suggested functionality can be implemented currently as follows:

  $remotespecs= array('xp://jboss01.example.com/', 'xp://jboss02.example.com/');
shuffle
($remotespecs);
foreach ($remotespecs as $remotespec) {
try(); {
$remote= &Remote::forName($remotespec);
} if (catch('RemoteException', $e)) {
continue;
}

$e= NULL;
break;
}

if ($e) {
$e->printStackTrace();
exit
(1);
}

$home= &$remote->lookup('xp/demo/IteratorDemo');



Proposed

The new functionality would make this transparent, so one would not have to differ whether there are one or many remoting servers:

  try(); {
$remote= &Remote::forName('xp://jboss01.example.com/,xp://jboss02.example.com/');
} if (catch('RemoteException', $e)) {
$e->printStackTrace();
exit
(1);
}

$home= &$remote->lookup('xp/demo/IteratorDemo');



Notes

  • Initially, a random value is used to determine which one of the given servers the connection should be made to. This is not real load- balancing!
  • If connecting to jboss01 fails, jboss02 will be used (the other way around respectively).


Security considerations

n/a

Speed impact

- Minimalistic for round-robbing load balancing

Dependencies

n/a

Related documents

- http://unittests.xp-framework.net/?net.xp_framework.unittest.remote.RemoteTest Unittest verifying new functionality

Comments

- friebe, Mon Jun 26 10:33:49 CEST 2006 More ideas using Remote::forName():

  Remote::forName(array('xp://jboss01.example.com/', 'xp://jboss02.example.com/'));
Remote::forName
('xp://jboss01.example.com/', 'xp://jboss02.example.com/');
Remote::forName
('xp+ha://jboss01.example.com,jboss02.example.com');
Remote::forName
('xp://[jboss01.example.com,jboss02.example.com]');

- friebe, Mon Jun 26 11:19:24 CEST 2006 Maybe an extra flag could be added as follows:

  Remote::forName('xp://jboss01.example.com/?master', 'xp://jboss02.example.com/?failover');

In this case, no random value would be used - rather, the connection would always go to jboss01, and only if that fails, jboss02 would be used.

- friebe, Fri Jun 30 09:48:25 2006 Initial implementation comitted, needs further testing but should be available soon.

<EOF>


Table of contents