use of org.jgroups.stack.AddressGenerator in project JGroups by belaban.
the class ProgrammaticUPerf method main.
public static void main(String[] args) throws Exception {
String name = null, bind_addr = null, mcast_addr = "232.4.5.6";
boolean run_event_loop = true;
AddressGenerator addr_generator = null;
int port = 7800, mcast_port = 45566;
boolean udp = true;
String initial_hosts = null;
for (int i = 0; i < args.length; i++) {
if ("-name".equals(args[i])) {
name = args[++i];
continue;
}
if ("-nohup".equals(args[i])) {
run_event_loop = false;
continue;
}
if ("-uuid".equals(args[i])) {
addr_generator = new OneTimeAddressGenerator(Long.parseLong(args[++i]));
continue;
}
if ("-port".equals(args[i])) {
port = Integer.parseInt(args[++i]);
continue;
}
if ("-bind_addr".equals(args[i])) {
bind_addr = args[++i];
continue;
}
if ("-tcp".equals(args[i])) {
udp = false;
continue;
}
if ("-mcast_addr".equals(args[i])) {
mcast_addr = args[++i];
continue;
}
if ("-mcast_port".equals(args[i])) {
mcast_port = Integer.parseInt(args[++i]);
continue;
}
if ("-initial_hosts".equals(args[i])) {
initial_hosts = args[++i];
continue;
}
help();
return;
}
ProgrammaticUPerf test = null;
try {
test = new ProgrammaticUPerf();
test.init(name, addr_generator, bind_addr, port, udp, mcast_addr, mcast_port, initial_hosts);
if (run_event_loop)
test.startEventThread();
} catch (Throwable ex) {
ex.printStackTrace();
if (test != null)
test.stop();
}
}
use of org.jgroups.stack.AddressGenerator in project JGroups by belaban.
the class Draw method main.
public static void main(String[] args) {
Draw draw = null;
String props = null;
boolean no_channel = false;
boolean jmx = true;
boolean use_state = false;
String group_name = null;
long state_timeout = 5000;
boolean use_unicasts = false;
String name = null;
boolean send_own_state_on_merge = true;
AddressGenerator generator = null;
for (int i = 0; i < args.length; i++) {
if ("-help".equals(args[i])) {
help();
return;
}
if ("-props".equals(args[i])) {
props = args[++i];
continue;
}
if ("-no_channel".equals(args[i])) {
no_channel = true;
continue;
}
if ("-jmx".equals(args[i])) {
jmx = Boolean.parseBoolean(args[++i]);
continue;
}
if ("-clustername".equals(args[i])) {
group_name = args[++i];
continue;
}
if ("-state".equals(args[i])) {
use_state = true;
continue;
}
if ("-timeout".equals(args[i])) {
state_timeout = Long.parseLong(args[++i]);
continue;
}
if ("-use_unicasts".equals(args[i])) {
use_unicasts = true;
continue;
}
if ("-name".equals(args[i])) {
name = args[++i];
continue;
}
if ("-send_own_state_on_merge".equals(args[i])) {
send_own_state_on_merge = Boolean.getBoolean(args[++i]);
continue;
}
if ("-uuid".equals(args[i])) {
generator = new OneTimeAddressGenerator(Long.parseLong(args[++i]));
continue;
}
help();
return;
}
try {
draw = new Draw(props, no_channel, jmx, use_state, state_timeout, use_unicasts, name, send_own_state_on_merge, generator);
if (group_name != null)
draw.setClusterName(group_name);
draw.go();
} catch (Throwable e) {
e.printStackTrace(System.err);
System.exit(0);
}
}
use of org.jgroups.stack.AddressGenerator in project JGroups by belaban.
the class UPerf method init.
public void init(String props, String name, AddressGenerator generator, int bind_port, boolean use_fibers) throws Throwable {
thread_factory = new DefaultThreadFactory("invoker", false, true).useFibers(use_fibers);
if (use_fibers && Util.fibersAvailable())
System.out.println("-- using fibers instead of threads");
channel = new JChannel(props).addAddressGenerator(generator).setName(name);
if (bind_port > 0) {
TP transport = channel.getProtocolStack().getTransport();
transport.setBindPort(bind_port);
}
disp = new RpcDispatcher(channel, this).setReceiver(this).setMethodLookup(id -> METHODS[id]);
channel.connect(groupname);
local_addr = channel.getAddress();
try {
MBeanServer server = Util.getMBeanServer();
JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName(), true);
} catch (Throwable ex) {
System.err.println("registering the channel in JMX failed: " + ex);
}
if (members.size() < 2)
return;
Address coord = members.get(0);
Config config = disp.callRemoteMethod(coord, new MethodCall(GET_CONFIG), new RequestOptions(ResponseMode.GET_ALL, 5000));
if (config != null) {
applyConfig(config);
System.out.println("Fetched config from " + coord + ": " + config + "\n");
} else
System.err.println("failed to fetch config from " + coord);
}
use of org.jgroups.stack.AddressGenerator in project JGroups by belaban.
the class UPerf method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
String props = null, name = null;
boolean run_event_loop = true, use_fibers = true;
AddressGenerator addr_generator = null;
int port = 0;
for (int i = 0; i < args.length; i++) {
if ("-props".equals(args[i])) {
props = args[++i];
continue;
}
if ("-name".equals(args[i])) {
name = args[++i];
continue;
}
if ("-nohup".equals(args[i])) {
run_event_loop = false;
continue;
}
if ("-uuid".equals(args[i])) {
addr_generator = new OneTimeAddressGenerator(Long.parseLong(args[++i]));
continue;
}
if ("-port".equals(args[i])) {
port = Integer.parseInt(args[++i]);
continue;
}
if ("-use_fibers".equals(args[i])) {
use_fibers = Boolean.parseBoolean(args[++i]);
continue;
}
help();
return;
}
UPerf test = null;
try {
test = new UPerf();
test.init(props, name, addr_generator, port, use_fibers);
if (run_event_loop)
test.eventLoop();
else {
for (; ; ) Util.sleep(60000);
}
} catch (Throwable ex) {
ex.printStackTrace();
if (test != null)
test.stop();
}
}
Aggregations