Hi,
We are using 5.5.27 and using tribes, however instead of tomcat
initializing and starting tribes we are doing it ourselves. Below is my
code. I was just wondering if you see anything wrong with what I'm
doing.
public synchronized void startup()
{
if(_tribesChannel == null)
{ // nothing to do if already running
try
{
_tribesChannel = new GroupChannel();
// must be done before start:
MembershipService mService =
_tribesChannel.getMembershipService();
McastService mCastService = (McastService)mService;
mCastService.setPort(_mainPort);
mCastService.setAddress(_multicastIPAddr);
mCastService.setRecoveryCounter(10);
// 10 Seconds instead of 3 seconds?
mCastService.setDropTime(10*1000);
ChannelReceiver receiver =
_tribesChannel.getChannelReceiver();
// _desiredLocalIPAddr may be set to select one nic in multihome
environments
if(_desiredLocalIPAddr != null &&
_desiredLocalIPAddr.length() > 0)
{
// Question: Set both of these, to have heartbeat and messages sent on
same nic?
mCastService.setBind(_desiredLocalIPAddr);
if(receiver instanceof ReceiverBase)
{
((ReceiverBase)receiver).setAddress(_desiredLocalIPAddr);
}
}
// Set if we want a different port than what tomcat uses as default
"4000"
if(_ancillaryPort > 0)
{
if(receiver.getPort() != _ancillaryPort)
{
if(receiver instanceof ReceiverBase)
{
((ReceiverBase)receiver).setPort(_ancillaryPort);
}
}
}
_tribesChannel.addInterceptor(new
TcpFailureDetector());
_tribesChannel.addMembershipListener(_tribesMembershipListener);
_tribesChannel.addChannelListener(_tribesChannelListener);
_tribesChannel.start(CHANNEL_COMPONENTS);
// This just adds this machine to our internal cluster topology list
addToTopology();
}
catch(ChannelException ex)
{
try { _tribesChannel.stop(CHANNEL_COMPONENTS); }
catch(Throwable t) { /*gulp*/}
_tribesChannel = null;
throw new RuntimeException(ex); // todo, exception
handling?
}
}
}
public void shutdown()
{
super.shutdown();
if(_tribesChannel != null)
{
try
{
synchronized(_tribesChannel)
{
_tribesChannel.removeMembershipListener(_tribesMembershipListener);
_tribesChannel.removeChannelListener(_tribesChannelListener);
_tribesChannel.stop(CHANNEL_COMPONENTS);
}
}
catch(ChannelException ex)
{
throw new RuntimeException(ex); // todo, exception
handling?
}
finally
{
_tribesChannel = null;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]