Package aleph.dir

Examples of aleph.dir.DirectoryManager


   
    //   Local accounts
    BankAccount account = new BankAccount("5-123");
    account .deposit(50);

    DirectoryManager locator = HyFlow.getLocator();
   
    System.out.println("Acquire1");
    BankAccount account1 = (BankAccount)locator.open("5-123");
    System.out.println("Release1");
//    locator.release(account1);
   
    System.out.println("Acquire2");
    BankAccount account2 = (BankAccount)locator.open("5-123");
    System.out.println("Release2");
    locator.release(account1);
   
    System.out.println("Complete Test");
    System.exit(0);
  }
View Full Code Here


        new BankAccount(args[i]).deposit(50);
   
    Thread.sleep(1000);
   
    // Remote accounts
    DirectoryManager locator = HyFlow.getLocator();
    for(int i=1; i<args.length; i++){
        BankAccount account = (BankAccount)locator.open(args[i]);
        if(account!=null){
          account.deposit(50);
          System.out.println(account.withdraw(10*Integer.parseInt(args[0])));
          locator.release(account);
        }
        else
          System.out.println("Account " + args[i] + " is not found!");
      }

    // Check results
    Thread.sleep(1000);
    for(int i=1; i<args.length; i++){
      BankAccount account = (BankAccount)HyFlow.getLocator().open(args[i], "r");
      System.out.println(account.checkBalance());
      locator.release(account);
    }
   
    System.out.println("Complete Test");
  }
View Full Code Here

    new _Node(HEAD, -1)// create the head node
  }

  @Atomic
  public void add(Integer value){
    DirectoryManager locator = HyFlow.getLocator();
    _Node head = (_Node)locator.open(HEAD);
    String oldNext = head.getNext();
    String newNodeId =  Network.getInstance().getID() + "-" + Math.random()// generate random id
    _Node newNode = new _Node(newNodeId, value);
    newNode.setNext(oldNext);
    head.setNext(newNodeId);
View Full Code Here

    head.setNext(newNodeId);
  }

  @Atomic
  public boolean delete(Integer value){
    DirectoryManager locator = HyFlow.getLocator();
    String next = HEAD;
    String prev = null;
    do// find the last node
      _Node node = (_Node)locator.open(next, "r");
      if(value.equals(node.getValue())){
        _Node deletedNode = (_Node)locator.open(next)//reopen for write to be deleted
        _Node prevNode = (_Node)locator.open(prev);    //open previous node for write
        prevNode.setNext(deletedNode.getNext());
        locator.delete(deletedNode);
        System.out.println("<" + node.getId() + "> " + node.getValue() + "  DELETED....");
        return true;
      }
      prev = next;
      next = node.getNext();
View Full Code Here

  }

  @Atomic
  private long sumAssests(int node){
    long balance = 0;
    DirectoryManager locator = HyFlow.getLocator();
    for(int i=0; i<localObjectsCount; i++){
      for(int j=0;j<node;j++){
        if(i%node==j){
          try {
            balance+=((LoanAccount) locator.open(j + "-" + i,"r")).checkBalance();
          } catch (Throwable e) {
            e.printStackTrace();
         
        }
      }
View Full Code Here

  public void delete(AbstractDistinguishable deleted) {
    lazyDelete.add(deleted);
  }
 
  protected void commitCreational(){
    DirectoryManager manager = HyFlow.getLocator();
   
    Logger.debug("Publish newly created objects");
    for(AbstractDistinguishable object : lazyPublish)
      manager.register(object); // populate me as this object owner

    Logger.debug("Unregister deleted objects");
    for(AbstractDistinguishable object : lazyDelete){
      manager.unregister(object); // unregister this object
    }
  }
View Full Code Here

        if(acquiredObjects.isEmpty()){
          Logger.debug(txnId + ": Empty Writeset.");
          return true;
        }
        Logger.debug("Backoff acquired objects :" + acquiredObjects.size());
        DirectoryManager locator = HyFlow.getLocator();
        for(AbstractDistinguishable distinguishable:acquiredObjects){
          if(incrementVersion)
            ((AbstractLoggableObject)distinguishable).__incVersion();
          ((AbstractLoggableObject)distinguishable).__release();
          locator.release(distinguishable);
          Logger.debug("Release :" + distinguishable.getId());
        }
      } finally {
        if(clear){
          Logger.debug(txnId + ": Remove from registery");
View Full Code Here

    return false;
  }

  @Atomic
  public boolean find(Integer value){
    DirectoryManager locator = HyFlow.getLocator();
    String next = HEAD;
    do// find the last node
      _Node node = (_Node)locator.open(next, "r");
      if(value.equals(node.getValue())){
        System.out.println("Found!");
        return true;
      }
      next = node.getNext();
View Full Code Here

    return amount;
  }
 
  @Atomic
  public static long totalBalance(String accountNum1, String accountNum2){
    DirectoryManager locator = HyFlow.getLocator();
    _BankAccount account1 = (_BankAccount) locator.open(accountNum1);
    _BankAccount account2 = (_BankAccount) locator.open(accountNum2);
   
    long balance = 0;
    for(int i=0; i<Benchmark.calls; i++)
      balance += account1.checkBalance();
   
View Full Code Here

    return false;
  }
 
  @Atomic
  public int sum(){
    DirectoryManager locator = HyFlow.getLocator();
    String next = HEAD;
    int sum = 1// to avoid -1 value of head sentential node
    do// find the last node
      _Node node = (_Node)locator.open(next, "r");
      next = node.getNext();
      sum += node.getValue();
    }while(next!=null);
    return sum;
  }
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.