/** * 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; }
private void setStickyFlag( final PinTask task, final String poolName, CellAddressCore poolAddress) { /* The pin lifetime should be from the moment the file is * actually pinned. Due to staging and pool to pool transfers * this may be much later than when the pin was requested. */ Date pinExpiration = task.freezeExpirationTime(); /* To allow for some drift in clocks we add a safety margin to * the lifetime of the sticky bit. */ long poolExpiration = (pinExpiration == null) ? -1 : pinExpiration.getTime() + CLOCK_DRIFT_MARGIN; PoolSetStickyMessage msg = new PoolSetStickyMessage( poolName, task.getPnfsId(), true, task.getSticky(), poolExpiration); _poolStub.send( new CellPath(poolAddress), msg, PoolSetStickyMessage.class, new AbstractMessageCallback<PoolSetStickyMessage>() { @Override public void success(PoolSetStickyMessage msg) { try { setToPinned(task); task.success(); } 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) { switch (rc) { case CacheException.POOL_DISABLED: /* Pool manager had outdated * information about the pool. Give * it a chance to be updated and * then retry. */ retry(task, RETRY_DELAY); break; case CacheException.FILE_NOT_IN_REPOSITORY: /* Pnfs manager had stale location * information. The pool clears * this information as a result of * this error, so we retry in a * moment. */ retry(task, SMALL_DELAY); break; default: fail(task, rc, error.toString()); break; } } @Override public void noroute(CellPath path) { /* The pool must have gone down. Give * pool manager a moment to notice this * and then retry. */ retry(task, RETRY_DELAY); } @Override public void timeout(CellPath path) { /* No response from pool. Typically this is * because the pool is overloaded. */ fail(task, CacheException.TIMEOUT, "No reply from " + path); } }); }