Package aleph.dir

Examples of aleph.dir.DirectoryManager.open()


  }

  @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


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

    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

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

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

  @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

  }
 
  @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

 
  @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

  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

    return balance;
  }
 
  public static void transfer(String accountNum1, String accountNum2, int amount){
    DirectoryManager locator = HyFlow.getLocator();
    _BankAccount account1 = (_BankAccount) locator.open(accountNum1);
    _BankAccount account2 = (_BankAccount) locator.open(accountNum2);
   
    for(int i=0; i<Benchmark.calls; i++)
      account1.withdraw(amount);
   
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.