Package aleph.comm.tcp

Examples of aleph.comm.tcp.Address


    int node = Network.getInstance().nodesCount();
    for(int i=0; i<localObjectsCount; i++){
      for(int j=0;j<node;j++){
        if(i%node==j){
          try {
            Address server1 = (Address) Network.getAddress(Benchmark.getServerId(j+"-"+i));
            account = (IBankAccount)LocateRegistry.getRegistry(server1.inetAddress.getHostAddress(), server1.port).lookup(j+"-"+i);
            account.lock();
            balance+=account.checkBalance();
            account.unlock();
           
View Full Code Here


 

  public static long getTotalBalance(String subAccountNum1, String subAccountNum2) {
    IBankAccount subAccount1 = null;
    IBankAccount subAccount2  = null;
    Address server1 = null, server2 = null;
    System.out.println("Object1 = " + subAccountNum1 + " Object2 = " + subAccountNum2);
   
    try {
      while(true){
        boolean locked1 = false;
View Full Code Here

  }
 
  public static boolean transfer(String subAccountNum1, String subAccountNum2, int amount) {
    IBankAccount account1 = null;
    IBankAccount account2 = null;
    Address server1 = null, server2 = null;
    char num1 = subAccountNum1.split("-")[1].charAt(0);
    char num2 = subAccountNum2.split("-")[1].charAt(0);
   
    System.out.println("Object1 = " + num1 + " Object2 = " + num2);
    if((int)num1 > (int)num2)
View Full Code Here

    int node = Network.getInstance().nodesCount();
    for(int i=0; i<localObjectsCount; i++){
      for(int j=0;j<node;j++){
        if(i%node==j){
          try {
            Address server1 = (Address) Network.getAddress(Benchmark.getServerId(j+"-"+i));
            account = (IBankAccount)LocateRegistry.getRegistry(server1.inetAddress.getHostAddress(), server1.port).lookup(j+"-"+i);
            account.rLock();
            balance+=account.checkBalance();
            account.rUnlock();
          } catch (RemoteException e) {
View Full Code Here

  }
 
  public static long getTotalBalance(String subAccountNum1, String subAccountNum2) {
    IBankAccount subAccount1 = null;
    IBankAccount subAccount2 = null;
    Address server1 = null, server2 = null;
    try {
      while(true){
        boolean locked1 = false;
        try {
          server1 = (Address) Network.getAddress(Benchmark.getServerId(subAccountNum1));
View Full Code Here

  }
 
  public static boolean transfer(String subAccountNum1, String subAccountNum2, int amount) {
    IBankAccount account1 = null;
    IBankAccount account2 = null;
    Address server1 = null, server2 = null;
    try {
      while(true){
        boolean locked1 = false;
        try {
          server1 = (Address) Network.getAddress(Benchmark.getServerId(subAccountNum1));
View Full Code Here

  }
  public static void borrow(Long txnId, String id, List accountNums, int amount){
    while(true){
      Logger.debug("Retry");
      ILoanAccount account = null;
      Address server = null;
      try {
        server = (Address) Network.getAddress(Benchmark.getServerId(id));
        account = (ILoanAccount)LocateRegistry.getRegistry(server.inetAddress.getHostAddress(), server.port).lookup(id);
        //lock
        Network.linkDelay(true, server);
View Full Code Here

  }
  public static void sum(Long txnId, String id, List accountNums){
    while(true){
      Logger.debug("Retry");
      ILoanAccount account = null;
      Address server = null;
      try {
        server = (Address) Network.getAddress(Benchmark.getServerId(id));
        account = (ILoanAccount)LocateRegistry.getRegistry(server.inetAddress.getHostAddress(), server.port).lookup(id);
        //lock
        Network.linkDelay(true, server);
View Full Code Here

    IReservation[] reservIds = new IReservation[3];
    boolean isFound = false;
    Object[] reservations = null;
    Address[] reservationsServers;
    ICustomer customer;
    Address customerServer;
   
    while(true){
      int i=0;
      try {
        Object[] data = open(objId);
        reservations = (Object[])data[0];
        reservationsServers = (Address[])data[1];
       
        data = open(customerId);
        customer = (data==null ? null : (ICustomer)((Object[])data[0])[0]);
        customerServer = (data==null ? null : ((Address[])data[1])[0]);
       
        for(; i<reservations.length; i++){
          IReservation reservation = (IReservation)reservations[i];
          if(reservation!=null)
            reservation.rLock();
        }
       
        if(customer!=null)
          customer.wLock();
       
        break;
      }catch (NoSuchObjectException e) {
        for(int j=0; j<i; j++){
          IReservation reservation = (IReservation)reservations[j];
          if(reservation!=null)
            reservation.rUnlock();
        }
        return;
      }catch (InterruptedException e) {
        for(int j=0; j<i; j++){
          IReservation reservation = (IReservation)reservations[j];
          if(reservation!=null)
            reservation.rUnlock();
        }
      }
    }
    try {
     
      for(int i=0; i<Benchmark.queryPerTransaction; i++){
        int price = Integer.MAX_VALUE;
        IReservation car = (IReservation)reservations[i];
        if(car==null)
          continue;
        if(car.isAvailable())
          price = car.getPrice();
        if(price < minPrice[objType[i]]){
          minPrice[objType[i]] = price;
          minIds[objType[i]] = objId[i];
          reservIds[objType[i]] = car;
          isFound = true;
        }
      }
 
      if(isFound){
        // create customer
        if(customer==null)
          try {
            Address address = (Address) Network.getAddress(Benchmark.getServerId(customerId));
            IVacation vacation = (IVacation)LocateRegistry.getRegistry(address.inetAddress.getHostAddress(), address.port).lookup("vacation");
            customer = vacation.createCustomer(customerId);
          } catch (RemoteException e1) {
            e1.printStackTrace();
          } catch (NotBoundException e) {
View Full Code Here

    Object[] data = null;
    while(true)
      try{
        data = open(customerId);
        customer = (data==null ? null : (ICustomer)((Object[])data[0])[0]);
        Address customerServer = (data==null ? null : ((Address[])data[1])[0]);
       
        if(customer==null)
          return;
       
        customer.wLock();
        break;
      }catch (NoSuchObjectException e) {
        return;
      }catch (InterruptedException e) {
      }
     
    data = open(customer.getReservations().toArray(new String[0]));
    Object[] reservationsInfo = (Object[])data[0];
    Address[] reservationsInfoServers = (Address[])data[1];

    for(int i=0; i<reservationsInfo.length; i++){
      IReservationInfo reservationInfo = (IReservationInfo)reservationsInfo[i];
      if(reservationInfo==null)
        continue;
      String reservationId = reservationInfo.getReservedResource();
      while(true)
        try{
          data = open(reservationId);
          IReservation reservation = (data==null ? null : (IReservation)((Object[])data[0])[0]);
          Address reservationServer = (data==null ? null : ((Address[])data[1])[0]);
          if(reservation!=null){
            reservation.wLock();
            reservation.release();
            reservation.wUnlock();
          }
View Full Code Here

TOP

Related Classes of aleph.comm.tcp.Address

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.