Search in sources :

Example 1 with Config

use of org.jgroups.tests.perf.PerfUtil.Config 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)

Aggregations

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 AddressGenerator (org.jgroups.stack.AddressGenerator)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