Search in sources :

Example 1 with GssSessionManager

use of org.dcache.oncrpc4j.rpc.gss.GssSessionManager in project dcache by dCache.

the class NFSv41Door method init.

public void init() throws Exception {
    _chimeraVfs = new ChimeraVfs(_fileFileSystemProvider, _idMapper);
    _vfsCache = new VfsCache(_chimeraVfs, _vfsCacheConfig);
    _vfs = _eventNotifier == null ? _vfsCache : wrapWithMonitoring(_vfsCache);
    OncRpcSvcBuilder oncRpcSvcBuilder = new OncRpcSvcBuilder().withPort(_port).withTCP().withAutoPublish().withWorkerThreadIoStrategy();
    if (_enableRpcsecGss) {
        oncRpcSvcBuilder.withGssSessionManager(new GssSessionManager(_idMapper));
    }
    for (String version : _versions) {
        switch(version) {
            case V3:
                MountServer ms = new MountServer(_exportFile, _vfs);
                NfsServerV3 nfs3 = new NfsServerV3(_exportFile, _vfs);
                oncRpcSvcBuilder.withRpcService(new OncRpcProgram(nfs3_prot.NFS_PROGRAM, nfs3_prot.NFS_V3), nfs3).withRpcService(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), ms);
                ;
                _loginBrokerPublisher.setTags(Collections.emptyList());
                break;
            case V41:
                final NFSv41DeviceManager _dm = this;
                _proxyIoFactory = new NfsProxyIoFactory(_dm);
                _executor = new StatsDecoratedOperationExecutor(new DoorOperationFactory(_proxyIoFactory, _chimeraVfs, _fileFileSystemProvider, _manageGids ? Optional.of(_idMapper) : Optional.empty(), _accessLogMode));
                int stateHandlerId = getOrCreateId(ZK_DOORS_PATH, getCellName() + "@" + getCellDomainName(), "state-handler-id");
                NFSv4StateHandler stateHandler = new NFSv4StateHandler(NFSv4Defaults.NFS4_LEASE_TIME, stateHandlerId, _clientStore);
                _nfs4 = new NFSServerV41.Builder().withStateHandler(stateHandler).withDeviceManager(_dm).withExportTable(_exportFile).withVfs(_vfs).withOperationExecutor(_executor).build();
                oncRpcSvcBuilder.withRpcService(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), _nfs4);
                updateLbPaths();
                break;
            default:
                throw new IllegalArgumentException("Unsupported NFS version: " + version);
        }
    }
    // Supported layout drivers
    _supportedDrivers = new EnumMap<>(layouttype4.class);
    _supportedDrivers.put(layouttype4.LAYOUT4_FLEX_FILES, new FlexFileLayoutDriver(4, 1, flex_files_prot.FF_FLAGS_NO_IO_THRU_MDS, ByteUnit.MiB.toBytes(1), new utf8str_mixed("17"), new utf8str_mixed("17"), this::logLayoutErrors));
    _supportedDrivers.put(layouttype4.LAYOUT4_NFSV4_1_FILES, new NfsV41FileLayoutDriver());
    _rpcService = oncRpcSvcBuilder.build();
    _rpcService.start();
}
Also used : NFSv41DeviceManager(org.dcache.nfs.v4.NFSv41DeviceManager) org.dcache.nfs.v4.xdr.layouttype4(org.dcache.nfs.v4.xdr.layouttype4) OncRpcSvcBuilder(org.dcache.oncrpc4j.rpc.OncRpcSvcBuilder) NfsProxyIoFactory(org.dcache.chimera.nfsv41.door.proxy.NfsProxyIoFactory) VfsCache(org.dcache.nfs.vfs.VfsCache) NfsServerV3(org.dcache.nfs.v3.NfsServerV3) NfsV41FileLayoutDriver(org.dcache.nfs.v4.NfsV41FileLayoutDriver) OncRpcProgram(org.dcache.oncrpc4j.rpc.OncRpcProgram) StatsDecoratedOperationExecutor(org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor) NFSServerV41(org.dcache.nfs.v4.NFSServerV41) org.dcache.nfs.v4.xdr.utf8str_mixed(org.dcache.nfs.v4.xdr.utf8str_mixed) NFSv4StateHandler(org.dcache.nfs.v4.NFSv4StateHandler) GssSessionManager(org.dcache.oncrpc4j.rpc.gss.GssSessionManager) FlexFileLayoutDriver(org.dcache.nfs.v4.FlexFileLayoutDriver) MountServer(org.dcache.nfs.v3.MountServer)

Example 2 with GssSessionManager

use of org.dcache.oncrpc4j.rpc.gss.GssSessionManager in project dcache by dCache.

the class NfsTransferService method tryToStartRpcService.

