Examples of GlobalObject


Examples of aleph.GlobalObject

       
          for (AbstractDistinguishable obj: set.values()) {
            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 ...");
View Full Code Here

Examples of aleph.GlobalObject

        Logger.debug("Null local object!");
      else if(LockTable.isAvailable(object)){  // check if currently locked
        Logger.debug("Locked object");
        object = null;
      }else{
        GlobalObject globalObject = ObjectsRegistery.getKey(object.getId());
        if(globalObject==null){
          Logger.debug("Deleted object.");
          object = null;
        }else if(globalObject.getVersion()!=key.getVersion()){
          Logger.debug("Old GlobalObject was used to retreive object, retry later.");
          object = null;
        }
      }
      int lockVersion = object==null ? 0 : LockTable.getLockVersion(object);
View Full Code Here

Examples of aleph.GlobalObject

    {
      for(Object obj : writeSet){
        Logger.debug("Validating: " + ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()));
       
        if(!LockTable.lock(obj, locksMarker)){
          GlobalObject globalObject = ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId());
          if(globalObject==null// object was deleted
            throw new TransactionException();
          LockTable.remoteLockRequest(this, globalObject);
          if(!pendingLock){
            Logger.debug("Remote lock refused");
            throw new TransactionException();
          }
          Logger.debug("Remote lock granted");
        }
        ++lockedCounter;
      }
          Logger.debug("Validate Read-Set");
      readSet.checkClock( localClock, true);
    }
    catch(TransactionException exception){
      Logger.debug("Invalid Read-Set");
      for(AbstractDistinguishable obj : writeSet){
        if( lockedCounter-- == 0)
          break;
        Logger.debug("Releasing " + obj);
        if(!LockTable.unLock(obj, locksMarker))
          LockTable.remoteUnlockRequest(ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()));
      }
      return false;
    }

    final int newClock = LocalClock.increment();
    canBeAborted = false;
   
    Logger.debug("Commit values to objects");
    for( WriteObjectAccess writeField : this.writeSet)
      writeField.put(); // commit value to field
     
    Logger.debug("Publish newly created objects");
    for(AbstractDistinguishable object : lazyPublish)
      new GlobalObject(object, object.getId()); // populate me as this object owner

    DirectoryManager locator = HyFlow.getLocator();
    Logger.debug("Unregister deleted objects");
    for(AbstractDistinguishable object : lazyDelete){
      GlobalObject key = ObjectsRegistery.getKey(object.getId());
      locator.unregister(key); // unregister this object
      PE.thisPE().populate(new UnregisterObject(key))// unregister this object from other nodes
    }

    Logger.debug("Release Write-Set");
    for(AbstractDistinguishable obj: writeSet){
      if(LockTable.setAndReleaseLock( obj, newClock, locksMarker)){  // is it remote
        AbstractDistinguishable object = (AbstractDistinguishable)obj;
        GlobalObject key = ObjectsRegistery.getKey(object.getId());
        if(key==null){
          System.out.println("TTTTT:"+object.getId());
          continue;
        }
        Logger.debug("I'm new owner of " + key);
        key.setHome(PE.thisPE())// me is the new owner
        ObjectsRegistery.regsiterObject(key)// register key local
        locator.newObject(key, object)// register at the directory manager
        PE.thisPE().populate(new RegisterObject(key))// populate me as the new owner
        Logger.debug("Populate me owner of " + key);
        // FIXME: if more than one local transaction at this node then we should release the object now not before changing its location
View Full Code Here

Examples of aleph.GlobalObject

    {
      for(Object obj : writeSet){
        Logger.debug("Validating: " + ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()));
       
        if(!LockTable.lock(obj, locksMarker)){
          GlobalObject globalObject = ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId());
          if(globalObject==null// object was deleted
            throw new TransactionException();
          LockTable.remoteLockRequest(this, globalObject);
          if(!pendingLock){
            Logger.debug("Remote lock refused");
            throw new TransactionException();
          }
          Logger.debug("Remote lock granted");
        }
        ++lockedCounter;
      }
     
          Logger.debug("Validate Read-Set");
      readSet.checkClock( localClock, true);
    }
    catch(TransactionException exception){
      Logger.debug("Invalid Read-Set");
      for(AbstractDistinguishable obj : writeSet){
        if( lockedCounter-- == 0)
          break;
        Logger.debug("Releasing " + obj);
        if(!LockTable.unLock(obj, locksMarker))
          LockTable.remoteUnlockRequest(ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()));
      }
      return false;
    }

    final int newClock = LocalClock.increment();
    canBeAborted = false;
   
    Logger.debug("Commit values to objects");
    for( WriteObjectAccess writeField : this.writeSet)
      writeField.put(); // commit value to field
     
    Logger.debug("Publish newly created objects");
    for(AbstractDistinguishable object : lazyPublish) {
      new GlobalObject(object, object.getId()); // populate me as this object owner
    }
    DirectoryManager locator = HyFlow.getLocator();
    Logger.debug("Unregister deleted objects");
    for(AbstractDistinguishable object : lazyDelete){
      GlobalObject key = ObjectsRegistery.getKey(object.getId());
      locator.unregister(key); // unregister this object
      PE.thisPE().populate(new UnregisterObject(key))// unregister this object from other nodes
    }

    Logger.debug("Release Write-Set");
    for(AbstractDistinguishable obj: writeSet){
      if(LockTable.setAndReleaseLock( obj, newClock, locksMarker)){  // is it remote
        AbstractDistinguishable object = (AbstractDistinguishable)obj;
        GlobalObject key = ObjectsRegistery.getKey(object.getId());
        if(key==null){
          System.out.println("TTTTT:"+object.getId());
          continue;
        }
        Logger.debug("I'm new owner of " + key);
        key.setHome(PE.thisPE())// me is the new owner
        ObjectsRegistery.regsiterObject(key)// register key local
        locator.newObject(key, object)// register at the directory manager
        PE.thisPE().populate(new RegisterObject(key))// populate me as the new owner
        Logger.debug("Populate me owner of " + key);
        // FIXME: if more than one local transaction at this node then we should release the object now not before changing its location
View Full Code Here

Examples of aleph.GlobalObject

        wasInterrupted = false;
        Logger.debug("Validating: " + ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()));

        if(!LockTable.lock(obj, locksMarker, deadline_ts, tid)){
          Logger.fetal("Remote Obj for commit " + obj);
          GlobalObject globalObject = ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId());
          if(globalObject==null) {  // object was deleted
            throw new TransactionException();
          }
          Logger.debug("Lock request - Realtime Deadline = " + deadline_ts.getSeconds() + " " + deadline_ts.getNanoseconds());
          try {
            LockTable.remoteLockRequest(this, globalObject, deadline_ts, period_ts, tid);
          } catch (InterruptedException exception) {
            wasInterrupted = true;
          }
          if(!pendingLock){
            Logger.debug("Remote lock refused");
            throw new TransactionException();
          }
        }

        ++lockedCounter;
       
        // Check for expired deadline
        if(edu.vt.rt.hyflow.benchmark.Benchmark.getAbortHandler().wasAborted(ChronosUtil.gettid()))
          throw new TransactionException();
       
        if(wasInterrupted == true)
              throw new InterruptedException();
      }
          Logger.debug("Validate Read-Set");
          readSet.checkClock( localClock, true);

    }
    catch(TransactionException exception){
     
      DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.IN_COMMIT_PHASE);
      Logger.debug("Invalid Read-Set");
      for(AbstractDistinguishable obj : writeSet){
        if( lockedCounter-- == 0)
          break;
        Logger.fetal("Releasing " + obj);
        if(!LockTable.unLock(obj, locksMarker)) {
          LockTable.remoteUnlockRequest(ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()), deadline_ts, period_ts, tid);
        }
        Logger.fetal("Unlocked " + obj + " by thread = " + tid);
      }
     
      if(DTL2Directory.priorityRaised_ThreadMap.get(tid) == DTL2Directory.PRIORITY_RAISED) {
        Logger.fetal("Reset Priority === on Abort " + tid);
        DTL2Directory.priorityRaised_ThreadMap.put(tid, DTL2Directory.PRIORITY_NOT_RAISED);
        ChronosScheduler.reset_self_deadline_priority(deadline_ts);
      }     
      DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.NOT_IN_COMMIT_PHASE);
      return false;
    } catch (InterruptedException exception) {
      DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.IN_COMMIT_PHASE);
      Logger.debug("Invalid Read-Set");
      for(AbstractDistinguishable obj : writeSet){
        if( lockedCounter-- == 0)
          break;
        Logger.fetal("Releasing " + obj);
        if(!LockTable.unLock(obj, locksMarker)) {
          LockTable.remoteUnlockRequest(ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId()), deadline_ts, period_ts, tid);
        }
        Logger.fetal("Unlocked " + obj + " by thread = " + tid);
      }
     
      if(DTL2Directory.priorityRaised_ThreadMap.get(tid) == DTL2Directory.PRIORITY_RAISED) {
        Logger.fetal("Reset Priority === on Abort " + tid);
        DTL2Directory.priorityRaised_ThreadMap.put(tid, DTL2Directory.PRIORITY_NOT_RAISED);
        ChronosScheduler.reset_self_deadline_priority(deadline_ts);
      }     
      DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.NOT_IN_COMMIT_PHASE);
      return false;
    }
   
    Logger.debug("Now going to finish commit");
        DTL2Directory.threadPhaseMap.put(tid, DTL2Directory.IN_COMMIT_PHASE);

    ConcurrentHashMap<Object, Address> objPrevOwnerAddressMap = new ConcurrentHashMap<Object, Address>();

    // store object's previous owner address.. will be used to wakeup waiting Tx
    for(Object obj : writeSet){
        GlobalObject globalObject = ObjectsRegistery.getKey(((AbstractDistinguishable)obj).getId());
        if(globalObject!=null)
          objPrevOwnerAddressMap.put(obj, globalObject.getHome().getAddress());
    }
   
    final int newClock = LocalClock.increment();
    canBeAborted = false;
   
    Logger.debug("Commit values to objects");
    for( WriteObjectAccess writeField : this.writeSet)
      writeField.put(); // commit value to field
     
    Logger.debug("Publish newly created objects");
    for(AbstractDistinguishable object : lazyPublish) {
      new GlobalObject(object, object.getId()); // populate me as this object owner
      Logger.fetal("Populate me as Owner for " + object);
    }
    DirectoryManager locator = HyFlow.getLocator();
    Logger.debug("Unregister deleted objects");
    for(AbstractDistinguishable object : lazyDelete){
      GlobalObject key = ObjectsRegistery.getKey(object.getId());
      locator.unregister(key); // unregister this object
      PE.thisPE().populate(new UnregisterObject(key))// unregister this object from other nodes
      Logger.fetal("Unregister " + object);
    }

    Logger.debug("Release Write-Set");
    for(AbstractDistinguishable obj: writeSet){
      if(LockTable.setAndReleaseLock( obj, newClock, locksMarker)){  // is it remote
       
        AbstractDistinguishable object = (AbstractDistinguishable)obj;
        GlobalObject key = ObjectsRegistery.getKey(object.getId());
        if(key==null){
          System.out.println("TTTTT:"+object.getId());
          continue;
        }
       
        key.setHome(PE.thisPE())// me is the new owner
        ObjectsRegistery.regsiterObject(key)// register key local
        locator.newObject(key, object)// register at the directory manager
        PE.thisPE().populate(new RegisterObject(key))// populate me as the new owner
        Logger.debug("Populate me owner of " + key);
        // FIXME: if more than one local transaction at this node then we should release the object now not before changing its location
      }
    }

    //System.out.println(" Wake up other tasks " + tid);
    for(Object obj : objPrevOwnerAddressMap.keySet()) {
      //System.out.println("From my address " + PE.thisPE().getAddress() + " Send signal request to " + obj + " owner" + objPrevOwnerAddressMap.get(obj));

      if(!objPrevOwnerAddressMap.get(obj).equals(PE.thisPE().getAddress())) {
        //try {
          AbstractDistinguishable object = (AbstractDistinguishable)obj;
          GlobalObject key = ObjectsRegistery.getKey(object.getId());
          //CommunicationManager.getManager().send(objPrevOwnerAddressMap.get(obj), new SignalWaitingTxRequest(key, tid, obj, deadline_ts, period_ts));
          TransactionWaitQueue.remoteWaitQueueRequest(this, key, object);
        //} catch (IOException ex) {
        //  ex.printStackTrace();
        //}
View Full Code Here

Examples of aleph.GlobalObject

  public static void main(String[] args) {
    new PEGroup("hell");
   
  SharedCounter counter = new SharedCounter();
    GlobalObject object = new GlobalObject(counter);
    CounterThread thread = new CounterThread(object);

    Join join = new Join();

    int howMany = PE.numPEs();
    int iterations = 100;
    try {
      if ( args.length > 0)
        iterations = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
      System.err.println("usage: Counter <#iterations>");
      Aleph.exit(1);
    }

    System.out.println("Counter iterations: " + iterations);
    System.out.println("#PEs\ttime");
    for (int i = 0; i < PE.numPEs(); i++) {
      long duration = 0;
      for (int j = 0; j < iterations; j++) {
        Iterator e = PE.roundRobin();
        long start = System.currentTimeMillis();
        for (int k = 0; k <= i; k++)
          thread.start((PE) e.next(), join);
        join.waitFor();
        long stop = System.currentTimeMillis();
        duration += (stop - start);
      }
      System.out.println(Integer.toString(i+1) + "\t" +
       (double) duration / (double) iterations);
      System.out.flush()// impatient?
    }
   
    System.out.println(((SharedCounter)object.open("r")).value);
  }
View Full Code Here

Examples of aleph.GlobalObject

    }
  }

  public static void main(String[] args) {

    GlobalObject object = new GlobalObject(new SharedCounter());
    CounterThread thread = new CounterThread(object);

    Join join = new Join();

    int howMany = PE.numPEs();
    int iterations = 100;
    try {
      if ( args.length > 0)
        iterations = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
      System.err.println("usage: Counter2 <#iterations>");
      Aleph.exit(1);
    }

    System.out.println("Counter iterations: " + iterations);
    System.out.println("#PEs\ttime");
    long duration = 0;
    for (int j = 0; j < iterations; j++) {
      long start = System.currentTimeMillis();
      for (Iterator e = PE.allPEs(); e.hasNext(); )
        thread.start((PE) e.next(), join);
      join.waitFor();
      long stop = System.currentTimeMillis();
      duration += (stop - start);
    }
    System.out.println(howMany + "\t" + (double) duration / (double)
        iterations);
    try {
      SharedCounter shared = (SharedCounter) object.open("w");
      System.out.println("Final counter value: " + shared.value);
      object.release();
    } catch (AlephException e) {}
  }
