Package org.deuce.transaction

Examples of org.deuce.transaction.Context


  }
 

  public boolean find(Integer value) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    boolean result = false;
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(3);
      try {
        result = find(value, context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here


    }
  }
 
  public int sum() throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    int result = 0;
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(3);
      try {
        result = sum(context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here

      }
    }
  }
  public static long totalBalance(String accountNum1, String accountNum2) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    long result = 0;
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(3);
      try {
        result = totalBalance(accountNum1, accountNum2, context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
 
View Full Code Here

      edu.vt.rt.hyflow.benchmark.Benchmark.processingDelay();
    }
  }
  public static long totalBalance(String accountNum1, String accountNum2, Timespec deadline, Timespec period_ts, int tid) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    boolean aborted = false;
    boolean earlierTxPresent = false;
    long result = 0;
    Timespec current = new Timespec();
   
    for (int i = 0; i < 0x7fffffff; i++) { 
      DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.NOT_IN_COMMIT_PHASE);
      if(DTL2Directory.priorityRaised_ThreadMap.get(tid) == DTL2Directory.PRIORITY_RAISED) {
        DTL2Directory.priorityRaised_ThreadMap.put(tid, DTL2Directory.PRIORITY_NOT_RAISED);
        ChronosScheduler.reset_self_deadline_priority(deadline);
      }
      context.init(3);
      try {
        result = totalBalance(accountNum1, accountNum2, context, deadline, period_ts, tid);
      } catch (TransactionException ex) {
        commit = false;
        aborted = true;
        //ex.printStackTrace();
      } catch (InterruptedException ex) {
        commit = false;
        Logger.fetal("Int-Ex recvd in Bank.Tfr " + tid);
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.IN_COMMIT_PHASE);
        if (context.commit(deadline, period_ts, tid)) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        } else {
          //  wait for signal to retry   
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else {
          context.rollback();
          //System.out.print("*-" + tid);
        }
        commit = true;
      }
     
View Full Code Here

      }
    }
  }
  public static void transfer(String accountNum1, String accountNum2, int amount) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
   
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(4);
      try {
        transfer(accountNum1, accountNum2, amount, context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else {
          context.rollback();
        }
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
View Full Code Here

//      edu.vt.rt.hyflow.benchmark.Benchmark.processingDelay();
    }
  }
  public Integer checkBalance() throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    int result = 0;
    for (int i = 0x7fffffff; i > 0; i--) {
      context.init(0);
      try {
        result = checkBalance(context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here

    }
    return result;
  }
  public static boolean transfer(String accountNum1, String accountNum2, int amount, Timespec deadline, Timespec period_ts, int thread_id) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    boolean aborted = false;
    boolean earlierTxPresent = false;
    Timespec current = new Timespec();
    Integer threadID = thread_id;   
   
    for (int i = 0; i < 0x7fffffff; i++) { 
      DTL2Directory.threadPhaseMap.put(thread_id, DTL2Directory.NOT_IN_COMMIT_PHASE);
      if(DTL2Directory.priorityRaised_ThreadMap.get(thread_id) == DTL2Directory.PRIORITY_RAISED) {
        DTL2Directory.priorityRaised_ThreadMap.put(thread_id, DTL2Directory.PRIORITY_NOT_RAISED);
        ChronosScheduler.reset_self_deadline_priority(deadline);
      }
      context.init(4);
      try {
        transfer(accountNum1, accountNum2, amount, context, deadline, period_ts, thread_id);
      } catch (TransactionException ex) {
        commit = false;
        earlierTxPresent = false;
        aborted = true;
        //ex.printStackTrace();
      } catch (InterruptedException ex) {
        commit = false;
        earlierTxPresent = true;
        Logger.fetal("Int-Ex recvd in Bank.Tfr " + thread_id);
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) { 
        if (context.commit(deadline, period_ts, thread_id)) {
          if (throwable != null) {
            throw throwable;
          } else {
            // Clear interrupt flag raised in commit stage
            Thread.interrupted();
            aborted = false;
            return true;
          }
        } else {
          // wait for signal to retry
          Logger.fetal("Failed to commit " + thread_id);
          aborted = true;
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else {
          //System.out.print("R-" + tid + " ");
          aborted = true;
          context.rollback();   
          if(earlierTxPresent) {
            //while(true) {
            DummyObject object = new DummyObject(threadID);

            synchronized(object) {
View Full Code Here

      }
    }
  }
  public static void borrow(String id, List accountNums, int amount) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(2);
      try {
        borrow(id, (List<String>)((LinkedList<String>)accountNums).clone(), amount, context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here

      }
    }
  }
  public static void sum(String id, List accountNums) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    for (int i = 0; i < 0x7fffffff; i++) {
      context.init(4);
      try {
        sum(id, (List<String>)((LinkedList<String>)accountNums).clone(), context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return;
          }
        }
      } else {
        if(context instanceof ControlContext)
          ControlContext.abort(((ControlContext)context).getContextId());
        else
          context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here

      }
    }
  }
  public static Object search(String keyword) throws Throwable{
    Throwable throwable = null;
    Context context = ContextDelegator.getInstance();
    boolean commit = true;
    Object result = null;
    for (int i = 0x7fffffff; i > 0; i--) {
      context.init(2);
      try {
        result = search(keyword, context);
      } catch (TransactionException ex) {
        commit = false;
      } catch (Throwable ex) {
        throwable = ex;
      }
      if (commit) {
        if (context.commit()) {
          if (throwable != null) {
            throw throwable;
          } else {
            return result;
          }
        }
      } else {
        context.rollback();
        commit = true;
      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
View Full Code Here

TOP

Related Classes of org.deuce.transaction.Context

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.