コード例 #1
0
ファイル: Job.java プロジェクト: pmacko86/pig-bench
  /**
   * Create an instance of a Job from a list of arguments
   *
   * @param arguments the arguments
   */
  public Job(final List<String> arguments) {
    this();

    this.arguments = new ArrayList<String>();
    this.arguments.add(Bench.graphdbBenchDir + "/runBenchmarkSuite.sh");

    // Copy the + arguments first

    for (int i = 0; i < arguments.size(); i++) {
      String a = arguments.get(i);
      if (a.startsWith("+")) this.arguments.add(a);
    }

    // Further arguments that we need to run the job through the web interface

    this.arguments.add("--dumb-terminal");

    // Copy the arguments and extract the database engine and instance names

    for (int i = 0; i < arguments.size(); i++) {
      String a = arguments.get(i);
      if (a.startsWith("+")) continue;

      if (a.startsWith("--")) {
        if (DatabaseEngine.ENGINES.containsKey(a.substring(2))) {
          if (dbEngine != null) {
            throw new IllegalArgumentException("Cannot specify more than one database engine");
          }
          dbEngine = a.substring(2);
        }
      }

      if (a.equals("--database") || a.equals("-d")) {
        if (i + 1 >= arguments.size() || arguments.get(i + 1).startsWith("-")) {
          throw new IllegalArgumentException("The " + a + " option requires an argument");
        }
        if (dbInstance != null) {
          throw new IllegalArgumentException("Cannot specify more than one database instance");
        }
        dbInstance = arguments.get(i + 1);
        WebUtils.asssertDatabaseInstanceNameValidity(dbInstance);
      }

      this.arguments.add(a);
    }

    if (dbEngine == null) {
      throw new IllegalArgumentException("No database engine is specified");
    }
  }
