Java 类org.apache.catalina.tribes.group.GroupChannel 实例源码

项目:tomcat7    文件:SimpleTcpCluster.java   
/**
 * Start Cluster and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {

    if (log.isInfoEnabled()) log.info("Cluster is about to start");

    try {
        checkDefaults();
        registerClusterValve();
        channel.addMembershipListener(this);
        channel.addChannelListener(this);
        if (channel instanceof GroupChannel)
            ((GroupChannel)channel).setName(getClusterName() + "-Channel");
        channel.start(channelStartOptions);
        if (clusterDeployer != null) clusterDeployer.start();
        registerMember(channel.getLocalMember(false));
    } catch (Exception x) {
        log.error("Unable to start cluster.", x);
        throw new LifecycleException(x);
    }

    setState(LifecycleState.STARTING);
}
项目:tomcat7    文件:TcpPingInterceptor.java   
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if ( thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel)getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel)getChannel()).getName() + "]";
        }
        thread.setName("TcpPingInterceptor.PingThread" + channelName +"-"+cnt.addAndGet(1));
        thread.start();
    }

    //acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while ( next != null ) {
        if ( next instanceof TcpFailureDetector ) 
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector)next);
        if ( next instanceof StaticMembershipInterceptor ) 
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor)next);
        next = next.getNext();
    }

}
项目:tomcat7    文件:McastServiceImpl.java   
public static synchronized void recover(McastServiceImpl parent) {
    if (running) return;
    if (!parent.isRecoveryEnabled())
        return;

    running = true;

    Thread t = new RecoveryThread(parent);
    String channelName = "";
    if (parent.channel instanceof GroupChannel
            && ((GroupChannel)parent.channel).getName() != null) {
        channelName = "[" + ((GroupChannel)parent.channel).getName() + "]";
    }
    t.setName("Tribes-MembershipRecovery" + channelName);
    t.setDaemon(true);
    t.start();
}
项目:tomcat7    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:tomcat7    文件:TestTcpFailureDetector.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
}
项目:tomcat7    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:tomcat7    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.73-with-comment    文件:SimpleTcpCluster.java   
/**
 * Start Cluster and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {

    if (log.isInfoEnabled()) log.info("Cluster is about to start");

    try {
        checkDefaults();
        registerClusterValve();
        channel.addMembershipListener(this);
        channel.addChannelListener(this);
        if (channel instanceof GroupChannel)
            ((GroupChannel)channel).setName(getClusterName() + "-Channel");
        channel.start(channelStartOptions);
        if (clusterDeployer != null) clusterDeployer.start();
        registerMember(channel.getLocalMember(false));
    } catch (Exception x) {
        log.error("Unable to start cluster.", x);
        throw new LifecycleException(x);
    }

    setState(LifecycleState.STARTING);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TcpPingInterceptor.java   
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if ( thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel)getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel)getChannel()).getName() + "]";
        }
        thread.setName("TcpPingInterceptor.PingThread" + channelName +"-"+cnt.addAndGet(1));
        thread.start();
    }

    //acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while ( next != null ) {
        if ( next instanceof TcpFailureDetector ) 
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector)next);
        if ( next instanceof StaticMembershipInterceptor ) 
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor)next);
        next = next.getNext();
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:McastServiceImpl.java   
public static synchronized void recover(McastServiceImpl parent) {
    if (running) return;
    if (!parent.isRecoveryEnabled())
        return;

    running = true;

    Thread t = new RecoveryThread(parent);
    String channelName = "";
    if (parent.channel instanceof GroupChannel
            && ((GroupChannel)parent.channel).getName() != null) {
        channelName = "[" + ((GroupChannel)parent.channel).getName() + "]";
    }
    t.setName("Tribes-MembershipRecovery" + channelName);
    t.setDaemon(true);
    t.start();
}
项目:apache-tomcat-7.0.73-with-comment    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestTcpFailureDetector.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:lazycat    文件:SimpleTcpCluster.java   
/**
 * Start Cluster and implement the requirements of
 * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException
 *                if this component detects a fatal error that prevents this
 *                component from being used
 */
