Package aleph.dir

Examples of aleph.dir.DirectoryManager


    new IDContainer<ImmutableList<E>>(containerID);
  }

  @Atomic
  private ImmutableList<E> getHead() {
    DirectoryManager locator = HyFlow.getLocator();
    IDContainer<ImmutableList<E>> container = (IDContainer<ImmutableList<E>>) locator.open(containerID, "r");
    return container.getItem();
  }
View Full Code Here


   * @see edu.vt.rt.datastructures.lang.DistributedSet#remove(java.io.Serializable)
   */
  @Atomic
  @Override
  public boolean remove(E value) {
    DirectoryManager locator = HyFlow.getLocator();
    IDContainer<ImmutableList<E>> container = (IDContainer<ImmutableList<E>>) locator.open(containerID, "r");
    final ImmutableList<E> list = container.getItem();
    if (list == null) {  //List is empty
      return false;
    }
    final ImmutableList<E> newList = list.remove(value);
    if (newList == list) {
      return false;
    }
    container = (IDContainer<ImmutableList<E>>) locator.open(containerID, "w");
    container.setItem(newList);
    return true;
  }
View Full Code Here

   * @see edu.vt.rt.datastructures.lang.DistributedSet#add(java.io.Serializable)
   */
  @Atomic
  @Override
  public boolean add(E value) {
    DirectoryManager locator = HyFlow.getLocator();
    List<E> list = (List<E>) locator.open(listID, "w");
    return list.add(value);
  }
View Full Code Here

   * @see edu.vt.rt.datastructures.lang.DistributedSet#contains(java.io.Serializable)
   */
  @Atomic
  @Override
  public boolean contains(E value) {
    DirectoryManager locator = HyFlow.getLocator();
    List<E> list = (List<E>) locator.open(listID, "r");
    return list.contains(value);
  }
View Full Code Here

   * @see edu.vt.rt.datastructures.lang.DistributedSet#remove(java.io.Serializable)
   */
  @Atomic
  @Override
  public boolean remove(E value) {
    DirectoryManager locator = HyFlow.getLocator();
    List<E> list = (List<E>) locator.open(listID, "w");
    return list.remove(value);
  }
View Full Code Here

    } catch (InterruptedException e) {
      e.printStackTrace();
    }
   
    long balance = 0;
    DirectoryManager locator = HyFlow.getLocator();
    int node = Network.getInstance().nodesCount();
    for(int i=0; i<localObjectsCount; i++){
      for(int j=0;j<node;j++){
        if(i%node==j){
          balance+=((BankAccount) locator.open(j + "-" + i,"r")).checkBalance()
        }
      }
    }
    if(balance==localObjectsCount*amount)
      Logger.debug("Passed sanity check");
View Full Code Here

    String[] minIds = new String[3];
    Reservation[] reservIds = new Reservation[3];
    boolean isFound = false;
    Reservation[] reservations = new Reservation[objId.length];
    Customer customer = null;
    DirectoryManager locator = HyFlow.getLocator();
    while(true){
      int i=0;
      try {
        for(; i<objId.length; i++)
          try {
            reservations[i] = (Reservation)locator.open(objId[i]);
          } catch (NotRegisteredKeyException e) {
          }
         
        try {
          customer = (Customer)locator.open(customerId);
        } catch (NotRegisteredKeyException e) {
        }
       
        break;
      }catch (TimeoutException e) {
        for(int j=0; j<i; j++){
          if(reservations[j]!=null)
            locator.release(reservations[j]);
        }
      }
    }
    try {
     
      for(int i=0; i<Benchmark.queryPerTransaction; i++){
        int price = Integer.MAX_VALUE;
        Reservation car = (Reservation)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){
          customer = new Customer(customerId);
          Logger.info(">>>>>>>>>>Customer added..." + customerId);
        }
       
        for(int i=0; i<minPrice.length; i++)
          if(minPrice[i]!=Integer.MAX_VALUE){
            String reserveId = "-reserve-" + Math.random()// generate random id
            Reservation reservation = reservIds[i];
            if(reservation.reserve()){
              ReservationInfo reservationInfo = new ReservationInfo(reserveId, minIds[i], minPrice[i], i);
              customer.addReservation((String)reservationInfo.getId());
              Logger.info(">>>>>>>>>>Reservation done...");
            }
          }
      }

    } finally{
      for(int i=0; i<reservations.length; i++){
        Reservation reservation = (Reservation)reservations[i];
        if(reservation!=null)
          locator.release(reservation);
      }
      if(customer!=null)
        locator.release(customer);
    }
  }