コード例 #2
0
ファイル: Job.java プロジェクト: pmacko86/pig-bench
  /**
   * Load from an HTTP request
   *
   * @param request the HTTP request from which to create the job
   * @param _dbEngine a specific database engine name to use instead of the one from the request
   * @param _dbInstance a specific database instance to use instead of the one from the request
   */
  protected void loadFromRequest(HttpServletRequest request, String _dbEngine, String _dbInstance) {

    arguments = new ArrayList<String>();
    status = -1;
    executionCount = 0;
    executionTime = null;
    logFile = null;

    // Get the relevant configuration

    boolean provenanceEnabled = Bench.getBooleanProperty(Bench.CPL_ENABLED, true);
    boolean warmupEnabled = Bench.getBooleanProperty(Bench.WARMUP_ENABLED, true);

    // Get the request arguments

    dbEngine = WebUtils.getStringParameter(request, "database_name");
    dbInstance = WebUtils.getStringParameter(request, "database_instance");
    if (_dbEngine != null) {
      dbEngine = _dbEngine;
      dbInstance = _dbInstance;
      if (dbInstance != null) {
        if (dbInstance.equals("<new>")) {
          dbInstance = WebUtils.getStringParameter(request, "new_database_instance");
        }
      }
    }
    if (dbInstance != null) {
      if (dbInstance.equals("")) dbInstance = null;
    }
    if (!DatabaseEngine.ENGINES.containsKey(dbEngine)) {
      throw new IllegalArgumentException("Unknown database engine: " + dbEngine);
    }
    if (dbInstance != null) {
      WebUtils.asssertDatabaseInstanceNameValidity(dbInstance);
    }

    String s_annotation = WebUtils.getStringParameter(request, "annotation");
    String s_txBuffer = WebUtils.getStringParameter(request, "tx_buffer");
    String s_opCount = WebUtils.getStringParameter(request, "op_count");
    String s_warmupOpCount = WebUtils.getStringParameter(request, "warmup_op_count");
    String s_kHops = WebUtils.getStringParameter(request, "k_hops");

    boolean useJRockit = WebUtils.getBooleanParameter(request, "use_jrockit", false);
    boolean noProvenance = WebUtils.getBooleanParameter(request, "no_provenance", false);
    boolean forceBlueprints = WebUtils.getBooleanParameter(request, "force_blueprints", false);
    boolean useStoredProcedures =
        WebUtils.getBooleanParameter(request, "use_stored_procedures", false);
    boolean noWarmup = WebUtils.getBooleanParameter(request, "no_warmup", false);
    boolean noCachePollution = WebUtils.getBooleanParameter(request, "no_cache_pollution", false);
    boolean updateDirectly = WebUtils.getBooleanParameter(request, "update_directly", false);
    boolean iostat = WebUtils.getBooleanParameter(request, "iostat", false);
    String s_javaHeapSize = WebUtils.getStringParameter(request, "java_heap_size");
    String s_dbCacheSize = WebUtils.getStringParameter(request, "db_cache_size");

    boolean ingestAsUndirected =
        WebUtils.getBooleanParameter(request, "ingest_as_undirected", false);
    String s_ingestFile = WebUtils.getStringParameter(request, "ingest_file");
    String s_ingestWarmupFile = WebUtils.getStringParameter(request, "ingest_warmup_file");

    String s_generateModel = WebUtils.getStringParameter(request, "generate_model");
    String s_generateBarabasiN = WebUtils.getStringParameter(request, "generate_barabasi_n");
    String s_generateBarabasiM = WebUtils.getStringParameter(request, "generate_barabasi_m");

    String s_vertexPropertyKeys = WebUtils.getStringParameter(request, "vertex_property_keys");
    String s_edgePropertyKeys = WebUtils.getStringParameter(request, "edge_property_keys");
    String s_propertyKeys = combinePropertyKeys(s_vertexPropertyKeys, s_edgePropertyKeys);
    String s_edgeCondProp = WebUtils.getStringParameter(request, "edge_cond_prop");

    String s_edgeLabels = WebUtils.getStringParameter(request, "edge_labels");
    String s_edgeLabelsNormalized = combinePropertyKeys(s_edgeLabels, null);

    // Get the workloads

    String[] a_workloads = WebUtils.getStringParameterValues(request, "workloads");
    HashMap<String, Workload> workloads = new HashMap<String, Workload>();

    boolean usesOpCount = false;
    boolean hasUpdates = false;
    @SuppressWarnings("unused")
    boolean hasLoadUpdates = false;
    boolean hasNonLoadUpdates = false;

    if (a_workloads != null) {
      for (String w : a_workloads) {

        Workload workload = Workload.WORKLOADS.get(w);
        if (workload == null) throw new IllegalArgumentException("Unknown workload: " + w);

        workloads.put(w, workload);

        if (workload.isUsingOpCount()) usesOpCount = true;
        if (workload.isUpdate()) {
          hasUpdates = true;
          if (workload.getUpdateCategory() == Workload.UpdateCategory.LOAD_UPDATE)
            hasLoadUpdates = true;
          if (workload.getUpdateCategory() != Workload.UpdateCategory.LOAD_UPDATE)
            hasNonLoadUpdates = true;
        }
      }
    }

    // Build the list of command-line arguments

    arguments.add(Bench.graphdbBenchDir + "/runBenchmarkSuite.sh");

    if (useJRockit) {
      arguments.add("+jrockit");
    }

    if (s_javaHeapSize != null) {
      if (!s_javaHeapSize.equalsIgnoreCase(BenchmarkMicro.DEFAULT_JVM_HEAP_SIZE)) {
        arguments.add("+memory:" + s_javaHeapSize);
      }
    }

    arguments.add("--dumb-terminal");

    if (dbEngine != null) {
      arguments.add("--" + dbEngine);
    }
    if (dbInstance != null) {
      arguments.add("--database");
      arguments.add(dbInstance);
    }
    if (s_annotation != null) {
      arguments.add("--annotation");
      arguments.add(s_annotation);
    }

    if (s_dbCacheSize != null) {
      if (!s_dbCacheSize.equals(
          Bench.getProperty(Bench.DB_CACHE_SIZE, "" + GlobalConfig.databaseCacheSize))) {
        arguments.add("--db-cache-size");
        arguments.add(s_dbCacheSize);
      }
    }

    if (s_txBuffer != null) {
      if (!s_txBuffer.equals("" + BenchmarkMicro.DEFAULT_NUM_THREADS)) {
        arguments.add("--tx-buffer");
        arguments.add(s_txBuffer);
      }
    }

    if (noProvenance && provenanceEnabled) {
      arguments.add("--no-provenance");
    }

    if (noCachePollution) {
      arguments.add("--no-cache-pollution");
    }

    if (noWarmup && warmupEnabled) {
      arguments.add("--no-warmup");
    }

    if (forceBlueprints) {
      arguments.add("--force-blueprints");
    }

    if (useStoredProcedures) {
      arguments.add("--use-stored-procedures");
    }

    if (updateDirectly && hasUpdates && hasNonLoadUpdates) {
      arguments.add("--update-directly");
    }

    if (iostat) {
      arguments.add("--iostat");
    }

    if (a_workloads != null) {
      for (String s : a_workloads) {
        arguments.add("--" + s);
        if ("ingest".equals(s) && s_ingestFile != null) {
          arguments.add(s_ingestFile);
        }
        if ("incr-ingest".equals(s) && s_ingestFile != null) {
          arguments.add(s_ingestFile);
        }
        if ("generate".equals(s) && s_generateModel != null) {
          arguments.add(s_generateModel);
        }
        if ("create-index".equals(s)
            && s_propertyKeys != null
            && !BenchmarkMicro.DEFAULT_PROPERTY_KEYS.equals(s_propertyKeys)) {
          arguments.add(s_propertyKeys);
        }
        if ("get-index".equals(s)
            && s_propertyKeys != null
            && !BenchmarkMicro.DEFAULT_PROPERTY_KEYS.equals(s_propertyKeys)) {
          arguments.add(s_propertyKeys);
        }
        if ("get-property".equals(s)
            && s_propertyKeys != null
            && !BenchmarkMicro.DEFAULT_PROPERTY_KEYS.equals(s_propertyKeys)) {
          arguments.add(s_propertyKeys);
        }
        if ("get-label".equals(s)
            && s_edgeLabelsNormalized != null
            && !BenchmarkMicro.DEFAULT_EDGE_LABELS.equals(s_edgeLabelsNormalized)) {
          arguments.add(s_edgeLabelsNormalized);
        }
        if ("get-k-label".equals(s)
            && s_edgeLabelsNormalized != null
            && !BenchmarkMicro.DEFAULT_EDGE_LABELS.equals(s_edgeLabelsNormalized)) {
          arguments.add(s_edgeLabelsNormalized);
        }
      }
    }

    if (usesOpCount) {
      if (s_opCount != null) {
        if (!s_opCount.equals("" + BenchmarkMicro.DEFAULT_OP_COUNT)) {
          arguments.add("--op-count");
          arguments.add(s_opCount);
        }
      }
      if (s_warmupOpCount != null) {
        if (!s_warmupOpCount.equals(s_opCount) && !noWarmup && warmupEnabled) {
          arguments.add("--warmup-op-count");
          arguments.add(s_warmupOpCount);
        }
      }
    }

    if (workloads.containsKey("get-k")) {
      if (s_kHops != null) {
        if (!s_kHops.equals("" + BenchmarkMicro.DEFAULT_K_HOPS)) {
          arguments.add("--k-hops");
          arguments.add(s_kHops);
        }
      }
    }

    if (s_edgeCondProp != null
        && !BenchmarkMicro.DEFAULT_EDGE_CONDITIONAL_PROPERTY_KEY.equals(s_edgeCondProp)) {
      if (workloads.containsKey("get")
          || workloads.containsKey("get--micro")
          || workloads.containsKey("get--traversals")
          || workloads.containsKey("get-k")
          || workloads.containsKey("get-label")
          || workloads.containsKey("get-k-label")) {
        arguments.add("--edge-cond-prop");
        arguments.add(s_edgeCondProp);
      }
    }

    if (workloads.containsKey("ingest") || workloads.containsKey("incr-ingest")) {
      if (ingestAsUndirected) {
        arguments.add("--ingest-as-undirected");
      }
      if (s_ingestWarmupFile != null) {
        if (!s_ingestWarmupFile.equals(s_ingestFile)) {
          arguments.add("--warmup-ingest");
          arguments.add(s_ingestWarmupFile);
        }
      }
    }

    if (workloads.containsKey("generate")) {
      if (s_generateModel == null || "barabasi".equals(s_generateModel)) {
        if (s_generateBarabasiN != null) {
          if (!s_generateBarabasiN.equals("" + BenchmarkMicro.DEFAULT_BARABASI_N)) {
            arguments.add("--barabasi-n");
            arguments.add(s_generateBarabasiN);
          }
        }
        if (s_generateBarabasiM != null) {
          if (!s_generateBarabasiM.equals("" + BenchmarkMicro.DEFAULT_BARABASI_M)) {
            arguments.add("--barabasi-m");
            arguments.add(s_generateBarabasiM);
          }
        }
      }
    }
  }