View Full Code Here

Examples of aleph.GlobalObject

    GlobalObject[] gb = new GlobalObject[n];
    for(int i=0; i<n; i++) {
      c[i] = new Column();
      c[i]._id = i;
      c[i]._val = _L.getColumn(i);
      gb[i] = new GlobalObject(c[i]);
    }
   
    //construct a level array
    int maxlevel = 0;
    int[] level = new int[n];
View Full Code Here

Examples of aleph.GlobalObject

    GlobalObject[] gb = new GlobalObject[n];
    for(int i=0; i<n; i++) {
      c[i] = new Column();
      c[i]._id = i;
      c[i]._val = _L.getColumn(i);
      gb[i] = new GlobalObject(c[i]);
    }
   
    //factorizaton
    long start = System.currentTimeMillis();
    for(int k=0; k<n; k++) {
View Full Code Here

Examples of aleph.GlobalObject

  {
    double med;
    Tree t = new Tree();
    Join jv = new Join();
    PE me = PE.thisPE();
    GlobalObject gb;
    int leftN, rightN;
   
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.println("n:"+n+" dir:"+dir+" peNo:"+peNo+" numPE:"+numPE);
    if (n == 0) return null;
    gb = new GlobalObject(t);
   
    t = (Tree) gb.open("w");
    leftN = (n-1)/2;
    rightN = n-1-leftN;
    if (dir == 1) {
      dir = 0;
      med = median(minX, maxX, n);

      if (leftN == 0)
  t._left = null;
      else {
  if (me.equals(PE.getPE(peNo+numPE/2))) {  // Local PE
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.print("Left ");
    t._left = buildTree(leftN, dir, peNo+numPE/2, numPE/2, minX, med, minY, maxY);
  } else // Remote PE
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
    }
    Builder builder = new Builder(gb, leftN, dir, peNo+numPE/2, numPE/2,
          minX, med, minY, maxY);
    builder.start(PE.getPE(peNo+numPE/2), jv);
    jv.waitFor();
    t = (Tree) gb.open("w");
  }
      }
     
      if (rightN == 0)
  t._right = null;
      else {
  if (Aleph.verbosity(Constants.LOQUACIOUS))
    System.out.print("Right ");
  // Right subtree always in local PE
  t._right = buildTree(rightN, dir, peNo, numPE/2, med, maxX, minY, maxY);
      }

      t._x = med;
      t._y = uniform(minY, maxY);

    } else {
      dir = 1;
      med = median(minY, maxY, n);

      if (leftN == 0)
  t._left = null;
      else {
  if (me.equals(PE.getPE(peNo+numPE/2))) {  // Local PE
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.print("Left ");
    t._left = buildTree(leftN, dir, peNo+numPE/2, numPE/2, minX, maxX, minY, med);
  } else // Remote PE
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
    }
    Builder builder = new Builder(gb, leftN, dir, peNo+numPE/2, numPE/2,
          minX, maxX, minY, med);
    builder.start(PE.getPE(peNo+numPE/2), jv);
    jv.waitFor();
    t = (Tree) gb.open("w");
  }
      }

      if (rightN == 0)
  t._right = null;
      else {
  if (Aleph.verbosity(Constants.LOQUACIOUS))
    System.out.print("Right ");
  // Right subtree always in local PE
  t._right = buildTree(rightN, dir, peNo, numPE/2, minX, maxX, med, maxY);
      }

      t._y = med;
      t._x = uniform(minX, maxX);
    }

    t._size = n;
    t._next = null;
    t._prev = null;
    jv.waitFor();
   
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
    }
    return gb;
    //new GlobalObject(t);     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.