Package edu.vt.rt.hyflow.benchmark.tm.bank

Examples of edu.vt.rt.hyflow.benchmark.tm.bank.BankAccount


   
    System.out.println("Creating Local Objects");
    // Local accounts
    for(int i=1; i<args.length; i++)
      if(args[i].startsWith(args[0]))
        new BankAccount(args[i]).deposit(50);
   
    System.out.println("Sleeping to objects populated");
    Thread.sleep(5000);

    // Making money transfer
    final String luckyAccount = args[nodeId+1]// pick one of the accounts
    for(int i=nodeId+2; i<args.length; i++){
      final int index = i;
      if(!args[i].equals(luckyAccount))
        new Thread(){
          public void run() {
          System.out.println("Transaction<" + args[index] + "," + luckyAccount + ">:");
          try {
            BankAccount.transfer(args[index], luckyAccount, 10);
          } catch (Throwable e) {
            e.printStackTrace();
          }
//          transaction.cleanup();
        }
      }.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


    HyFlow.start(5);
    System.out.println("Sleeping");
    Thread.sleep(1000);
   
    //   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

    Thread.sleep(1000);
   
    //   Local accounts
    for(int i=1; i<args.length; i++)
      if(args[i].startsWith(args[0]))
        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

TOP

Related Classes of edu.vt.rt.hyflow.benchmark.tm.bank.BankAccount

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.