@Transactional protected void clearPin(PinTask task) { if (task.getPool() != null) { /* If the pin record expired or the pin was explicitly * unpinned, then the unpin processor may already have * submitted a request to the pool to clear the sticky * flag. Although out of order delivery of messages is * unlikely, if it would happen then we have a race * between the set sticky and clear sticky messages. To * cover this case we delete the old record and create a * fresh one in UNPINNING. */ _dao.deletePin(task.getPin()); Pin pin = new Pin(task.getSubject(), task.getPnfsId()); pin.setState(UNPINNING); _dao.storePin(pin); } else { /* We didn't create a sticky flag yet, so there is no * reason to keep the record. It will expire by itself, * but we delete the record now to avoid that we get * tickets from admins wondering why they have records * staying in PINNING. */ _dao.deletePin(task.getPin()); } }
@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)); }
@Transactional(isolation = REPEATABLE_READ) protected void setToPinned(PinTask task) throws CacheException { Pin pin = loadPinBelongingTo(task); pin.setExpirationTime(task.getExpirationTime()); pin.setState(PINNED); task.setPin(_dao.storePin(pin)); }
@Transactional(isolation = REPEATABLE_READ) protected void setPool(PinTask task, String pool) throws CacheException { Pin pin = loadPinBelongingTo(task); pin.setExpirationTime(getExpirationTimeForSettingFlag()); pin.setPool(pool); task.setPin(_dao.storePin(pin)); }
/** * 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; }
@Transactional(isolation = REPEATABLE_READ) protected void refreshTimeout(PinTask task, Date date) throws CacheException { Pin pin = loadPinBelongingTo(task); pin.setExpirationTime(date); task.setPin(_dao.storePin(pin)); }