Exemplo n.º 1
0
 @Override
 public synchronized void getInfo(PrintWriter pw) {
   try {
     pw.println("  Interface  : " + getInterface());
   } catch (UnknownHostException e) {
     pw.println("  Interface  : " + e.getMessage());
   }
   pw.println("  Max Active : " + _maxActive);
   pw.println("Pnfs Timeout : " + _pnfs.getTimeout() + " " + _pnfs.getTimeoutUnit());
 }
Exemplo n.º 2
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);
          }
        });
  }
Exemplo n.º 3
0
 @Override
 public synchronized void printSetup(PrintWriter pw) {
   pw.println("#\n#  Pool to Pool (P2P)\n#");
   pw.println("pp set max active " + _maxActive);
   pw.println("pp set pnfs timeout " + (_pnfs.getTimeoutInMillis() / 1000L));
   if (_interface != null) {
     pw.println("pp interface " + _interface.getHostAddress());
   }
 }
Exemplo n.º 4
0
  @Override
  public synchronized void afterStart() {
    CellStub.addCallback(
        poolManagerStub.send(
            new PoolManagerGetPoolMonitor(), CellEndpoint.SendFlag.RETRY_ON_NO_ROUTE_TO_CELL),
        new AbstractMessageCallback<PoolManagerGetPoolMonitor>() {
          @Override
          public void success(PoolManagerGetPoolMonitor message) {
            messageArrived(message.getPoolMonitor());
          }

          @Override
          public void timeout(String message) {
            afterStart();
          }

          @Override
          public void failure(int rc, Object error) {}
        },
        MoreExecutors.directExecutor());
  }
Exemplo n.º 5
0
  public boolean isPinned(FileAttributes fileAttributes, CellStub cellStub)
      throws CacheException, InterruptedException, URISyntaxException {
    boolean isPinned = false;

    PinManagerCountPinsMessage message = new PinManagerCountPinsMessage(fileAttributes.getPnfsId());

    message = cellStub.sendAndWait(message);
    if (message.getCount() != 0) {
      isPinned = true;
    }
    return isPinned;
  }
 private void initPoolMonitor() throws InterruptedException {
   while (true) {
     try {
       setPoolMonitor(
           _poolManagerStub.sendAndWait(new PoolManagerGetPoolMonitor()).getPoolMonitor());
       break;
     } catch (CacheException e) {
       _log.error(e.toString());
       Thread.sleep(INIT_DELAY);
     }
   }
 }
 public static void releaseSpace(
     Subject subject,
     String spaceToken,
     Long spaceToReleaseInBytes,
     SrmReleaseSpaceCallback callback,
     CellStub spaceManagerStub,
     Executor executor) {
   LOGGER.trace(
       "SrmReleaseSpaceCompanion.releaseSpace({}, token {}, spaceToReleaseInBytes {})",
       subject.getPrincipals(),
       spaceToken,
       spaceToReleaseInBytes);
   try {
     long token = Long.parseLong(spaceToken);
     SrmReleaseSpaceCompanion companion = new SrmReleaseSpaceCompanion(callback);
     Release release = new Release(token, spaceToReleaseInBytes);
     release.setSubject(subject);
     CellStub.addCallback(spaceManagerStub.send(release), companion, executor);
   } catch (NumberFormatException e) {
     callback.invalidRequest("No such space");
   }
 }
Exemplo n.º 8
0
  public void init() throws Exception {

    _cellName = getCellName();
    _domainName = getCellDomainName();

    _rpcService = new OncRpcSvcBuilder().withPort(_port).withTCP().withAutoPublish().build();
    if (_enableRpcsecGss) {
      _rpcService.setGssSessionManager(new GssSessionManager(_idMapper));
    }

    _vfs = new VfsCache(new ChimeraVfs(_fileFileSystemProvider, _idMapper), _vfsCacheConfig);

    MountServer ms = new MountServer(_exportFile, _vfs);
    _rpcService.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), ms);
    _rpcService.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), ms);

    for (String version : _versions) {
      switch (version) {
        case V3:
          NfsServerV3 nfs3 = new NfsServerV3(_exportFile, _vfs);
          _rpcService.register(new OncRpcProgram(nfs3_prot.NFS_PROGRAM, nfs3_prot.NFS_V3), nfs3);
          break;
        case V41:
          final NFSv41DeviceManager _dm = this;
          _proxyIoFactory =
              new DcapProxyIoFactory(getCellAddress().getCellName() + "-dcap-proxy", "");
          _proxyIoFactory.setBillingStub(_billingStub);
          _proxyIoFactory.setFileSystemProvider(_fileFileSystemProvider);
          _proxyIoFactory.setPnfsHandler(_pnfsHandler);
          _proxyIoFactory.setPoolManager(_poolManagerStub.getDestinationPath());
          _proxyIoFactory.setIoQueue(_ioQueue);
          _proxyIoFactory.setRetryPolicy(RETRY_POLICY);
          _proxyIoFactory.startAdapter();
          _nfs4 =
              new NFSServerV41(
                  new ProxyIoMdsOpFactory(_proxyIoFactory, new MDSOperationFactory()),
                  _dm,
                  _vfs,
                  _idMapper,
                  _exportFile);
          _rpcService.register(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), _nfs4);
          _loginBrokerHandler.start();
          break;
        default:
          throw new IllegalArgumentException("Unsupported NFS version: " + version);
      }
    }

    _rpcService.start();
  }
