示例#1
0
  public void scheduleAndQueueTPCC(int index, String key, long l, String clId, long tInv) {
    Scheduler scheduler = new Scheduler();
    // Session session = null;
    String cLevel = "ALL", condn = "price>20";
    ClientQueryExampleThread clientQueryExampleThread = new ClientQueryExampleThread(clId, tInv, 1);
    if (ClientQueryExampleThread.session == null || ClientQueryExampleThread.session.isClosed())
      ClientQueryExampleThread.session =
          ClientQueryExampleThread.callClient(cLevel, condn); // unblock for deploy
    Query q = null;
    // UUID idOne = UUID.randomUUID();
    String CLID = null; // String.valueOf(idOne) + String.valueOf(System.currentTimeMillis());
    long latencyDep = 0;
    l = System.currentTimeMillis() - l;
    // key = (String)
    // ((HashMap<String,String>)DependencyChecker.serializeList.get(index)).keySet().toArray()[0];

    curr_deadline = curr_deadline - (System.currentTimeMillis() - tInv);
    createRegistry(ClientQueryExampleThread.session);

    writeToRegister(
        key,
        index,
        clId,
        l,
        latencyDep,
        curr_deadline,
        "OFF",
        ClientQueryExampleThread.session); // unblock for deploy
    System.out.println(
        "***After write to register"); // for thread "+Thread.currentThread().getName());
    // CLID = readFromRegister(key, session);//unblock for deploy
    // System.out.println("****rlist size:="+ rList.size());
    // if(rList.size()>0)
    // if(CLID!=null)
    // {
    // CLID = scheduler.schedule(rList).split(":")[0];
    // STATUS = scheduler.schedule(rList).split(":")[1];

    while (readFromRegister(key, ClientQueryExampleThread.session) != null
        && readFromRegister(key, ClientQueryExampleThread.session).contains(":")
        && readFromRegister(key, ClientQueryExampleThread.session)
            .split(":")[1]
            .equalsIgnoreCase("OFF")
        && !clId.equalsIgnoreCase(
            readFromRegister(key, ClientQueryExampleThread.session)
                .split(":")[0])) // || !STATUS.equalsIgnoreCase("OFF"))
    {
      // System.out.println("***Client " + clId +"Waiting for the lock to the column "+key);// for
      // thread "+Thread.currentThread().getName());
      // System.out.println("***Waiting for the lock to the column "+key);// for thread
      // "+Thread.currentThread().getName());
    }
    scheduler.requestLock(ClientQueryExampleThread.session, key, clId, index); // unblock for deploy
    System.out.println("***After requesting the lock to the columnfor the query index" + index);
  }
