Commit b0751208 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfsv41: refactor device manager

drop device manager factory
Make device manager part of request context

Acked-By: Gerd
parent 22f54d69
......@@ -30,6 +30,7 @@ public class CompoundContext {
private final RpcCall _callInfo;
private final UnixUser _user;
private final ExportFile _exportFile;
private final NFSv41DeviceManager _deviceManager;
/**
* Create context of COUMPOUND request.
......@@ -41,10 +42,11 @@ public class CompoundContext {
* @param exportFile list of servers exports.
*/
public CompoundContext(List<nfs_resop4> processedOps, int minorversion, FileSystemProvider fs,
RpcCall call, ExportFile exportFile) {
NFSv41DeviceManager deviceManager, RpcCall call, ExportFile exportFile) {
_processedOps = processedOps;
_minorversion = minorversion;
_fs = fs;
_deviceManager = deviceManager;
_callInfo = call;
_exportFile = exportFile;
_user = HimeraNFS4Utils.remoteUser(_callInfo, _exportFile);
......@@ -61,6 +63,10 @@ public class CompoundContext {
return _fs;
}
public NFSv41DeviceManager getDeviceManager() {
return _deviceManager;
}
/**
* Get NFSv4 minor version number. The version number os provided by client
* for each coumpound.
......
......@@ -27,12 +27,13 @@ public class NFSServerV41 extends nfs4_prot_NFS4_PROGRAM_ServerStub {
private final ExportFile _exportFile;
private static final Logger _log = Logger.getLogger(NFSServerV41.class.getName());
private final NFSv4OperationFactory _operationFactory;
private final NFSv41DeviceManager _deviceManager;
public NFSServerV41(NFSv4OperationFactory operationFactory,
NFSv41DeviceManager deviceManager, FileSystemProvider fs,
ExportFile exportFile) throws OncRpcException, IOException {
NFSv41DeviceManagerFactory.setDeviceManager(deviceManager);
_deviceManager = deviceManager;
_fs = fs;
_exportFile = exportFile;
_operationFactory = operationFactory;
......@@ -61,7 +62,7 @@ public class NFSServerV41 extends nfs4_prot_NFS4_PROGRAM_ServerStub {
}
CompoundContext context = new CompoundContext(v, arg1.minorversion.value,
_fs, call$, _exportFile);
_fs, _deviceManager, call$, _exportFile);
for (nfs_argop4 op : arg1.argarray) {
......
package org.dcache.chimera.nfs.v4;
public class NFSv41DeviceManagerFactory {
private final static NFSv41DeviceManager DEFAULT_MANAGER = new DeviceManager();
private static NFSv41DeviceManager _MANAGER = DEFAULT_MANAGER;
private NFSv41DeviceManagerFactory() {
// no instance allowed
}
public static void setDeviceManager(NFSv41DeviceManager deviceManager) {
_MANAGER = deviceManager;
}
public static NFSv41DeviceManager getDeviceManager() {
return _MANAGER;
}
}
......@@ -41,7 +41,7 @@ public class OperationGETDEVICEINFO extends AbstractNFSv4Operation {
res.gdir_resok4 = new GETDEVICEINFO4resok();
NFS4IoDevice device = NFSv41DeviceManagerFactory.getDeviceManager()
NFS4IoDevice device = context.getDeviceManager()
.getIoDevice(deviceId);
if (device == null) {
......
......@@ -71,9 +71,9 @@ public class OperationGETDEVICELIST extends AbstractNFSv4Operation {
device_addr4 deviceAddr = DeviceManager.deviceAddrOf( addresses );
NFS4IoDevice newDevice = new NFS4IoDevice(mdsID , deviceAddr);
NFSv41DeviceManagerFactory.getDeviceManager().addIoDevice(newDevice, layoutiomode4.LAYOUTIOMODE4_ANY);
context.getDeviceManager().addIoDevice(newDevice, layoutiomode4.LAYOUTIOMODE4_ANY);
List<NFS4IoDevice> deviceList = NFSv41DeviceManagerFactory.getDeviceManager().getIoDeviceList();
List<NFS4IoDevice> deviceList = context.getDeviceManager().getIoDeviceList();
int deviceListSize = deviceList.size();
if (deviceListSize > _args.opgetdevicelist.gdla_maxdevices.value.value) {
......
......@@ -92,7 +92,7 @@ public class OperationLAYOUTGET extends AbstractNFSv4Operation {
NFS4IoDevice ioDevice = null;
if (context.currentInode().type() == FsInodeType.INODE ) {
ioDevice = NFSv41DeviceManagerFactory.getDeviceManager().getIoDevice(
ioDevice = context.getDeviceManager().getIoDevice(
context.currentInode(),
_args.oplayoutget.loga_iomode,
context.getRpcCall().getTransport().getRemoteSocketAddress().getAddress(),
......@@ -105,7 +105,7 @@ public class OperationLAYOUTGET extends AbstractNFSv4Operation {
device_addr4 deviceAddr = DeviceManager.deviceAddrOf( addresses );
ioDevice = new NFS4IoDevice(MSD_ID, deviceAddr);
NFSv41DeviceManagerFactory.getDeviceManager().
context.getDeviceManager().
addIoDevice(ioDevice, layoutiomode4.LAYOUTIOMODE4_ANY);
}
......
......@@ -33,7 +33,7 @@ public class OperationLAYOUTRETURN extends AbstractNFSv4Operation {
if( _args.oplayoutreturn.lora_layoutreturn.lr_returntype == layoutreturn_type4.LAYOUTRETURN4_FILE) {
NFSv41DeviceManagerFactory.getDeviceManager().
context.getDeviceManager().
releaseDevice(_args.oplayoutreturn.lora_layoutreturn.lr_layout.lrf_stateid);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment