Search in sources :

Example 1 with AddressGenerator

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();
    }
}
Also used : AddressGenerator(org.jgroups.stack.AddressGenerator)

Example 2 with AddressGenerator

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);
    }
}
Also used : OneTimeAddressGenerator(org.jgroups.util.OneTimeAddressGenerator) OneTimeAddressGenerator(org.jgroups.util.OneTimeAddressGenerator) AddressGenerator(org.jgroups.stack.AddressGenerator)

Example 3 with AddressGenerator

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);
}
Also used : Property(org.jgroups.annotations.Property) Config(org.jgroups.tests.perf.PerfUtil.Config) LongAdder(java.util.concurrent.atomic.LongAdder) java.util(java.util) ResponseMode(org.jgroups.blocks.ResponseMode) RpcDispatcher(org.jgroups.blocks.RpcDispatcher) AddressGenerator(org.jgroups.stack.AddressGenerator) IOException(java.io.IOException) MethodCall(org.jgroups.blocks.MethodCall) PutCall(org.jgroups.tests.perf.PerfUtil.PutCall) Field(java.lang.reflect.Field) GetCall(org.jgroups.tests.perf.PerfUtil.GetCall) CountDownLatch(java.util.concurrent.CountDownLatch) org.jgroups.util(org.jgroups.util) RequestOptions(org.jgroups.blocks.RequestOptions) RELAY2(org.jgroups.protocols.relay.RELAY2) MBeanServer(javax.management.MBeanServer) org.jgroups(org.jgroups) Results(org.jgroups.tests.perf.PerfUtil.Results) Method(java.lang.reflect.Method) JmxConfigurator(org.jgroups.jmx.JmxConfigurator) TP(org.jgroups.protocols.TP) RpcDispatcher(org.jgroups.blocks.RpcDispatcher) RequestOptions(org.jgroups.blocks.RequestOptions) Config(org.jgroups.tests.perf.PerfUtil.Config) TP(org.jgroups.protocols.TP) MethodCall(org.jgroups.blocks.MethodCall) MBeanServer(javax.management.MBeanServer)

Example 4 with AddressGenerator

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();
    }
}
Also used : AddressGenerator(org.jgroups.stack.AddressGenerator)

Aggregations

AddressGenerator (org.jgroups.stack.AddressGenerator)4 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 java.util (java.util)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 LongAdder (java.util.concurrent.atomic.LongAdder)1 MBeanServer (javax.management.MBeanServer)1 org.jgroups (org.jgroups)1 Property (org.jgroups.annotations.Property)1 MethodCall (org.jgroups.blocks.MethodCall)1 RequestOptions (org.jgroups.blocks.RequestOptions)1 ResponseMode (org.jgroups.blocks.ResponseMode)1 RpcDispatcher (org.jgroups.blocks.RpcDispatcher)1 JmxConfigurator (org.jgroups.jmx.JmxConfigurator)1 TP (org.jgroups.protocols.TP)1 RELAY2 (org.jgroups.protocols.relay.RELAY2)1 Config (org.jgroups.tests.perf.PerfUtil.Config)1 GetCall (org.jgroups.tests.perf.PerfUtil.GetCall)1 PutCall (org.jgroups.tests.perf.PerfUtil.PutCall)1