Example #1
0
  private void rereadNameSpaceEntry(final PinTask task) throws CacheException {
    /* Ensure that task is still valid and stays valid for the
     * duration of the name space lookup.
     */
    refreshTimeout(task, getExpirationTimeForNameSpaceLookup());

    /* We allow the set of provided attributes to be incomplete
     * and thus add attributes required by pool manager.
     */
    Set<FileAttribute> attributes = EnumSet.noneOf(FileAttribute.class);
    attributes.addAll(task.getFileAttributes().getDefinedAttributes());
    attributes.addAll(PoolMgrSelectReadPoolMsg.getRequiredAttributes());

    _pnfsStub.send(
        new PnfsGetFileAttributes(task.getPnfsId(), attributes),
        PnfsGetFileAttributes.class,
        new AbstractMessageCallback<PnfsGetFileAttributes>() {
          @Override
          public void success(PnfsGetFileAttributes msg) {
            try {
              task.setFileAttributes(msg.getFileAttributes());

              /* Ensure that task is still valid
               * and stays valid for the duration
               * of the pool selection.
               */
              refreshTimeout(task, getExpirationTimeForPoolSelection());
              selectReadPool(task);
            } 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) {
            fail(task, rc, error.toString());
          }

          @Override
          public void noroute(CellPath path) {
            /* PnfsManager is unreachable. We
             * expect this to be a transient
             * problem and retry in a moment.
             */
            retry(task, RETRY_DELAY);
          }

          @Override
          public void timeout(CellPath path) {
            /* PnfsManager did not respond. We
             * expect this to be a transient
             * problem and retry in a moment.
             */
            retry(task, SMALL_DELAY);
          }
        });
  }
Example #2
0
  private void selectReadPool(final PinTask task) throws CacheException {
    try {
      PoolSelector poolSelector =
          _poolMonitor.getPoolSelector(task.getFileAttributes(), task.getProtocolInfo(), null);

      PoolInfo pool = poolSelector.selectPinPool();
      setPool(task, pool.getName());
      setStickyFlag(task, pool.getName(), pool.getAddress());
    } catch (FileNotOnlineCacheException e) {
      askPoolManager(task);
    }
  }
Example #3
0
 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;
 }
Example #4
0
  public MessageReply<PinManagerPinMessage> messageArrived(PinManagerPinMessage message)
      throws CacheException {
    MessageReply<PinManagerPinMessage> reply = new MessageReply<>();

    enforceLifetimeLimit(message);

    PinTask task = createTask(message, reply);
    if (task != null) {
      if (!task.getFileAttributes().isDefined(REQUIRED_ATTRIBUTES)) {
        rereadNameSpaceEntry(task);
      } else {
        selectReadPool(task);
      }
    }

    return reply;
  }
Example #5
0
  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);
          }
        });
  }