use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.
the class TestNonBlockingCoordinator method setUp.
@Before
public void setUp() throws Exception {
LogManager.getLogManager().getLogger("org.apache.catalina.tribes.group.interceptors.TestNonBlockingCoordinator").setLevel(Level.ALL);
try {
log.info("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();
((ReceiverBase) channels[i].getChannelReceiver()).setHost("localhost");
coordinators[i] = new NonBlockingCoordinator();
channels[i].addInterceptor(coordinators[i]);
TcpFailureDetector tcpFailureDetector = new TcpFailureDetector();
// Double default timeout - mainly for loaded CI systems
tcpFailureDetector.setReadTestTimeout(tcpFailureDetector.getReadTestTimeout() * 2);
channels[i].addInterceptor(tcpFailureDetector);
final int j = i;
threads[i] = new Thread() {
@Override
public void run() {
try {
channels[j].start(Channel.DEFAULT);
} 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();
}
// Allow up to 30s for cluster to form once all the nodes have been
// started
int count = 0;
Member member = null;
boolean electionComplete = false;
while (!electionComplete && count < 300) {
electionComplete = true;
member = coordinators[0].getCoordinator();
if (member == null) {
electionComplete = false;
} else {
for (int i = 0; i < CHANNEL_COUNT; i++) {
electionComplete = electionComplete && (member.equals(coordinators[i].getCoordinator()));
}
}
Thread.sleep(100);
count++;
}
} finally {
LogManager.getLogManager().getLogger("org.apache.catalina.tribes.group.interceptors.TestNonBlockingCoordinator").setLevel(Level.INFO);
}
}
use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.
the class TestMulticastPackages method setUp.
@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);
}
use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.
the class TestUdpPackages method setUp.
@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);
}
use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.
the class TestOrderInterceptor method setUp.
@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();
((ReceiverBase) channels[i].getChannelReceiver()).setHost("localhost");
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();
}
int totalSleep = 0;
for (int i = 0; i < channelCount; i++) {
Member[] m = channels[i].getMembers();
while (m == null || m.length < channelCount - 1) {
totalSleep += 50;
if (totalSleep > 60000) {
Assert.fail("Cluster took more than 60s to start");
}
Thread.sleep(50);
m = channels[i].getMembers();
}
}
}
use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.
the class SimpleTcpCluster method checkDefaults.
protected void checkDefaults() {
if (clusterListeners.size() == 0 && managerTemplate instanceof DeltaManager) {
addClusterListener(new ClusterSessionListener());
}
if (valves.size() == 0) {
addValve(new JvmRouteBinderValve());
addValve(new ReplicationValve());
}
if (clusterDeployer != null) {
clusterDeployer.setCluster(this);
}
if (channel == null) {
channel = new GroupChannel();
}
if (channel instanceof GroupChannel && !((GroupChannel) channel).getInterceptors().hasNext()) {
channel.addInterceptor(new MessageDispatchInterceptor());
channel.addInterceptor(new TcpFailureDetector());
}
if (heartbeatBackgroundEnabled) {
channel.setHeartbeat(false);
}
}
Aggregations