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();
}
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);
}
}
Aggregations