Exemplo n.º 1
0
  public MyTPCC(String args[]) {
    m_helpah = new AppHelper(MyTPCC.class.getCanonicalName());
    m_helpah.add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 180);
    m_helpah.add("warehouses", "number_of_warehouses", "Number of warehouses", 12);
    m_helpah.add("scalefactor", "scale_factor", "Scale factor", 1.0);
    m_helpah.add("skewfactor", "skew_factor", "Skew factor", 0.0);
    m_helpah.add("loadthreads", "number_of_load_threads", "Number of load threads", 4);
    m_helpah.add("ratelimit", "rate_limit", "Rate limit to start from (tps)", 200000);
    m_helpah.add(
        "displayinterval",
        "display_interval_in_seconds",
        "Interval for performance feedback, in seconds.",
        10);
    m_helpah.add(
        "servers",
        "comma_separated_server_list",
        "List of VoltDB servers to connect to.",
        "localhost");
    m_helpah.setArguments(args);

    // default values
    int warehouses = m_helpah.intValue("warehouses");
    double scalefactor = m_helpah.doubleValue("scalefactor");
    double skewfactor = m_helpah.doubleValue("skewfactor");

    String servers = m_helpah.stringValue("servers");
    System.out.printf("Connecting to servers: %s\n", servers);
    int sleep = 1000;
    while (true) {
      try {
        m_clientCon = ClientConnectionPool.get(servers, 21212);
        break;
      } catch (Exception e) {
        System.err.printf("Connection failed - retrying in %d second(s).\n", sleep / 1000);
        try {
          Thread.sleep(sleep);
        } catch (Exception tie) {
        }
        if (sleep < 8000) sleep += sleep;
      }
    }
    System.out.println("Connected.  Starting benchmark.");

    try {
      if ((int)
              (m_clientCon
                  .execute(LoadStatus.class.getSimpleName())
                  .getResults()[0]
                  .fetchRow(0)
                  .getLong(0))
          == 0) (new MyLoader(args, m_clientCon)).run();
      else
        while ((int)
                (m_clientCon
                    .execute(LoadStatus.class.getSimpleName())
                    .getResults()[0]
                    .fetchRow(0)
                    .getLong(0))
            < warehouses) ;
    } catch (Exception e) {
      System.exit(-1);
    }

    // makeForRun requires the value cLast from the load generator in
    // order to produce a valid generator for the run. Thus the sort
    // of weird eat-your-own ctor pattern.
    RandomGenerator.NURandC base_loadC = new RandomGenerator.NURandC(0, 0, 0);
    RandomGenerator.NURandC base_runC =
        RandomGenerator.NURandC.makeForRun(new RandomGenerator.Implementation(0), base_loadC);
    RandomGenerator rng = new RandomGenerator.Implementation(0);
    rng.setC(base_runC);

    scaleParams = ScaleParameters.makeWithScaleFactor(warehouses, scalefactor);
    tpccSim = new TPCCSimulation(this, rng, new Clock.RealTime(), scaleParams, false, skewfactor);
  }