예제 #1
0
  public static void main(String[] args) {
    String props = null;
    String name = null;

    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;
      }
      help();
      return;
    }

    UPerf test = null;
    try {
      test = new UPerf();
      test.init(props, name);
      test.eventLoop();
    } catch (Throwable ex) {
      ex.printStackTrace();
      if (test != null) test.stop();
    }
  }
예제 #2
0
    public void run() {
      final byte[] buf = new byte[msg_size];
      Object[] put_args = {0, buf};
      Object[] get_args = {0};
      MethodCall get_call = new MethodCall(GET, get_args);
      MethodCall put_call = new MethodCall(PUT, put_args);
      RequestOptions get_options = new RequestOptions(ResponseMode.GET_ALL, 40000, false, null);
      RequestOptions put_options =
          new RequestOptions(
              sync ? ResponseMode.GET_ALL : ResponseMode.GET_NONE, 40000, true, null);

      if (oob) {
        get_options.setFlags(Message.OOB);
        put_options.setFlags(Message.OOB);
      }
      if (sync) {
        get_options.setFlags(Message.DONT_BUNDLE, Message.NO_FC);
        put_options.setFlags(Message.DONT_BUNDLE, Message.NO_FC);
      }

      while (true) {
        long i = num_msgs_sent.getAndIncrement();
        if (i >= num_msgs_to_send) break;

        boolean get = Util.tossWeightedCoin(read_percentage);

        try {
          if (get) { // sync GET
            Address target = pickTarget();
            get_args[0] = i;
            disp.callRemoteMethod(target, get_call, get_options);
            num_gets++;
          } else { // sync or async (based on value of 'sync') PUT
            Collection<Address> targets = pickAnycastTargets();
            put_args[0] = i;
            disp.callRemoteMethods(targets, put_call, put_options);
            num_puts++;
          }
        } catch (Throwable throwable) {
          throwable.printStackTrace();
        }
      }
    }
예제 #3
0
  /**
   * Main function
   *
   * @param args
   */
  public static void main(String[] args) {
    JWhiteBoard whiteBoard = 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;

    // Get startup parameters for JWhiteBoard
    for (int i = 0; i < args.length; i++) {
      // Show help
      if ("-help".equals(args[i])) {
        help();
        return;
      }
      // Properties for Channel
      if ("-props".equals(args[i])) {
        props = args[++i];
        continue;
      }
      // If existed, use no channel
      if ("-no_channel".equals(args[i])) {
        no_channel = true;
        continue;
      }
      // Use Java Management Extensions or not
      if ("-jmx".equals(args[i])) {
        jmx = Boolean.parseBoolean(args[++i]);
        continue;
      }
      // If existed, set name for the Group
      if ("-clustername".equals(args[i])) {
        group_name = args[++i];
        continue;
      }
      // If existed, save Group's state
      if ("-state".equals(args[i])) {
        use_state = true;
        continue;
      }
      // If existed, set timeout for state
      if ("-timeout".equals(args[i])) {
        state_timeout = Long.parseLong(args[++i]);
        continue;
      }
      if ("-bind_addr".equals(args[i])) {
        System.setProperty("jgroups.bind_addr", 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.valueOf(args[++i]));
        continue;
      }

      help();
      return;
    }

    try {
      whiteBoard =
          new JWhiteBoard(
              props,
              no_channel,
              jmx,
              use_state,
              state_timeout,
              use_unicasts,
              name,
              send_own_state_on_merge,
              generator);
      if (group_name == null) whiteBoard.setGroupName(group_name);
      whiteBoard.go();
    } catch (Throwable e) {
      e.printStackTrace(System.err);
      System.exit(0);
    }
  }