Package org.radargun.stages.tpcc.domain

Examples of org.radargun.stages.tpcc.domain.Customer


      if (id_wharehouse < 0 || id_district < 0) return;
      else {
         log.info(" CUSTOMER " + id_wharehouse + ", " + id_district);
         for (int i = 1; i <= TpccTools.NB_MAX_CUSTOMER; i++) {

            Customer newCustomer = new Customer(id_wharehouse,
                                                id_district,
                                                i,
                                                TpccTools.aleaChainec(8, 16),
                                                "OE",
                                                c_last(),
                                                TpccTools.aleaChainec(10, 20),
                                                TpccTools.aleaChainec(10, 20),
                                                TpccTools.aleaChainec(10, 20),
                                                TpccTools.aleaChainel(2, 2),
                                                TpccTools.aleaChainen(4, 4) + TpccTools.CHAINE_5_1,
                                                TpccTools.aleaChainen(16, 16),
                                                new Date(System.currentTimeMillis()),
                                                (TpccTools.aleaNumber(1, 10) == 1) ? "BC" : "GC",
                                                500000.0, TpccTools.aleaDouble(0., 0.5, 4), -10.0, 10.0, 1, 0, TpccTools.aleaChainec(300, 500));


            boolean successful = false;
            while (!successful) {
               try {
                  newCustomer.store(basicCache);
                  successful = true;
               } catch (Throwable e) {
                  log.warn("Storing new customer failed", e);
               }
            }
View Full Code Here


   private void orderStatusTransaction(BasicOperations.Cache basicCache, long w_id, long d_id, long c_id, String c_last, boolean c_by_name) throws Throwable {
      long namecnt;

      boolean found = false;
      Customer c = null;
      if (c_by_name) {
         List<Customer> cList = CustomerDAC.loadByCLast(basicCache, w_id, d_id, c_last);
         if (cList == null || cList.isEmpty())
            throw new ElementNotFoundException("C_LAST=" + c_last + " C_D_ID=" + d_id + " C_W_ID=" + w_id + " not found!");
         Collections.sort(cList);


         namecnt = cList.size();


         if (namecnt % 2 == 1) namecnt++;
         Iterator<Customer> itr = cList.iterator();

         for (int i = 1; i <= namecnt / 2; i++) {

            c = itr.next();

         }

      } else {
         // clause 2.6.2.2 (dot 3, Case 1)
         c = new Customer();
         c.setC_id(c_id);
         c.setC_d_id(d_id);
         c.setC_w_id(w_id);
         found = c.load(basicCache);
         if (!found)
            throw new ElementNotFoundException("C_ID=" + c_id + " C_D_ID=" + d_id + " C_W_ID=" + w_id + " not found!");

      }
View Full Code Here

      long ol_supply_w_id, ol_i_id, ol_quantity;
      int s_remote_cnt_increment;
      double ol_amount, total_amount = 0;


      Customer c = new Customer();
      Warehouse w = new Warehouse();

      c.setC_id(c_id);
      c.setC_d_id(d_id);
      c.setC_w_id(w_id);

      boolean found = c.load(basicCache);

      if (!found)
         throw new ElementNotFoundException("W_ID=" + w_id + " C_D_ID=" + d_id + " C_ID=" + c_id + " not found!");

      w.setW_id(w_id);
View Full Code Here

   private CustomerDAC() {
   }

   public static List<Customer> loadByCLast(BasicOperations.Cache basicCache, long c_w_id, long c_d_id, String c_last) throws Throwable {
      List<Customer> result = new ArrayList<Customer>();
      Customer current = null;
      boolean found = false;

      for (int i = 1; i <= TpccTools.NB_MAX_CUSTOMER; i++) {
         current = new Customer();
         current.setC_id(i);
         current.setC_d_id(c_d_id);
         current.setC_w_id(c_w_id);
         found = current.load(basicCache);
         if (found && current.getC_last() != null && current.getC_last().equals(c_last)) {
            result.add(current);
         }
      }
      return result;
   }
View Full Code Here

      if (!found) throw new ElementNotFoundException("D_ID=" + d_id + " D_W_ID=" + w_id + " not found!");

      d.setD_ytd(h_amount);
      d.store(basicCache);

      Customer c = null;

      if (c_by_name) {
         new_c_last = c_last;
         List cList = null;
         cList = CustomerDAC.loadByCLast(basicCache, c_w_id, c_d_id, new_c_last);

         if (cList == null || cList.isEmpty())
            throw new ElementNotFoundException("C_LAST=" + c_last + " C_D_ID=" + c_d_id + " C_W_ID=" + c_w_id + " not found!");

         Collections.sort(cList);

         namecnt = cList.size();

         if (namecnt % 2 == 1) namecnt++;
         Iterator<Customer> itr = cList.iterator();

         for (int i = 1; i <= namecnt / 2; i++) {
            c = itr.next();
         }
      } else {
         c = new Customer();
         c.setC_id(c_id);
         c.setC_d_id(c_d_id);
         c.setC_w_id(c_w_id);
         found = c.load(basicCache);
         if (!found)
            throw new ElementNotFoundException("C_ID=" + c_id + " C_D_ID=" + c_d_id + " C_W_ID=" + c_w_id + " not found!");
      }

      c.setC_balance(c.getC_balance() + h_amount);
      if (c.getC_credit().equals("BC")) {

         c_data = c.getC_data();

         c_new_data = c.getC_id() + " " + c_d_id + " " + c_w_id + " " + d_id + " " + w_id + " " + h_amount + " |";
         if (c_data.length() > c_new_data.length()) {
            c_new_data += c_data.substring(0, c_data.length() - c_new_data.length());
         } else {
            c_new_data += c_data;
         }

         if (c_new_data.length() > 500) c_new_data = c_new_data.substring(0, 500);

         c.setC_data(c_new_data);
         c.store(basicCache);
      } else {
         c.store(basicCache);
      }

      w_name = w.getW_name();
      d_name = d.getD_name();

      if (w_name.length() > 10) w_name = w_name.substring(0, 10);
      if (d_name.length() > 10) d_name = d_name.substring(0, 10);
      h_data = w_name + "    " + d_name;

      History h = new History(c.getC_id(), c_d_id, c_w_id, d_id, w_id, new Date(), h_amount, h_data);
      h.store(basicCache, this.slaveIndex);
   }
View Full Code Here

TOP

Related Classes of org.radargun.stages.tpcc.domain.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.