Package aleph.dir

Examples of aleph.dir.DirectoryManager


    Logger.debug("Commit values to objects");
    for( WriteObjectAccess writeField : this.writeSet)
      writeField.put(); // commit value to field
     
    Logger.debug("Publish newly created objects");
    DirectoryManager manager = HyFlow.getLocator();
    for(AbstractDistinguishable object : lazyPublish)
      manager.register(object); // populate me as this object owner

    DirectoryManager locator = HyFlow.getLocator();
    Logger.debug("Unregister deleted objects");
    for(AbstractDistinguishable object : lazyDelete){
      locator.unregister(object); // unregister this object
    }

    Logger.debug("Release Write-Set");
    for(AbstractDistinguishable obj: writeSet){
      if(LockTable.setAndReleaseLock( obj, newClock, locksMarker)){  // is it remote
        AbstractDistinguishable object = (AbstractDistinguishable)obj;
        Object key = obj.getId();
        Logger.debug("I'm new owner of " + key);
        locator.register(object)// register at the directory manager
        Logger.debug("Registered as owner of " + key);
      }
    }
   
    Logger.debug("Commited ===================================");
View Full Code Here


     
    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

     
    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

    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
      }
    }
View Full Code Here

    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
  public void add(Integer value, Context __transactionContext__){
    try{
//      System.err.println("\nadd " + value);
      DirectoryManager locator = HyFlow.getLocator();
      String next = HEAD;
      String prev = null;
      boolean right = true;
      do
        Node node = (Node)locator.open(next, "s");
        if(value >= node.getValue(__transactionContext__)){
          prev = next;
          next = node.getRightChild(__transactionContext__);
          right = true;
        }else{
          prev = next;
          next = node.getLeftChild(__transactionContext__);
          right = false;
        }
      }while(next!=null);
     
      Node prevNode = (Node)locator.open(prev);    //open previous node for write
     
      String newNodeId =  Network.getInstance().getID() + "-" + Math.random()// generate random id
      new Node(newNodeId, value)// create the node
     
      if(right)
View Full Code Here

    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
  public boolean delete(Integer value, Context __transactionContext__){
    try{
//      System.err.println("\ndelete " + value);
      DirectoryManager locator = HyFlow.getLocator();
      String next = HEAD;
      String prev = null;
      boolean right = true;
      Node node;
      do{
        node = (Node)locator.open(next, "s");
        if(value > node.getValue(__transactionContext__)){
          prev = next;
          next = node.getRightChild(__transactionContext__);
          right = true;
        }else if(value < node.getValue(__transactionContext__)){
          prev = next;
          next = node.getLeftChild(__transactionContext__);
          right = false;
        }else{
          Node prevNode = (Node)locator.open(prev);    //open previous node for write
          Node deletedNode = (Node)locator.open(next)//reopen for write to be deleted
          String replacement;
          if(deletedNode.getLeftChild(__transactionContext__)==null){
  //          System.err.println("replace with right child");
            replacement = deletedNode.getRightChild(__transactionContext__);
          }else if(deletedNode.getRightChild(__transactionContext__)==null){
  //          System.err.println("replace with left child");
            replacement = deletedNode.getLeftChild(__transactionContext__);
          }else// get left most in right tree
  //          System.err.println("replace with left most in right tree");
            String next2 = deletedNode.getRightChild(__transactionContext__);
            Node currNode2 = null;
            Node prevNode2 = null;
            do{
              prevNode2 = currNode2;
              replacement = next2;
             
              currNode2 = (Node)locator.open(next2, "r");
              next2 = currNode2.getLeftChild(__transactionContext__);
            }while(next2!=null);
            if(prevNode2!=null){  // disconnect replacement node from its parent
              Node prevNode2w = (Node)locator.open(prevNode2.getId())//open previous node for write
              prevNode2w.setLeftChild(currNode2.getRightChild(__transactionContext__), __transactionContext__);
            }
            Node currNode2w = (Node)locator.open(replacement)//replace
            currNode2w.setLeftChild(node.getLeftChild(__transactionContext__), __transactionContext__);
            if(!replacement.equals(node.getRightChild(__transactionContext__)))
              currNode2w.setRightChild(node.getRightChild(__transactionContext__), __transactionContext__);
          }
          if(right)
            prevNode.setRightChild(replacement, __transactionContext__);
          else
            prevNode.setLeftChild(replacement, __transactionContext__);
          locator.delete(deletedNode);
          return true;
        }
      }while(next!=null);
  //    System.err.println("Nothing to Delete....");
      Node last = ((Node)locator.open(node.getId(), "r"))// reopen last node for read
      last.getValue(__transactionContext__)// force add to the readset
      Logger.debug("Nothing to Delete....");
      return false;
    } finally{
      try {
View Full Code Here

      }
    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
  public boolean find(Integer value, Context __transactionContext__){
    DirectoryManager locator = HyFlow.getLocator();
    String prev = null;
    Node node = null;
    try{
      String next = HEAD;
      do
        node = (Node)locator.open(next, "s");
        if(value > node.getValue(__transactionContext__)){
          prev = next;
          next = node.getRightChild(__transactionContext__);
        }else if(value < node.getValue(__transactionContext__)){
          prev = next;
          next = node.getLeftChild(__transactionContext__);
        }else{
//          System.out.println("FOUND!");
          return true;
        }
      }while(next!=null);
//      System.out.println("NOT FOUND!");
      return false;
    } finally{
      if(prev!=null){
        Node lastPrev = ((Node)locator.open(prev, "r"))// reopen last node for read
        lastPrev.getValue(__transactionContext__)// force add to the readset
      }
      if(node!=null){
        Node last = ((Node)locator.open(node.getId(), "r"))// reopen last node for read
        last.getValue(__transactionContext__)// force add to the readset
      }
      try {
        edu.vt.rt.hyflow.benchmark.Benchmark.processingDelay();
      } catch (InterruptedException e) {
View Full Code Here

    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
  public int sum(Context __transactionContext__){
    try{
      DirectoryManager locator = HyFlow.getLocator();
      return sum((Node)locator.open(HEAD), __transactionContext__) + 1;
    } finally{
      try {
        edu.vt.rt.hyflow.benchmark.Benchmark.processingDelay();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
View Full Code Here

    }
  }
 
  private int sum(Node node, Context __transactionContext__){
    int sum = node.getValue(__transactionContext__);
    DirectoryManager locator = HyFlow.getLocator();
    if(node.getLeftChild(__transactionContext__)!=null)
      sum += sum((Node)locator.open(node.getLeftChild(__transactionContext__)), __transactionContext__);
    if(node.getRightChild(__transactionContext__)!=null)
      sum += sum((Node)locator.open(node.getRightChild(__transactionContext__)), __transactionContext__);
    return sum;
  }
View Full Code Here

      }.start();
    }
    Thread.sleep(10000);

    // View final output
    DirectoryManager locator = HyFlow.getLocator();
    if(nodeId==1){ // just one node view output
      System.out.println("Sleep till transactions complete");
      Thread.sleep(10000);
      for(int i=1; i<args.length; i++){
       
        BankAccount account = (BankAccount)locator.open(args[i], "r");
        System.out.println(account.checkBalance());
        locator.release(account);

        BankAccount account2 = (BankAccount)locator.open(args[i], "r");
        System.out.println(account2.checkBalance());
        locator.release(account2);
      }
    }
   
    System.out.println("Test complete");
  }
View Full Code Here

TOP

Related Classes of aleph.dir.DirectoryManager

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.