Esempio n. 1
0
 /**
  * Load the pin belonging to the PinTask.
  *
  * @throw CacheException if the pin no longer exists or is no longer in PINNING.
  */
 protected Pin loadPinBelongingTo(PinTask task) throws CacheException {
   Pin pin = _dao.getPin(task.getPinId(), task.getSticky(), PINNING);
   if (pin == null) {
     throw new CacheException("Operation was aborted");
   }
   return pin;
 }
Esempio n. 2
0
  @Transactional
  protected PinTask createTask(
      PinManagerPinMessage message, MessageReply<PinManagerPinMessage> reply) {
    PnfsId pnfsId = message.getFileAttributes().getPnfsId();

    if (message.getRequestId() != null) {
      Pin pin = _dao.getPin(pnfsId, message.getRequestId());
      if (pin != null) {
        /* In this case the request is a resubmission. If the
         * previous pin completed then use it. Otherwise abort the
         * previous pin and create a new one.
         */
        if (pin.getState() == PINNED) {
          message.setPin(pin);
          reply.reply(message);
          return null;
        }

        pin.setState(UNPINNING);
        pin.setRequestId(null);
        _dao.storePin(pin);
      }
    }

    Pin pin = new Pin(message.getSubject(), pnfsId);
    pin.setRequestId(message.getRequestId());
    pin.setSticky("PinManager-" + UUID.randomUUID().toString());
    pin.setExpirationTime(getExpirationTimeForPoolSelection());

    return new PinTask(message, reply, _dao.storePin(pin));
  }