org.apache.catalina.tribes.group.GroupChannel Java Examples

The following examples show how to use org.apache.catalina.tribes.group.GroupChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUdpPackages.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: TestUdpPackages.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: TestMulticastPackages.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: TestTcpFailureDetector.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@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});
}
 
Example #5
Source File: CoordinationDemo.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: McastServiceImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #7
Source File: TcpPingInterceptor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@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();
    }
    
}
 
Example #8
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: CoordinationDemo.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
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 MessageDispatchInterceptor());
    return channel;
}
 
Example #10
Source File: TestMulticastPackages.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: TestTcpFailureDetector.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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});
}
 
Example #12
Source File: CoordinationDemo.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #13
Source File: TestUdpPackages.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatchInterceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatchInterceptor());
    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);
}
 
Example #14
Source File: TestTcpFailureDetector.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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});
}
 
Example #15
Source File: TestMulticastPackages.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatchInterceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatchInterceptor());
    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);
}
 
Example #16
Source File: McastServiceImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public ReceiverThread() {
    super();
    String channelName = "";
    if (channel instanceof GroupChannel && ((GroupChannel)channel).getName() != null) {
        channelName = "[" + ((GroupChannel)channel).getName() + "]";
    }
    setName("Tribes-MembershipReceiver" + channelName);
}
 
Example #17
Source File: TestOrderInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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(1500);
}
 
Example #18
Source File: TestRemoteProcessException.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    listener1 = new Listener();
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
 
Example #19
Source File: TestDataIntegrity.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatch15Interceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatch15Interceptor());
    listener1 = new Listener();
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
 
Example #20
Source File: TestNonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
}
 
Example #21
Source File: TestDomainFilterInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
    }
}
 
Example #22
Source File: TestDomainFilterInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #23
Source File: TestNonBlockingCoordinator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #24
Source File: TestOrderInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: McastServiceImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
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);

}
 
Example #26
Source File: TestNonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #27
Source File: ReceiverBase.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #28
Source File: MessageDispatch15Interceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #29
Source File: TestDataIntegrity.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel1.addInterceptor(new MessageDispatchInterceptor());
    channel2 = new GroupChannel();
    channel2.addInterceptor(new MessageDispatchInterceptor());
    listener1 = new Listener();
    channel2.addChannelListener(listener1);
    TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
    channel1.start(Channel.DEFAULT);
    channel2.start(Channel.DEFAULT);
}
 
Example #30
Source File: MessageDispatchInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
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();
}