Package aleph.dir

Examples of aleph.dir.DirectoryManager


 
 
  public static long totalBalance(String accountNum1, String accountNum2, Context context, Timespec deadline, Timespec period_ts, int tid) throws InterruptedException{
    try{
     
      DirectoryManager locator = HyFlow.getLocator();
      BankAccount account1 = (BankAccount) locator.open(accountNum1, "r", deadline, period_ts, tid);
      ContextDelegator.beforeReadAccess(account1, 0, context);
      BankAccount account2 = (BankAccount) locator.open(accountNum2, "r", deadline, period_ts, tid);
     
      long balance = 0;
      for(int i=0; i<Benchmark.calls; i++)
        balance += account1.checkBalance(context);
     
View Full Code Here


  }
 
  public void borrow(List<String> accountNums, int branching, boolean initiator, int amount) {
    if(!initiator)
      withdraw(amount)// provide the loan request
    DirectoryManager locator = HyFlow.getLocator();
    accountNums = (List<String>)((LinkedList<String>)accountNums).clone();
    for(int i=0; i<branching && !accountNums.isEmpty(); i++){
      LoanAccount account = (LoanAccount) locator.open(accountNums.remove(0), "w");
      boolean last = (i==branching-1 || accountNums.isEmpty())// is the last one?
      int loan = last ? amount : (int)(Math.random()*amount);    // randomly have a loan amount from neighbor 
      account.borrow(accountNums, branching, false, loan);    // borrow from others
      deposit(loan)// add the loaned amount to my money
      amount -= loan;
View Full Code Here

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

      }
    }

    if(!initiator)
      withdraw(amount, __transactionContext__)// provide the loan request
    DirectoryManager locator = HyFlow.getLocator();
    accountNums = (List<String>)((LinkedList<String>)accountNums).clone();
    for(int i=0; i<branching && !accountNums.isEmpty(); i++){
      LoanAccount account = (LoanAccount) locator.open((AbstractContext)__transactionContext__, accountNums.remove(0), "w");
      boolean last = (i==branching-1 || accountNums.isEmpty())// is the last one?
      int loan = last ? amount : (int)(Math.random()*amount);    // randomly have a loan amount from neighbor 
      account.borrow(accountNums, branching, false, loan, __transactionContext__);    // borrow from others
      deposit(loan, __transactionContext__)// add the loaned amount to my money
      amount -= loan;
View Full Code Here

    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }
   
  public static void transfer(String accountNum1, String accountNum2, int amount, Context context){
    try{
      DirectoryManager locator = HyFlow.getLocator();
      BankAccount account1 = (BankAccount) locator.open(accountNum1);
      ContextDelegator.beforeReadAccess(account1, 0, context);
      BankAccount account2 = (BankAccount) locator.open(accountNum2);
     
      for(int i=0; i<Benchmark.calls; i++)
        account1.withdraw(amount, context);
     
      try {
View Full Code Here

    }
    throw new TransactionException("Failed to commit the transaction in the defined retries.");
  }

  public int sum(List<String> accountNums, int branching) throws Throwable {
    DirectoryManager locator = HyFlow.getLocator();
    int sum = checkBalance();
    accountNums = (List<String>)((LinkedList<String>)accountNums).clone();
    for(int i=0; i<branching && !accountNums.isEmpty(); i++){
      LoanAccount account = (LoanAccount) locator.open(accountNums.remove(0), "r");
      sum += account.sum(accountNums, branching);
    }
    return sum;
  }
View Full Code Here

      } catch (RemoteException e) {
        e.printStackTrace();
      }
    }
   
    DirectoryManager locator = HyFlow.getLocator();
    int sum = checkBalance(__transactionContext__);
    accountNums = (List<String>)((LinkedList<String>)accountNums).clone();
    for(int i=0; i<branching && !accountNums.isEmpty(); i++){
      LoanAccount account = (LoanAccount) locator.open((AbstractContext)__transactionContext__, accountNums.remove(0), "r");
      sum += account.sum(accountNums, branching, __transactionContext__);
    }
    return sum;
  }
View Full Code Here

  public static boolean wakeupWaitingTaskonAbort(String accountNum1, String accountNum2, Context context, Timespec deadline, Timespec period_ts, int tid) {
    boolean result = false;

    try {
      Logger.fetal("Freeing resources " + accountNum1 + " " + accountNum2);
      DirectoryManager locator = HyFlow.getLocator();
      locator.wakeupWaitingTask(accountNum1, deadline, period_ts, tid);
      locator.wakeupWaitingTask(accountNum2, deadline, period_ts, tid);
    } catch(TransactionException e){
      System.out.println("Transaction Exception in Bank.wakeupWaitingTasksonAbort " + tid);
      //e.printStackTrace();
      throw e;
    } catch (Throwable e) {
View Full Code Here

 
  public static boolean transfer(String accountNum1, String accountNum2, int amount, Context context, Timespec deadline, Timespec period_ts, int tid) throws InterruptedException{
    boolean result = false;
    try{
     
      DirectoryManager locator = HyFlow.getLocator();
      BankAccount account1 = (BankAccount) locator.open(accountNum1, "w", deadline, period_ts, tid);
      ContextDelegator.beforeReadAccess(account1, 0, context);
      BankAccount account2 = (BankAccount) locator.open(accountNum2, "w", deadline, period_ts, tid);

      for(int i=0; i<Benchmark.calls; i++)
        account1.withdraw(amount, context);
     
      try {
View Full Code Here

  @Remote
  public void borrow(List<String> accountNums, int branching, boolean initiator, int amount) {
    if(!initiator)
      withdraw(amount)// provide the loan request
    DirectoryManager locator = HyFlow.getLocator();
    accountNums = (List<String>)((LinkedList<String>)accountNums).clone();
    for(int i=0; i<branching && !accountNums.isEmpty(); i++){
      LoanAccount account = (LoanAccount) locator.open(accountNums.remove(0), "w");
      boolean last = (i==branching-1 || accountNums.isEmpty())// is the last one?
      int loan = last ? amount : (int)(Math.random()*amount);    // randomly have a loan amount from neighbor 
      account.borrow(accountNums, branching, false, loan);    // borrow from others
      deposit(loan)// add the loaned amount to my money
      amount -= loan;
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.