private void tryToStartRpcService() throws GSSException, IOException {
    PortRange portRange;
    int minTcpPort = _minTcpPort;
    int maxTcpPort = _maxTcpPort;
    try {
        List<String> lines = Files.readAllLines(_tcpPortFile.toPath(), StandardCharsets.US_ASCII);
        if (!lines.isEmpty()) {
            String line = lines.get(0);
            int savedPort = Integer.parseInt(line);
            if (savedPort >= _minTcpPort && savedPort <= _maxTcpPort) {
                /*
                     *if saved port with in the range, then restrict range to a single port
                     * to enforce it.
                     */
                minTcpPort = savedPort;
                maxTcpPort = savedPort;
            }
        }
    } catch (NumberFormatException e) {
        // garbage in the file.
        _log.warn("Invalid content in the port file {} : {}", _tcpPortFile, e.getMessage());
    } catch (NoSuchFileException e) {
    }
    boolean bound = false;
    int retry = 3;
    BindException bindException = null;
    do {
        retry--;
        portRange = new PortRange(minTcpPort, maxTcpPort);
        try {
            OncRpcSvcBuilder oncRpcSvcBuilder = new OncRpcSvcBuilder().withMinPort(portRange.getLower()).withMaxPort(portRange.getUpper()).withTCP().withoutAutoPublish();
            _log.debug("Using {} IO strategy", _ioStrategy);
            if (_ioStrategy == IoStrategy.SAME_THREAD) {
                oncRpcSvcBuilder.withSameThreadIoStrategy();
            } else {
                oncRpcSvcBuilder.withWorkerThreadIoStrategy();
            }
            if (_withGss) {
                RpcLoginService rpcLoginService = (t, gss) -> Subjects.NOBODY;
                GssSessionManager gss = new GssSessionManager(rpcLoginService);
                oncRpcSvcBuilder.withGssSessionManager(gss);
            }
            _rpcService = oncRpcSvcBuilder.build();
            _rpcService.start();
            bound = true;
        } catch (BindException e) {
            bindException = e;
            minTcpPort = _minTcpPort;
            maxTcpPort = _maxTcpPort;
        }
    } while (!bound && retry > 0);
    if (!bound) {
        throw new BindException("Can't bind to a port within the rage: " + portRange + " : " + bindException);
    }
    int localPort = _rpcService.getInetSocketAddress(IpProtocolType.TCP).getPort();
    // if we had a port range, then store selected port for the next time.
    if (minTcpPort != maxTcpPort) {
        byte[] outputBytes = Integer.toString(localPort).getBytes(StandardCharsets.US_ASCII);
        Files.write(_tcpPortFile.toPath(), outputBytes);
    }
}
Also used : OperationDESTROY_CLIENTID(org.dcache.nfs.v4.OperationDESTROY_CLIENTID) NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) GssSessionManager(org.dcache.oncrpc4j.rpc.gss.GssSessionManager) Subjects(org.dcache.auth.Subjects) LoggerFactory(org.slf4j.LoggerFactory) NFS4Client(org.dcache.nfs.v4.NFS4Client) DoorValidateMoverMessage(org.dcache.vehicles.DoorValidateMoverMessage) DiskErrorCacheException(diskCacheV111.util.DiskErrorCacheException) AbstractNFSv4Operation(org.dcache.nfs.v4.AbstractNFSv4Operation) Command(dmg.util.command.Command) InetAddress(java.net.InetAddress) BadHandleException(org.dcache.nfs.status.BadHandleException) PnfsHandler(diskCacheV111.util.PnfsHandler) NFSv41Session(org.dcache.nfs.v4.NFSv41Session) Duration(java.time.Duration) Map(java.util.Map) OperationPUTROOTFH(org.dcache.nfs.v4.OperationPUTROOTFH) org.dcache.nfs.v4.xdr.stateid4(org.dcache.nfs.v4.xdr.stateid4) IpProtocolType(org.dcache.oncrpc4j.rpc.net.IpProtocolType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) StandardOpenOption(java.nio.file.StandardOpenOption) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PortRange(org.dcache.util.PortRange) OperationEXCHANGE_ID(org.dcache.nfs.v4.OperationEXCHANGE_ID) GSSException(org.ietf.jgss.GSSException) CellCommandListener(dmg.cells.nucleus.CellCommandListener) Instant(java.time.Instant) AbstractOperationExecutor(org.dcache.nfs.v4.AbstractOperationExecutor) InetSocketAddress(java.net.InetSocketAddress) Sets(com.google.common.collect.Sets) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) IoStrategy(org.dcache.oncrpc4j.rpc.IoStrategy) Mover(org.dcache.pool.movers.Mover) List(java.util.List) CompoundContext(org.dcache.nfs.v4.CompoundContext) OperationSEQUENCE(org.dcache.nfs.v4.OperationSEQUENCE) org.dcache.nfs.v4.xdr.nfs_opnum4(org.dcache.nfs.v4.xdr.nfs_opnum4) OperationRECLAIM_COMPLETE(org.dcache.nfs.v4.OperationRECLAIM_COMPLETE) NetworkUtils(org.dcache.util.NetworkUtils) CellPath(dmg.cells.nucleus.CellPath) OperationBIND_CONN_TO_SESSION(org.dcache.nfs.v4.OperationBIND_CONN_TO_SESSION) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) TransferService(org.dcache.pool.classic.TransferService) CellAddressCore(dmg.cells.nucleus.CellAddressCore) OperationILLEGAL(org.dcache.nfs.v4.OperationILLEGAL) Callable(java.util.concurrent.Callable) BindException(java.net.BindException) BadStateidException(org.dcache.nfs.status.BadStateidException) OncRpcException(org.dcache.oncrpc4j.rpc.OncRpcException) InterruptedIOException(java.io.InterruptedIOException) CacheException(diskCacheV111.util.CacheException) CellStub(org.dcache.cells.CellStub) ChimeraNFSException(org.dcache.nfs.ChimeraNFSException) OperationCREATE_SESSION(org.dcache.nfs.v4.OperationCREATE_SESSION) MoverFactory(org.dcache.pool.movers.MoverFactory) CellIdentityAware(dmg.cells.nucleus.CellIdentityAware) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OperationDESTROY_SESSION(org.dcache.nfs.v4.OperationDESTROY_SESSION) OncRpcSvcBuilder(org.dcache.oncrpc4j.rpc.OncRpcSvcBuilder) Repository(org.dcache.pool.repository.Repository) Logger(org.slf4j.Logger) PoolIoFileMessage(diskCacheV111.vehicles.PoolIoFileMessage) Files(java.nio.file.Files) OpenOption(java.nio.file.OpenOption) StatsDecoratedOperationExecutor(org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor) PoolPassiveIoFileMessage(diskCacheV111.vehicles.PoolPassiveIoFileMessage) CompletionHandler(java.nio.channels.CompletionHandler) OperationGETATTR(org.dcache.nfs.v4.OperationGETATTR) RequestExecutionTimeGauges(org.dcache.commons.stats.RequestExecutionTimeGauges) IOException(java.io.IOException) Cancellable(org.dcache.pool.classic.Cancellable) File(java.io.File) OncRpcProgram(org.dcache.oncrpc4j.rpc.OncRpcProgram) TimeUnit(java.util.concurrent.TimeUnit) org.dcache.nfs.v4.xdr.nfs4_prot(org.dcache.nfs.v4.xdr.nfs4_prot) PostTransferService(org.dcache.pool.classic.PostTransferService) OncRpcSvc(org.dcache.oncrpc4j.rpc.OncRpcSvc) Option(dmg.util.command.Option) OperationPUTFH(org.dcache.nfs.v4.OperationPUTFH) org.dcache.nfs.v4.xdr.nfs_argop4(org.dcache.nfs.v4.xdr.nfs_argop4) ReplicaDescriptor(org.dcache.pool.repository.ReplicaDescriptor) Required(org.springframework.beans.factory.annotation.Required) RpcLoginService(org.dcache.oncrpc4j.rpc.RpcLoginService) NFSServerV41(org.dcache.nfs.v4.NFSServerV41) OncRpcSvcBuilder(org.dcache.oncrpc4j.rpc.OncRpcSvcBuilder) NoSuchFileException(java.nio.file.NoSuchFileException) BindException(java.net.BindException) RpcLoginService(org.dcache.oncrpc4j.rpc.RpcLoginService) PortRange(org.dcache.util.PortRange) GssSessionManager(org.dcache.oncrpc4j.rpc.gss.GssSessionManager)

Aggregations

Sets (com.google.common.collect.Sets)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 CacheException (diskCacheV111.util.CacheException)1 DiskErrorCacheException (diskCacheV111.util.DiskErrorCacheException)1 PnfsHandler (diskCacheV111.util.PnfsHandler)1 PoolIoFileMessage (diskCacheV111.vehicles.PoolIoFileMessage)1 PoolPassiveIoFileMessage (diskCacheV111.vehicles.PoolPassiveIoFileMessage)1 CellAddressCore (dmg.cells.nucleus.CellAddressCore)1 CellCommandListener (dmg.cells.nucleus.CellCommandListener)1 CellIdentityAware (dmg.cells.nucleus.CellIdentityAware)1 CellInfoProvider (dmg.cells.nucleus.CellInfoProvider)1 CellPath (dmg.cells.nucleus.CellPath)1 Command (dmg.util.command.Command)1 Option (dmg.util.command.Option)1 File (java.io.File)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 BindException (java.net.BindException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1