当前位置: 首页>>代码示例>>Java>>正文


Java McastService类代码示例

本文整理汇总了Java中org.apache.catalina.tribes.membership.McastService的典型用法代码示例。如果您正苦于以下问题:Java McastService类的具体用法?Java McastService怎么用?Java McastService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


McastService类属于org.apache.catalina.tribes.membership包,在下文中一共展示了McastService类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalStart

import org.apache.catalina.tribes.membership.McastService; //导入依赖的package包/类
/**
 * Starts up the channel. This can be called multiple times for individual services to start
 * The svc parameter can be the logical or value of any constants
 * @param svc int value of <BR>
 * DEFAULT - will start all services <BR>
 * MBR_RX_SEQ - starts the membership receiver <BR>
 * MBR_TX_SEQ - starts the membership broadcaster <BR>
 * SND_TX_SEQ - starts the replication transmitter<BR>
 * SND_RX_SEQ - starts the replication receiver<BR>
 * @throws ChannelException if a startup error occurs or the service is already started.
 */
protected synchronized void internalStart(int svc) throws ChannelException {
    try {
        boolean valid = false;
        //make sure we don't pass down any flags that are unrelated to the bottom layer
        svc = svc & Channel.DEFAULT;

        if (startLevel == Channel.DEFAULT) return; //we have already started up all components
        if (svc == 0 ) return;//nothing to start
        
        if (svc == (svc & startLevel)) throw new ChannelException("Channel already started for level:"+svc);

        //must start the receiver first so that we can coordinate the port it
        //listens to with the local membership settings
        if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) {
            clusterReceiver.setMessageListener(this);
            clusterReceiver.start();
            //synchronize, big time FIXME
            membershipService.setLocalMemberProperties(getClusterReceiver().getHost(), 
                                                       getClusterReceiver().getPort(),
                                                       getClusterReceiver().getSecurePort(),
                                                       getClusterReceiver().getUdpPort());
            valid = true;
        }
        if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) {
            clusterSender.start();
            valid = true;
        }
        
        if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) {
            membershipService.setMembershipListener(this);
            if (membershipService instanceof McastService) {
                ((McastService)membershipService).setMessageListener(this);
            }
            membershipService.start(MembershipService.MBR_RX);
            valid = true;
        }
        if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) {
            membershipService.start(MembershipService.MBR_TX);
            valid = true;
        }
        
        if ( !valid) {
            throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ");
        }
        startLevel = (startLevel | svc);
    }catch ( ChannelException cx ) {
        throw cx;
    }catch ( Exception x ) {
        throw new ChannelException(x);
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:63,代码来源:ChannelCoordinator.java


注:本文中的org.apache.catalina.tribes.membership.McastService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。