@Override
protected void startInternal() throws LifecycleException {

    if (log.isInfoEnabled())
        log.info("Cluster is about to start");

    try {
        checkDefaults();
        registerClusterValve();
        channel.addMembershipListener(this);
        channel.addChannelListener(this);
        if (channel instanceof GroupChannel)
            ((GroupChannel) channel).setName(getClusterName() + "-Channel");
        channel.start(channelStartOptions);
        if (clusterDeployer != null)
            clusterDeployer.start();
        registerMember(channel.getLocalMember(false));
    } catch (Exception x) {
        log.error("Unable to start cluster.", x);
        throw new LifecycleException(x);
    }

    setState(LifecycleState.STARTING);
}
项目:lazycat    文件:TcpPingInterceptor.java   
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if (thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel) getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel) getChannel()).getName() + "]";
        }
        thread.setName("TcpPingInterceptor.PingThread" + channelName + "-" + cnt.addAndGet(1));
        thread.start();
    }

    // acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while (next != null) {
        if (next instanceof TcpFailureDetector)
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector) next);
        if (next instanceof StaticMembershipInterceptor)
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor) next);
        next = next.getNext();
    }

}
项目:lazycat    文件:McastServiceImpl.java   
public static synchronized void recover(McastServiceImpl parent) {
    if (running)
        return;
    if (!parent.isRecoveryEnabled())
        return;

    running = true;

    Thread t = new RecoveryThread(parent);
    String channelName = "";
    if (parent.channel instanceof GroupChannel && ((GroupChannel) parent.channel).getName() != null) {
        channelName = "[" + ((GroupChannel) parent.channel).getName() + "]";
    }
    t.setName("Tribes-MembershipRecovery" + channelName);
    t.setDaemon(true);
    t.start();
}
项目:class-guard    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:class-guard    文件:TestTcpFailureDetector.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
}
项目:class-guard    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:class-guard    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.57    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:apache-tomcat-7.0.57    文件:TestTcpFailureDetector.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
}
项目:apache-tomcat-7.0.57    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.57    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.57    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:apache-tomcat-7.0.57    文件:TestTcpFailureDetector.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
}
项目:apache-tomcat-7.0.57    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:apache-tomcat-7.0.57    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:WBSAirback    文件:CoordinationDemo.java   
public GroupChannel createChannel() {
    channel = new GroupChannel();
    ((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
    interceptor = new NonBlockingCoordinator() {
        @Override
        public void fireInterceptorEvent(InterceptorEvent event) {
            status = event.getEventTypeDesc();
            int type = event.getEventType();
            boolean display = VIEW_EVENTS[type];
            if ( display ) parent.printScreen();
            try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
                // Ignore
            }
        }
    };
    channel.addInterceptor(interceptor);
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatch15Interceptor());
    return channel;
}
项目:WBSAirback    文件:TestMulticastPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:WBSAirback    文件:TestUdpPackages.java   
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    ThroughputInterceptor tint = new ThroughputInterceptor();
    tint.setInterval(500);
    ThroughputInterceptor tint2 = new ThroughputInterceptor();
    tint2.setInterval(500);
    //channel1.addInterceptor(tint);
    channel2.addInterceptor(tint2);
    listener1 = new Listener();
    ReceiverBase rb1 = (ReceiverBase)channel1.getChannelReceiver();
    ReceiverBase rb2 = (ReceiverBase)channel2.getChannelReceiver();
    rb1.setUdpPort(50000);
    rb2.setUdpPort(50000);
    channel2.addChannelListener(listener1);
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
项目:tomcat7    文件:MessageDispatchInterceptor.java   
public void startQueue() {
    msgDispatchThread = new Thread(this);
    String channelName = "";
    if (getChannel() instanceof GroupChannel
            && ((GroupChannel)getChannel()).getName() != null) {
        channelName = "[" + ((GroupChannel)getChannel()).getName() + "]";
    }
    msgDispatchThread.setName("MessageDispatchInterceptor.MessageDispatchThread" + channelName);
    msgDispatchThread.setDaemon(true);
    msgDispatchThread.setPriority(Thread.MAX_PRIORITY);
    queue.setEnabled(true);
    run = true;
    msgDispatchThread.start();
}
项目:tomcat7    文件:MessageDispatch15Interceptor.java   
@Override
public void startQueue() {
    if ( run ) return;
    String channelName = "";
    if (getChannel() instanceof GroupChannel
            && ((GroupChannel)getChannel()).getName() != null) {
        channelName = "[" + ((GroupChannel)getChannel()).getName() + "]";
    }
    executor = ExecutorFactory.newThreadPool(maxSpareThreads, maxThreads,
            keepAliveTime, TimeUnit.MILLISECONDS,
            new TcclThreadFactory("MessageDispatch15Interceptor.MessageDispatchThread" + channelName));
    run = true;
}
项目:tomcat7    文件:ReceiverBase.java   
@Override
public void start() throws IOException {
    if ( executor == null ) {
        //executor = new ThreadPoolExecutor(minThreads,maxThreads,60,TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
        String channelName = "";
        if (channel instanceof GroupChannel && ((GroupChannel)channel).getName() != null) {
            channelName = "[" + ((GroupChannel)channel).getName() + "]";
        }
        TaskThreadFactory tf = new TaskThreadFactory("Tribes-Task-Receiver" + channelName + "-");
        executor = ExecutorFactory.newThreadPool(minThreads, maxThreads, maxIdleTime, TimeUnit.MILLISECONDS, tf);
    }
}
项目:tomcat7    文件:McastServiceImpl.java   
public ReceiverThread() {
    super();
    String channelName = "";
    if (channel instanceof GroupChannel && ((GroupChannel)channel).getName() != null) {
        channelName = "[" + ((GroupChannel)channel).getName() + "]";
    }
    setName("Tribes-MembershipReceiver" + channelName);
}
项目:tomcat7    文件:McastServiceImpl.java   
public SenderThread(long time) {
    this.time = time;
    String channelName = "";
    if (channel instanceof GroupChannel && ((GroupChannel)channel).getName() != null) {
        channelName = "[" + ((GroupChannel)channel).getName() + "]";
    }
    setName("Tribes-MembershipSender" + channelName);

}
项目:tomcat7    文件:TestOrderInterceptor.java   
@Before
public void setUp() throws Exception {
    System.out.println("Setup");
    channels = new GroupChannel[channelCount];
    orderitcs = new OrderInterceptor[channelCount];
    mangleitcs = new MangleOrderInterceptor[channelCount];
    test = new TestListener[channelCount];
    threads = new Thread[channelCount];
    for ( int i=0; i<channelCount; i++ ) {
        channels[i] = new GroupChannel();

        orderitcs[i] = new OrderInterceptor();
        mangleitcs[i] = new MangleOrderInterceptor();
        orderitcs[i].setExpire(Long.MAX_VALUE);
        channels[i].addInterceptor(orderitcs[i]);
        channels[i].addInterceptor(mangleitcs[i]);
        test[i] = new TestListener(i);
        channels[i].addChannelListener(test[i]);
        final int j = i;
        threads[i] = new Thread() {
            @Override
            public void run() {
                try {
                    channels[j].start(Channel.DEFAULT);
                    Thread.sleep(50);
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };
    }
    TesterUtil.addRandomDomain(channels);
    for ( int i=0; i<channelCount; i++ ) threads[i].start();
    for ( int i=0; i<channelCount; i++ ) threads[i].join();
    Thread.sleep(1000);
}
项目:tomcat7    文件:TestNonBlockingCoordinator.java   
@Before
public void setUp() throws Exception {
    System.out.println("Setup");
    channels = new GroupChannel[CHANNEL_COUNT];
    coordinators = new NonBlockingCoordinator[CHANNEL_COUNT];
    Thread[] threads = new Thread[CHANNEL_COUNT];
    for ( int i=0; i<CHANNEL_COUNT; i++ ) {
        channels[i] = new GroupChannel();
        coordinators[i] = new NonBlockingCoordinator();
        channels[i].addInterceptor(coordinators[i]);
        channels[i].addInterceptor(new TcpFailureDetector());
        final int j = i;
        threads[i] = new Thread() {
            @Override
            public void run() {
                try {
                    channels[j].start(Channel.DEFAULT);
                    Thread.sleep(50);
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };
    }
    TesterUtil.addRandomDomain(channels);
    for (int i = 0; i < CHANNEL_COUNT; i++) {
        threads[i].start();
    }
    for (int i = 0; i < CHANNEL_COUNT; i++) {
        threads[i].join();
    }
    Thread.sleep(1000);
}
项目:tomcat7    文件:TestDomainFilterInterceptor.java   
@Before
public void setUp() throws Exception {
    for (int i = 0; i < channels.length; i++) {
        channels[i] = new GroupChannel();
        channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
        listeners[i] = new TestMbrListener( ("Listener-" + (i + 1)));
        channels[i].addMembershipListener(listeners[i]);
        DomainFilterInterceptor filter = new DomainFilterInterceptor();
        filter.setDomain(UUIDGenerator.randomUUID(false));
        channels[i].addInterceptor(filter);
    }
}