@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()); } }
protected EnumSet<RequestContainerV5.RequestState> checkStaging(PinTask task) { try { Subject subject = task.getSubject(); StorageInfo info = task.getFileAttributes().getStorageInfo(); return _checkStagePermission.canPerformStaging(subject, info) ? RequestContainerV5.allStates : RequestContainerV5.allStatesExceptStage; } catch (PatternSyntaxException | IOException ex) { _log.error("Failed to check stage permission: " + ex); } return RequestContainerV5.allStatesExceptStage; }
private void askPoolManager(final PinTask task) { PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg( task.getFileAttributes(), task.getProtocolInfo(), task.getReadPoolSelectionContext(), checkStaging(task)); msg.setSubject(task.getSubject()); msg.setSkipCostUpdate(true); _poolManagerStub.send( msg, PoolMgrSelectReadPoolMsg.class, new AbstractMessageCallback<PoolMgrSelectReadPoolMsg>() { @Override public void success(PoolMgrSelectReadPoolMsg msg) { try { /* Pool manager expects us * to keep some state * between retries. */ task.setReadPoolSelectionContext(msg.getContext()); /* Store the pool name in * the DB so we know what to * clean up if something * fails. */ String poolName = msg.getPoolName(); CellAddressCore poolAddress = msg.getPoolAddress(); task.getFileAttributes().getLocations().add(poolName); setPool(task, poolName); setStickyFlag(task, poolName, poolAddress); } catch (CacheException e) { fail(task, e.getRc(), e.getMessage()); } catch (RuntimeException e) { fail(task, CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.toString()); } } @Override public void failure(int rc, Object error) { /* Pool manager expects us to * keep some state between * retries. */ task.setReadPoolSelectionContext(getReply().getContext()); switch (rc) { case CacheException.OUT_OF_DATE: /* Pool manager asked for a * refresh of the request. * Retry right away. */ retry(task, 0); break; case CacheException.FILE_NOT_IN_REPOSITORY: case CacheException.PERMISSION_DENIED: fail(task, rc, error.toString()); break; default: /* Ideally we would delegate the retry to the door, * but for the time being the retry is dealed with * by pin manager. */ retry(task, RETRY_DELAY); break; } } @Override public void noroute(CellPath path) { /* Pool manager is * unreachable. We expect this * to be transient and retry in * a moment. */ retry(task, RETRY_DELAY); } @Override public void timeout(CellPath path) { /* Pool manager did not * respond. We expect this to be * transient and retry in a * moment. */ retry(task, SMALL_DELAY); } }); }