コード例 #1
0
  /**
   * Load the profile information stored in the database
   *
   * @param
   */
  protected void loadProfile(AuctionMarkWorker worker) throws SQLException {
    synchronized (AuctionMarkProfile.class) {
      // Check whether we have a cached Profile we can copy from
      if (cachedProfile == null) {

        // Store everything in the cached profile.
        // We can then copy from that and extract out only the records
        // that we need for each AuctionMarkWorker
        cachedProfile = new AuctionMarkProfile(this.benchmark, this.rng);

        // Otherwise we have to go fetch everything again
        // So first we want to reset the database
        Connection conn = worker.getConnection();
        if (AuctionMarkConstants.RESET_DATABASE_ENABLE) {
          if (LOG.isDebugEnabled()) LOG.debug("Reseting database from last execution run");
          worker.getProcedure(ResetDatabase.class).run(conn);
        }

        // Then invoke LoadConfig to pull down the profile information we need
        if (LOG.isDebugEnabled()) LOG.debug("Loading AuctionMarkProfile for the first time");
        ResultSet results[] = worker.getProcedure(LoadConfig.class).run(conn);
        conn.commit();
        int result_idx = 0;

        // CONFIG_PROFILE
        loadConfigProfile(cachedProfile, results[result_idx++]);

        // IMPORTANT: We need to set these timestamps here. It must be done
        // after we have loaded benchmarkStartTime
        cachedProfile.setAndGetClientStartTime();
        cachedProfile.updateAndGetCurrentTime();

        // ITEM CATEGORY COUNTS
        loadItemCategoryCounts(cachedProfile, results[result_idx++]);

        // GLOBAL_ATTRIBUTE_GROUPS
        loadGlobalAttributeGroups(cachedProfile, results[result_idx++]);

        // PENDING COMMENTS
        loadPendingItemComments(cachedProfile, results[result_idx++]);

        // ITEMS
        while (result_idx < results.length) {
          //                assert(results[result_idx].isClosed() == false) :
          //                    "Unexpected closed ITEM ResultSet [idx=" + result_idx + "]";
          loadItems(cachedProfile, results[result_idx]);
          result_idx++;
        } // FOR

        for (ResultSet r : results) r.close();

        if (LOG.isDebugEnabled()) LOG.debug("Loaded profile:\n" + cachedProfile.toString());
      }
    } // SYNCH

    if (LOG.isTraceEnabled()) LOG.trace("Using cached SEATSProfile");
    this.copyProfile(worker, cachedProfile);
  }
コード例 #2
0
  private static final void loadConfigProfile(AuctionMarkProfile profile, ResultSet vt)
      throws SQLException {
    boolean adv = vt.next();
    assert (adv)
        : String.format(
            "Failed to get data from %s\n%s", AuctionMarkConstants.TABLENAME_CONFIG_PROFILE, vt);
    int col = 1;
    profile.scale_factor = vt.getDouble(col++);
    profile.loaderStartTime = vt.getTimestamp(col++);
    profile.loaderStopTime = vt.getTimestamp(col++);
    JSONUtil.fromJSONString(profile.users_per_itemCount, vt.getString(col++));

    if (LOG.isDebugEnabled())
      LOG.debug(String.format("Loaded %s data", AuctionMarkConstants.TABLENAME_CONFIG_PROFILE));
  }
コード例 #3
0
  private static final void loadItems(AuctionMarkProfile profile, ResultSet vt)
      throws SQLException {
    int ctr = 0;
    while (vt.next()) {
      int col = 1;
      ItemId i_id = new ItemId(vt.getLong(col++));
      double i_current_price = vt.getDouble(col++);
      Timestamp i_end_date = vt.getTimestamp(col++);
      int i_num_bids = (int) vt.getLong(col++);

      // IMPORTANT: Do not set the status here so that we make sure that
      // it is added to the right queue
      ItemInfo itemInfo = new ItemInfo(i_id, i_current_price, i_end_date, i_num_bids);
      profile.addItemToProperQueue(itemInfo, false);
      ctr++;
    } // WHILE

    if (LOG.isDebugEnabled())
      LOG.debug(
          String.format("Loaded %d records from %s", ctr, AuctionMarkConstants.TABLENAME_ITEM));
  }