示例#2
0
  public ResultSet scheduleAndQueue(
      String operationtype,
      Statement statement,
      Session session,
      int index,
      long l,
      long latency_insert2,
      String cLevel,
      String clId,
      long tInv,
      Tuple tuple) {
    Query q = null;
    String key = null;
    // UUID idOne = UUID.randomUUID();
    String CLID = null; // String.valueOf(idOne) + String.valueOf(System.currentTimeMillis());
    long latencyDep = 0;
    CopyOnWriteArrayList<RegistryEntry> rList = null;
    String STATUS;
    ResultSet result = null;
    Scheduler scheduler = new Scheduler();

    if ((DependencyChecker.causalList.size() > index
            && ((Query) DependencyChecker.causalList.get(index))
                .getGuarantee()
                .equalsIgnoreCase("C"))
        || (DependencyChecker.serializeList.size() > index
            && ((Query) DependencyChecker.serializeList.get(index))
                .getGuarantee()
                .equalsIgnoreCase("S"))) {
      // System.out.println("***in iof constion causal:serialise");
      if (DependencyChecker.causalList.contains(index)
          && ((Query) DependencyChecker.causalList.get(index))
              .getGuarantee()
              .equalsIgnoreCase("C")) {
        while (!((Query) DependencyChecker.causalList.get(index))
            .getIndex()
            .equalsIgnoreCase(String.valueOf(index))) {
          // System.out.println("***Waiting in causal queue");
        }
        // if(((Query)DependencyChecker.causalList.get(index)).getIndex().equalsIgnoreCase(String.valu             eOf(index)))
        // {
        statement = updateConsistencyLevel(statement, cLevel, index, tuple);
        result = session.execute(statement); // unblock for deploy
        q = tuple.getCausalQueue().remove();
      } else {
        // System.out.println("***in else
        // constionL===="+((Query)tuple.getDependencyChecker().getSerializeList().get(index)).getIndex()+": index"+String.valueOf((int)tuple.getDependencyChecker().getQueryList().size()-index-1));
        if (((Query) DependencyChecker.serializeList.get(index))
            .getIndex()
            .equalsIgnoreCase(
                String.valueOf((int) DependencyChecker.queryList.size() - 1 - index))) {
          // System.out.println("1111in else
          // constionL===="+((Query)tuple.getDependencyChecker().getSerializeList().get(index)).getIndex());
          l = System.currentTimeMillis() - l;
          // key = (String)
          // ((HashMap<String,String>)DependencyChecker.serializeList.get(index)).keySet().toArray()[0];
          key = ((Query) DependencyChecker.serializeList.get(index)).getKey();
          for (int i = index; i < DependencyChecker.serializeList.size(); i++) {
            latencyDep = latencyDep + ((Query) DependencyChecker.serializeList.get(i)).getLatency();
          }
          curr_deadline = curr_deadline - (System.currentTimeMillis() - tInv);
          createRegistry(session);

          writeToRegister(
              ((Query) DependencyChecker.serializeList.get(index)).getKey(),
              index,
              clId,
              l,
              latencyDep,
              curr_deadline,
              "OFF",
              session); // unblock for deploy
          // System.out.println("***After write to register");//for thread
          // "+Thread.currentThread().getName());
          // CLID = readFromRegister(key, session);//unblock for deploy
          // System.out.println("****rlist size:="+ rList.size());
          // if(rList.size()>0)
          // if(CLID!=null)
          // {
          // CLID = scheduler.schedule(rList).split(":")[0];
          // STATUS = scheduler.schedule(rList).split(":")[1];

          while (readFromRegister(key, session) != null
              && readFromRegister(key, session).contains(":")
              && readFromRegister(key, session).split(":")[1].equalsIgnoreCase("OFF")
              && !clId.equalsIgnoreCase(
                  readFromRegister(key, session)
                      .split(":")[0])) // || !STATUS.equalsIgnoreCase("OFF"))
          {
            // System.out.println("***Client " + clId +"Waiting for the lock to the column "+key);//
            // for thread "+Thread.currentThread().getName());
            // System.out.println("***Waiting for the lock to the column "+key);// for thread
            // "+Thread.currentThread().getName());
          }
          scheduler.requestLock(session, key, clId, index); // unblock for deploy
          // System.out.println("***After requesting the lock to the columnfor the query index"+
          // index);
          statement = updateConsistencyLevel(statement, cLevel, index, tuple);
          result = session.execute(statement); // unblock for deploy
          // System.out.println("***After executing the query index"+ index);
          scheduler.releaseLock(session, key, clId, index); // unblock for deploy
          if (tuple.getCausalQueue().peek() != null) {
            q = tuple.getCausalQueue().remove();
            scheduler.removeregistry(session, key, clId, index); // unblock for deploy
          }
          // System.out.println("***After release lock and registry cleanup for the query index"+
          // index);
          // }
        } else {

        }
      }
    } else {
      // System.out.println("In eventual guarantee case:"+mutator);
      statement = updateConsistencyLevel(statement, cLevel, index, tuple);
      // System.out.println("***111 Executing eventual consistent queries statement:="+statement);
      // System.out.println("***222 Executing eventual consistent queries tuple
      // session:="+tuple.getSession());
      result = session.execute(statement); // unblock for deploy
      // if(causalQueue.peek()!=null)
      // q = causalQueue.remove();
    }
    return result;
  }