View Full Code Here

  }


  public static void deleteCustomer(String customerId){
    Customer customer = null;
    DirectoryManager locator = HyFlow.getLocator();
    while(true)
      try{
        try {
          customer = (Customer)locator.open(customerId);
        } catch (NotRegisteredKeyException e) {
          return;
        }
       
        break;
      }catch (TimeoutException e) {
      }
     
    for(Iterator<String> itr=customer.getReservations().iterator(); itr.hasNext(); ){
      String reservationInfoId = itr.next();
     
      ReservationInfo reservationInfo;
      while(true)
        try{
          reservationInfo = (ReservationInfo)locator.open(reservationInfoId);
          break;
        }catch (TimeoutException e) {
        }
       
      if(reservationInfo==null)
        continue;
      String reservationId = reservationInfo.getReservedResource();
      while(true)
        try{
          Reservation reservation = (Reservation)locator.open(reservationId);
          if(reservation!=null){
            reservation.release();
            locator.release(reservation);
          }
          break;
        }catch (TimeoutException e) {
        }
      locator.delete(reservationInfo);
    }
   
    locator.delete(customer);
    Logger.info(">>>>>>>>>>Customer deleted..." + customerId);
    try {
      customer = (Customer)locator.open(customerId);
      System.out.println("How!!!!!!!!!!!!!!");
    } catch (NotRegisteredKeyException e) {
      return;
    }
  }
View Full Code Here

  }
 
 
  public static void updateOffers(boolean[] opType, String[] objId, int[] price){
    Reservation[] reservations = new Reservation[objId.length];
    DirectoryManager locator = HyFlow.getLocator();
    while(true){
      int i=0;
      try {
        for(; i<objId.length; i++)
          try {
            reservations[i] = (Reservation)locator.open(objId[i]);
          } catch (NotRegisteredKeyException e) {
          }
         
        break;
      }catch (TimeoutException e) {
        for(int j=0; j<i; j++){
          if(reservations[j]!=null)
            locator.release(reservations[j]);
        }
      }
    }
    try {
      for(int i=0; i<Benchmark.queryPerTransaction; i++){
        Reservation reservation = (Reservation)reservations[i];
        if(reservation==null){
          new Reservation(objId[i], price[i]);
          Logger.info(">>>>>>>>>>Add Item...");
          continue;
        }
        if(opType[i]){  // add/update
          Logger.info(">>>>>>>>>>Update Price...");
          reservation.setPrice(price[i]);
        }
        else{
          Logger.info(">>>>>>>>>>Retire Item...");
          reservation.retrieItem();
        }
      }
    } finally{
      for(int i=0; i<reservations.length; i++){
        Reservation reservation = (Reservation)reservations[i];
        if(reservation!=null)
          locator.release(reservation);
      }
    }
  }
View Full Code Here

        }
        if(acquiredObjects.isEmpty())
          return;
       
        Logger.debug("Backoff acquired objects ;" + acquiredObjects.size());
        DirectoryManager locator = HyFlow.getLocator();
        Logger.debug("Locator found");
        for(AbstractDistinguishable distinguishable:acquiredObjects){
          Logger.debug("Releasing " + distinguishable);
          locator.release(distinguishable);
          Logger.debug("Released " + distinguishable);
        }
        break;
      } catch (ConcurrentModificationException e) {
        Logger.debug("Conucrrent Exception !!");
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.