tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Wannamaker" <mwann...@opentext.com>
Subject Tribes Startup Help
Date Wed, 07 Jan 2009 22:16:20 GMT
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message