Exemplo n.º 9
0
  /*
   * While pinning files this requestId value "qos" will be stored for the pin.
   * Storing requestId insures the possibility to filter files being pinned by Qos or SRM.
   */
  public void pin(FileAttributes fileAttributes, CellStub cellStub) throws URISyntaxException {

    HttpProtocolInfo protocolInfo =
        new HttpProtocolInfo(
            "Http",
            1,
            1,
            new InetSocketAddress(request.getRemoteHost(), 0),
            null,
            null,
            null,
            new URI("http", request.getRemoteHost(), null, null));

    PinManagerPinMessage message =
        new PinManagerPinMessage(fileAttributes, protocolInfo, requestId, -1);

    cellStub.notify(message);
  }
Exemplo n.º 10
0
 private synchronized PoolMonitor getPoolMonitor() {
   try {
     if (poolMonitor == null) {
       long deadline =
           addWithInfinity(System.currentTimeMillis(), poolManagerStub.getTimeoutInMillis());
       do {
         wait(subWithInfinity(deadline, System.currentTimeMillis()));
       } while (poolMonitor == null || deadline <= System.currentTimeMillis());
       if (poolMonitor == null) {
         throw new RemoteConnectFailureException(
             "Cached pool information is not yet available.", null);
       }
     }
     if (lastRefreshTime < System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(5)) {
       LOGGER.warn("Cached pool information is older than 5 minutes. Please check pool manager.");
     }
     return poolMonitor;
   } catch (InterruptedException e) {
     throw new RemoteProxyFailureException("Failed to fetch pool monitor: " + e.getMessage(), e);
   }
 }
Exemplo n.º 11
0
 public void refresh() throws CacheException, InterruptedException, NoRouteToCellException {
   messageArrived(poolManagerStub.sendAndWait(new PoolManagerGetPoolMonitor()).getPoolMonitor());
 }
Exemplo n.º 12
0
 private Date getExpirationTimeForSettingFlag() {
   long now = System.currentTimeMillis();
   long timeout = _poolStub.getTimeoutInMillis();
   return new Date(now + 2 * timeout);
 }
Exemplo n.º 13
0
 private Date getExpirationTimeForPoolSelection() {
   long now = System.currentTimeMillis();
   long timeout = _poolManagerStub.getTimeoutInMillis();
   return new Date(now + 2 * (timeout + RETRY_DELAY));
 }
Exemplo n.º 14
0
 private Date getExpirationTimeForNameSpaceLookup() {
   long now = System.currentTimeMillis();
   long timeout = _pnfsStub.getTimeoutInMillis();
   return new Date(now + 2 * (timeout + RETRY_DELAY));
 }
Exemplo n.º 15
0
  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);
          }
        });
  }
Exemplo n.º 16
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);
          }
        });
  }
Exemplo n.º 17
0
  public void unpin(FileAttributes fileAttributes, CellStub cellStub) {

    PinManagerUnpinMessage message = new PinManagerUnpinMessage(fileAttributes.getPnfsId());
    message.setRequestId(requestId);
    cellStub.notify(message);
  }
Exemplo n.º 18
0
 public synchronized String ac_pp_set_pnfs_timeout_$_1(Args args) {
   long timeout = Long.parseLong(args.argv(0));
   _pnfs.setTimeout(timeout);
   _pnfs.setTimeoutUnit(TimeUnit.SECONDS);
   return "Pnfs timeout set to " + timeout + " seconds";
 }