示例#1
0
  /** Executes a payment transaction. */
  public void doPayment() throws IOException {
    boolean allow_remote = (parameters.warehouses > 1 && config.payment_multip != false);
    double remote_prob = (config.payment_multip_mix >= 0 ? config.payment_multip_mix : 15) * 10d;

    short w_id = generateWarehouseId();
    byte d_id = generateDistrict();

    short c_w_id;
    byte c_d_id;
    if (allow_remote == false || generator.number(1, 1000) <= (1000 - remote_prob)) {
      // 85%: paying through own warehouse (or there is only 1 warehouse)
      c_w_id = w_id;
      c_d_id = d_id;
    } else {
      // 15%: paying through another warehouse:
      if (config.warehouse_pairing) {
        c_w_id =
            generatePairedWarehouse(w_id, parameters.starting_warehouse, parameters.last_warehouse);
      } else if (config.payment_multip_remote) {
        c_w_id =
            (short)
                generator.numberRemoteWarehouseId(
                    parameters.starting_warehouse, parameters.last_warehouse, (int) w_id);
      } else {
        // select in range [1, num_warehouses] excluding w_id
        c_w_id =
            (short)
                generator.numberExcluding(
                    parameters.starting_warehouse, parameters.last_warehouse, w_id);
      }
      assert c_w_id != w_id;
      c_d_id = generateDistrict();
    }
    double h_amount = generator.fixedPoint(2, TPCCConstants.MIN_PAYMENT, TPCCConstants.MAX_PAYMENT);
    TimestampType now = clock.getDateTime();

    if (generator.number(1, 100) <= 60) {
      // 60%: payment by last name
      String c_last = generator.makeRandomLastName(parameters.customersPerDistrict);
      client.callPaymentByName(w_id, d_id, h_amount, c_w_id, c_d_id, c_last, now);
    } else {
      // 40%: payment by id
      client.callPaymentById(w_id, d_id, h_amount, c_w_id, c_d_id, generateCID(), now);
    }
  }
示例#2
0
  /** Executes a new order transaction. */
  public void doNewOrder() throws IOException {
    short warehouse_id = generateWarehouseId();
    int ol_cnt = generator.number(TPCCConstants.MIN_OL_CNT, TPCCConstants.MAX_OL_CNT);

    // 1% of transactions roll back
    boolean rollback = (config.neworder_abort && generator.number(1, 100) == 1);
    int local_warehouses = 0;
    int remote_warehouses = 0;

    int[] item_id = new int[ol_cnt];
    short[] supply_w_id = new short[ol_cnt];
    int[] quantity = new int[ol_cnt];
    for (int i = 0; i < ol_cnt; ++i) {
      if (rollback && i + 1 == ol_cnt) {
        // LOG.fine("[NOT_ERROR] Causing a rollback on purpose defined in TPCC spec. "
        //     + "You can ignore following 'ItemNotFound' exception.");
        item_id[i] = parameters.items + 1;
      } else {
        item_id[i] = generateItemID();
      }

      // 1% of items are from a remote warehouse
      boolean remote = config.neworder_multip && (generator.number(1, 100) == 1);
      if (parameters.warehouses > 1 && remote) {
        short remote_w_id;
        if (config.warehouse_pairing) {
          remote_w_id =
              generatePairedWarehouse(
                  warehouse_id, parameters.starting_warehouse, parameters.last_warehouse);
        } else {
          remote_w_id =
              (short)
                  generator.numberExcluding(
                      parameters.starting_warehouse, parameters.last_warehouse, (int) warehouse_id);
        }
        supply_w_id[i] = remote_w_id;
        if (supply_w_id[i] != warehouse_id) remote_warehouses++;
        else local_warehouses++;
      } else {
        supply_w_id[i] = warehouse_id;
        local_warehouses++;
      }

      quantity[i] = generator.number(1, TPCCConstants.MAX_OL_QUANTITY);
    }
    // Whether to force this transaction to be multi-partitioned
    if (parameters.warehouses > 1
        && config.neworder_multip == false
        && config.neworder_multip_mix > 0
        && (generator.number(1, 1000) <= (config.neworder_multip_mix * 100))) {
      if (trace.val) LOG.trace("Forcing Multi-Partition NewOrder Transaction");
      // Flip a random one
      int idx = generator.number(0, ol_cnt - 1);
      short remote_w_id;
      if (config.warehouse_pairing) {
        remote_w_id =
            generatePairedWarehouse(
                warehouse_id, parameters.starting_warehouse, parameters.last_warehouse);
      }
      if (config.neworder_multip_remote) {
        remote_w_id =
            (short)
                generator.numberRemoteWarehouseId(
                    parameters.starting_warehouse, parameters.last_warehouse, (int) warehouse_id);
      } else {
        remote_w_id =
            (short)
                generator.numberExcluding(
                    parameters.starting_warehouse, parameters.last_warehouse, (int) warehouse_id);
      }
      supply_w_id[idx] = remote_w_id;
    }

    if (trace.val)
      LOG.trace(
          "newOrder(W_ID="
              + warehouse_id
              + ") -> ["
              + "local_warehouses="
              + local_warehouses
              + ", "
              + "remote_warehouses="
              + remote_warehouses
              + "]");

    TimestampType now = clock.getDateTime();
    client.callNewOrder(
        rollback,
        config.noop,
        warehouse_id,
        generateDistrict(),
        generateCID(),
        now,
        item_id,
        supply_w_id,
        quantity);
  }
示例#3
0
  /** Executes a delivery transaction. */
  public void doDelivery() throws IOException {
    int carrier = generator.number(TPCCConstants.MIN_CARRIER_ID, TPCCConstants.MAX_CARRIER_ID);

    client.callDelivery(generateWarehouseId(), carrier, clock.getDateTime());
  }