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

nfsv4: added destroy_clientid operation

parent 3a350c34
......@@ -133,6 +133,8 @@ public class MDSOperationFactory implements NFSv4OperationFactory {
return new OperationDESTROY_SESSION(op);
case nfs_opnum4.OP_SEQUENCE:
return new OperationSEQUENCE(op);
case nfs_opnum4.OP_DESTROY_CLIENTID:
return new OperationDESTROY_CLIENTID(op);
case nfs_opnum4.OP_RECLAIM_COMPLETE:
return new OperationRECLAIM_COMPLETE(op);
case nfs_opnum4.OP_ILLEGAL:
......
......@@ -189,6 +189,7 @@ public class NFSServerV41 extends nfs4_prot_NFS4_PROGRAM_ServerStub {
case nfs_opnum4.OP_CREATE_SESSION:
case nfs_opnum4.OP_EXCHANGE_ID:
case nfs_opnum4.OP_DESTROY_SESSION:
case nfs_opnum4.OP_DESTROY_CLIENTID:
break;
default:
throw new ChimeraNFSException(nfsstat4.NFS4ERR_OP_NOT_IN_SESSION, "not in session");
......
/*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Library General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
* details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program (see the file COPYING.LIB for more details); if not,
* write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
* 02139, USA.
*/
package org.dcache.chimera.nfs.v4;
import org.dcache.chimera.nfs.ChimeraNFSException;
import org.dcache.chimera.nfs.v4.xdr.*;
public class OperationDESTROY_CLIENTID extends AbstractNFSv4Operation {
public OperationDESTROY_CLIENTID(nfs_argop4 args) {
super(args, nfs_opnum4.OP_DESTROY_CLIENTID);
}
@Override
public nfs_resop4 process(CompoundContext context) {
DESTROY_CLIENTID4res res = new DESTROY_CLIENTID4res();
try {
Long clientId = Long.valueOf(_args.opdestroy_clientid.dca_clientid.value.value);
NFSv4StateHandler stateHandler = context.getStateHandler();
NFS4Client client = stateHandler.getClientByID(clientId);
stateHandler.removeClient(client);
res.dcr_status = nfsstat4.NFS4_OK;
} catch (ChimeraNFSException e) {
res.dcr_status = e.getStatus();
}
_result.opdestroy_clientid = res;
return _result;
}
}
/*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Library General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
* details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program (see the file COPYING.LIB for more details); if not,
* write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
* 02139, USA.
*/
package org.dcache.chimera.nfs.v4.client;
import org.dcache.chimera.nfs.v4.xdr.DESTROY_CLIENTID4args;
import org.dcache.chimera.nfs.v4.xdr.clientid4;
import org.dcache.chimera.nfs.v4.xdr.nfs_argop4;
import org.dcache.chimera.nfs.v4.xdr.nfs_opnum4;
public class DestroyClientidStub {
public static nfs_argop4 generate(clientid4 clientid) {
nfs_argop4 op = new nfs_argop4();
op.argop = nfs_opnum4.OP_DESTROY_CLIENTID;
op.opdestroy_clientid = new DESTROY_CLIENTID4args();
op.opdestroy_clientid.dca_clientid = clientid;
return op;
}
}
......@@ -318,6 +318,7 @@ public class Main {
if (nfsClient != null) {
nfsClient.destroy_session();
nfsClient.destroy_clientid();
}
timer.purge();
System.exit(0);
......@@ -435,6 +436,7 @@ public class Main {
public void umount() throws OncRpcException, IOException {
destroy_session();
destroy_clientid();
}
private void exchange_id() throws OncRpcException, IOException {
......@@ -509,6 +511,15 @@ public class Main {
ops.add(DestroySessionStub.standard(_sessionid));
@SuppressWarnings("unused")
COMPOUND4res compound4res = sendCompound(ops, "destroy_session");
}
private void destroy_clientid() throws OncRpcException, IOException {
List<nfs_argop4> ops = new LinkedList<nfs_argop4>();
ops.add(DestroyClientidStub.generate(_clientIdByServer));
@SuppressWarnings("unused")
COMPOUND4res compound4res = sendCompound(ops, "destroy_clientid");
_nfsClient.close();
}
......
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