<commit_before>package com.continuuity.data.runtime;

import com.continuuity.common.utils.Copyright;
import com.continuuity.data.operation.executor.remote.OperationExecutorService;
import com.google.inject.Guice;
import com.google.inject.Injector;

import java.io.PrintStream;

public class OpexServiceMain {

  static void usage(boolean error) {
    PrintStream out = (error ? System.err : System.out);
    String name = OpexServiceMain.class.getSimpleName();
    Copyright.print(out);
    out.println("Usage: ");
    out.println("  " + name + " ( start | stop ) ");
  }


  public static void main(String args[]) {

    if (args.length != 1) {
      usage(true);
      return;
    }
    if ("--help".equals(args[0])) {
      usage(false);
      return;
    }

    final int NOOP = 0;
    final int START = 1;
    final int STOP = 2;

    int command = NOOP;

    if ("start".equals(args[0])) {
      command = START;
    } else if ("stop".equals(args[0])) {
      command = STOP;
    } else {
      usage(true);
      return;
    }

    DataFabricDistributedModule module = new DataFabricDistributedModule();
    Injector injector = Guice.createInjector(module);

    // start an opex service
    final OperationExecutorService opexService =
        injector.getInstance(OperationExecutorService.class);

    if (START == command) {
      Copyright.print(System.out);
      System.out.println("Starting Operation Executor Service...");
      // start it. start is blocking, hence main won't terminate
      try {
        opexService.start(new String[] { }, module.getConfiguration());
      } catch (Exception e) {
        System.err.println("Failed to start service: " + e.getMessage());
        return;
      }
    }
    else if (STOP == command) {
      Copyright.print(System.out);
      System.out.println("Stopping Operation Executor Service...");
      opexService.stop(true);
    }
  }
}
<commit_msg>ENG-466 Instrument RemoteOpex for performance<commit_after>package com.continuuity.data.runtime;

import com.continuuity.common.conf.CConfiguration;
import com.continuuity.common.utils.Copyright;
import com.continuuity.data.operation.executor.remote.OperationExecutorService;
import com.continuuity.metrics2.collector.OverlordMetricsReporter;
import com.google.inject.Guice;
import com.google.inject.Injector;

import java.io.PrintStream;
import java.util.concurrent.TimeUnit;

public class OpexServiceMain {

  static void usage(boolean error) {
    PrintStream out = (error ? System.err : System.out);
    String name = OpexServiceMain.class.getSimpleName();
    Copyright.print(out);
    out.println("Usage: ");
    out.println("  " + name + " ( start | stop ) ");
  }


  public static void main(String args[]) {

    if (args.length != 1) {
      usage(true);
      return;
    }
    if ("--help".equals(args[0])) {
      usage(false);
      return;
    }

    final int NOOP = 0;
    final int START = 1;
    final int STOP = 2;

    int command = NOOP;

    if ("start".equals(args[0])) {
      command = START;
    } else if ("stop".equals(args[0])) {
      command = STOP;
    } else {
      usage(true);
      return;
    }

    DataFabricDistributedModule module = new DataFabricDistributedModule();
    Injector injector = Guice.createInjector(module);

    // start an opex service
    final OperationExecutorService opexService =
        injector.getInstance(OperationExecutorService.class);

    if (START == command) {

      // enable metrics collection
      CConfiguration configuration = module.getConfiguration();
      OverlordMetricsReporter.enable(1, TimeUnit.SECONDS, configuration);

      Copyright.print(System.out);
      System.out.println("Starting Operation Executor Service...");
      // start it. start is blocking, hence main won't terminate
      try {
        opexService.start(new String[] { }, configuration);
      } catch (Exception e) {
        System.err.println("Failed to start service: " + e.getMessage());
        return;
      }
    }
    else if (STOP == command) {
      Copyright.print(System.out);
      System.out.println("Stopping Operation Executor Service...");
      opexService.stop(true);
    }
  }
}

{'fraction_non_alphanumeric': 0.12467034284344282, 'fraction_numerical': 0.004555262526971949, 'mean_word_length': 2.928436911487759, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2652340', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1219, 'n_words': 277}