Пример #1
0
  public void init(String props, String name) throws Throwable {
    channel = new JChannel(props);
    if (name != null) channel.setName(name);
    disp = new RpcDispatcher(channel, null, this, this);
    disp.setMethodLookup(
        new MethodLookup() {
          public Method findMethod(short id) {
            return METHODS[id];
          }
        });
    disp.setRequestMarshaller(new CustomMarshaller());
    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);
    ConfigOptions config =
        (ConfigOptions)
            disp.callRemoteMethod(
                coord, new MethodCall(GET_CONFIG), new RequestOptions(ResponseMode.GET_ALL, 5000));
    if (config != null) {
      this.oob = config.oob;
      this.sync = config.sync;
      this.num_threads = config.num_threads;
      this.num_msgs = config.num_msgs;
      this.msg_size = config.msg_size;
      this.anycast_count = config.anycast_count;
      this.read_percentage = config.read_percentage;
      System.out.println("Fetched config from " + coord + ": " + config);
    } else System.err.println("failed to fetch config from " + coord);
  }