org.jgroups.tests.TestToaOrder Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
package org.jgroups.tests;
import org.jgroups.*;
import org.jgroups.AnycastAddress;
import org.jgroups.util.Util;
import javax.management.*;
import java.io.*;
import java.lang.management.ManagementFactory;
import java.util.*;
/**
* Runs the Total Order Anycast protocol and saves the messages delivered
*
* Note: this is used for debugging
* Note2: this needs to be clean :)
*
* @author Pedro Ruivo
* @since 3.1
*/
public class TestToaOrder {
private static final String PROPS = "toa.xml";
private static final String CLUSTER = "test-toa-cluster";
private static final String OUTPUT_FILE_SUFFIX = "-messages.txt";
private static final String JMX_DOMAIN = "org.jgroups";
private JChannel jChannel;
private MyReceiver receiver;
private int numberOfNodes;
private int numberOfMessages;
private final List members = new LinkedList<>();
private long start;
private long stop;
private long sentBytes = 0;
private long sentMessages = 0;
private String config;
public static void main(String[] args) throws InterruptedException {
System.out.println("==============");
System.out.println("Test TOA Order");
System.out.println("==============");
ArgumentsParser argumentsParser = new ArgumentsParser(args);
if (argumentsParser.isHelp()) {
helpAndExit();
} else if(argumentsParser.isTestOrder()) {
/*String[] paths = argumentsParser.getFilesPath();
int numberOfFiles = paths.length;
ProcessFile[] threads = new ProcessFile[numberOfFiles];
for (int i = 0; i < threads.length; ++i) {
threads[i] = new ProcessFile(paths[i]);
threads[i].start();
}
Map allMessages = new HashMap();
for (ProcessFile processFile : threads) {
processFile.join();
for (MessageInfo messageInfo : processFile.list) {
String message = messageInfo.message;
if (!allMessages.containsKey(message)) {
allMessages.put(message, messageInfo);
} else {
allMessages.get(message).join(messageInfo);
}
}
}
for (MessageInfo messageInfo : allMessages.values()) {
messageInfo.check();
}
System.out.println("============= FINISHED =============");
System.exit(0);*/
}
TestToaOrder test = new TestToaOrder(
argumentsParser.getNumberOfNodes(),
argumentsParser.getNumberOfMessages(),
argumentsParser.getConfig());
try {
test.startTest();
} catch (Exception e) {
System.err.println("Error while executing the test: " + e.getMessage());
e.printStackTrace();
System.exit(1);
} finally {
test.closeJChannel();
System.out.println("============= FINISHED =============");
}
System.exit(0);
}
private static void helpAndExit() {
System.out.println("usage: " + TestToaOrder.class.getCanonicalName() + "
© 2015 - 2025 Weber Informatics LLC | Privacy Policy