Package org.deuce.transaction

Examples of org.deuce.transaction.TransactionException


            pending = true;
          }
          try{ wait(); } catch (InterruptedException e) {};
          if(schedulingList.remove(context)){
          //  Logger.info("(Schedule 1) Remotely aborting: " + context);
            throw new TransactionException();
          }
        }
        //if(!context.status.equals(STATUS.ABORTED))
        readers.add(context);
        //else throw new TransactionException();
        break;
        case WRITE_MODE:
      // Get exclusive access.
      while (writer!=null || !readers.isEmpty() || ! writeValid) {
         if(writeValid){
          if(writer!=null){
            Logger.debug("Client Side: Write Mode resolve");
            int res = HyFlow.getConflictManager().resolve(context, writer);
            if(res==0)
              writer = null;
             
          }
          if(!readers.isEmpty()){
            int res = HyFlow.getConflictManager().resolve(context, readers);
            if(res==0) readers.clear();
          }
          continue;
         }
        // Ask for object if absent.
        if (! writeValid && ! pending) {
          RetrieveRequest retrieve = new RetrieveRequest(context, key, mode);
          if (DEBUG)
            Aleph.debug(this + " sends " + retrieve + " to " + key.getHome());
          pendingContext = context;
          retrieve.send(key.getHome());
          pending = true;
        }
        try{ wait(); } catch (InterruptedException e) {};
        //Logger.info("open abortedPending "+abortedPending.size());
        if(schedulingList.remove(context)){
      //    Logger.info("(Schedule 2) Remotely aborting: " + context);
          throw new TransactionException();
        }
      }
      if(!context.status.equals(STATUS.ABORTED))
        writer = context;
      //else throw new TransactionException();
View Full Code Here


 
  @Override
  public void beforeReadAccess(Object obj, long field) {
    // self-check validation
    if(isAborted())
      throw new TransactionException();
    // add to read-set
    if(obj instanceof AbstractLoggableObject){
      AbstractLoggableObject loggable = (AbstractLoggableObject)obj;
      Object[] metadata = registery.get(txnId);
      synchronized(metadata){
View Full Code Here

            if(LockTable.checkLock( obj, clock, false)<0){
              AbstractDistinguishable object = (AbstractDistinguishable)obj;
              try {
                GlobalObject key = ObjectsRegistery.getKey(object.getId());
                if(key==null// deleted object
                  throw new TransactionException();
                Logger.debug("READSET: Remote Validation for " + key);
                try {
              CommunicationManager.getManager().send(key.getHome(), new ValidateRequest(key, hashCode));
            } catch (IOException e) {
              e.printStackTrace();
              throw new TransactionException();
            }
            Logger.debug("READSET: Wait Remote " + key + " Validation ...");
            wait();
            if(clock<(remoteValidateResult & LockTable.UNLOCK)){
              Logger.debug("READSET: Remote Validation failed, remote version:" + (remoteValidateResult & LockTable.UNLOCK));
              throw new TransactionException();
            }
            Logger.debug("READSET: Remote Validation " + key + " successeded.");
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
View Full Code Here

            if(LockTable.checkLock( obj, clock, false)<0){
              AbstractDistinguishable object = (AbstractDistinguishable)obj;
              try {
                GlobalObject key = ObjectsRegistery.getKey(object.getId());
                if(key==null// deleted object
                  throw new TransactionException();
                Logger.fetal("READSET: Remote Validation for " + key);
                try {
              CommunicationManager.getManager().send(key.getHome(), new ValidateRequest(key, hashCode));
            } catch (IOException e) {
              e.printStackTrace();
              throw new TransactionException();
            }
            Logger.fetal("READSET: Wait Remote " + key + " Validation ...");
            wait();
            if(clock<(remoteValidateResult & LockTable.UNLOCK)){
              Logger.fetal("READSET: Remote Validation failed, remote version:" + (remoteValidateResult & LockTable.UNLOCK));
              throw new TransactionException();
            }
            Logger.fetal("READSET: Remote Validation " + key + " succeeded.");
          } catch (InterruptedException e) {
            //System.out.println("Interrupted Exception in wait method at Readset.checklock");
            throw new TransactionException();
          }
            }
          }
    } finally{
      if(clear)
View Full Code Here

      try {
        throw new Exception();
      } catch (Exception e) {
        for (StackTraceElement trace : e.getStackTrace()) {
          if(trace.getClassName().equals(ClientSide.class.getName()))
            throw new TransactionException();
        }
      }
    }

    try{
View Full Code Here

 
  // ----------------------- Read Fields ------------------------ //
  @Override
  public void beforeReadAccess(Object obj, long field) {
    if(status.equals(STATUS.ABORTED))
      throw new TransactionException();
    if(obj instanceof AbstractLoggableObject){
      AbstractLoggableObject loggable = (AbstractLoggableObject)obj;
      if(!loggable.__isFree(getContextId()))
        throw new TransactionException()// contention  R/W
    }
  }
View Full Code Here

 
  public void beforeWriteAccess(Object obj, long field) {
    // TODO: OPEN OBJECT FOR WRITE
   
    if(status.equals(STATUS.ABORTED))
      throw new TransactionException();
   
    if(obj instanceof AbstractLoggableObject){
      AbstractLoggableObject loggable = (AbstractLoggableObject)obj;
      while(!loggable.__own(this)){  // try to set me as the owner
        int res = HyFlow.getConflictManager().resolve(this, loggable.__getOwner());
View Full Code Here

       
        if(!LockTable.lock(obj, locksMarker)){
          LockTable.remoteLockRequest(this, key, owner);
          if(!pendingLock){
            Logger.debug("Remote lock refused");
            throw new TransactionException();
          }
          Logger.debug("Remote lock granted");
        }
        ++lockedCounter;
      }
View Full Code Here

  }

  private WriteObjectAccess onReadAccess0( Object obj, long field){
    if(status.equals(STATUS.ABORTED)){
      System.out.println("Aborted transaction!!");
      throw new TransactionException();
    }
   
    // Check if it is already included in the write set
    System.out.println("check");
    return writeSet.contains( readSet.getCurrent() );
View Full Code Here

    return val==null ? value : val;
  }
 
  public void onWriteAccess( Object obj, Object value, long field){
    if(status.equals(STATUS.ABORTED))
      throw new TransactionException();

    WriteObjectAccess fieldAccess = writeSet.get(obj);
    fieldAccess.set(field, value);
  }
View Full Code Here

TOP

Related Classes of org.deuce.transaction.TransactionException

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.