diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/stateid4.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/stateid4.java index c5dfd909b9b..f6fd916302e 100644 --- a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/stateid4.java +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/stateid4.java @@ -23,6 +23,7 @@ import java.io.Serializable; import java.util.Arrays; +@Deprecated(forRemoval = true) public class stateid4 implements Serializable { static final long serialVersionUID = -6677150504723505919L; diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/uint32_t.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/uint32_t.java index 97590396bd9..d666339bf2a 100644 --- a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/uint32_t.java +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfs/v4/xdr/uint32_t.java @@ -21,6 +21,7 @@ import java.io.Serializable; +@Deprecated(forRemoval = true) public class uint32_t implements Serializable { static final long serialVersionUID = -6603937444681096490L; diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/common/LegacyUtils.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/common/LegacyUtils.java new file mode 100644 index 00000000000..b831e00ca11 --- /dev/null +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/common/LegacyUtils.java @@ -0,0 +1,26 @@ +package org.dcache.chimera.nfsv41.common; + +import org.dcache.nfs.v4.xdr.stateid4; + +/** + * Utility class to support removal of legacy stateid class. + */ +@Deprecated(forRemoval = true) +public class LegacyUtils { + + private LegacyUtils() { + // no instance allowed + } + + public static stateid4 toStateid(Object stateObject) { + stateid4 stateid; + if (stateObject instanceof stateid4) { + stateid = (stateid4) stateObject; + } else { + org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid + = (org.dcache.chimera.nfs.v4.xdr.stateid4) stateObject; + stateid = new stateid4(legacyStateid.other, legacyStateid.seqid.value); + } + return stateid; + } +} diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/NFSv41Door.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/NFSv41Door.java index 789bfcc3835..3c7e9e11699 100644 --- a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/NFSv41Door.java +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/NFSv41Door.java @@ -89,6 +89,7 @@ import org.dcache.chimera.FsInode; import org.dcache.chimera.FsInodeType; import org.dcache.chimera.JdbcFs; +import org.dcache.chimera.nfsv41.common.LegacyUtils; import org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor; import org.dcache.chimera.nfsv41.door.proxy.NfsProxyIoFactory; import org.dcache.chimera.nfsv41.door.proxy.ProxyIoFactory; @@ -528,8 +529,7 @@ public void destroy() throws IOException { * and NFSv4.1 device id. Finally, notify waiting request that we have got * the reply for LAYOUTGET */ - public void messageArrived( - PoolPassiveIoFileMessage message) { + public void messageArrived(PoolPassiveIoFileMessage message) { String poolName = message.getPoolName(); long verifier = message.getVerifier(); @@ -539,9 +539,13 @@ public void messageArrived( PoolDS device = _poolDeviceMap.getOrCreateDS(poolName, verifier, poolAddresses); - org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = message.challange(); - NfsTransfer transfer = _transfers.get( - new stateid4(legacyStateid.other, legacyStateid.seqid.value)); + + // REVISIT 11.0: remove drop legacy support. Old polls will send legacy stateid. + // stateid4 stateid = message.challange(); + Object stateObject = message.challange(); + stateid4 stateid = LegacyUtils.toStateid(stateObject); + NfsTransfer transfer = _transfers.get(stateid); + /* * We got a notification for a transfer which was not * started by us. @@ -591,10 +595,12 @@ public void messageArrived(DoorTransferFinishedMessage transferFinishedMessage) } } - public DoorValidateMoverMessage messageArrived( - DoorValidateMoverMessage message) { - org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = message.getChallenge(); - stateid4 stateid = new stateid4(legacyStateid.other, legacyStateid.seqid.value); + public DoorValidateMoverMessage messageArrived(DoorValidateMoverMessage message) { + + // REVISIT 11.0: remove drop legacy support. Old polls will send legacy stateid. + // stateid4 stateid = message.getChallenge(); + Object stateObject = message.getChallenge(); + stateid4 stateid = LegacyUtils.toStateid(stateObject); boolean isValid = false; try { diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsMover.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsMover.java index 6cdd56af9ea..ce6f7e5133e 100644 --- a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsMover.java +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsMover.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.nio.channels.CompletionHandler; +import org.dcache.chimera.nfsv41.common.LegacyUtils; import org.dcache.nfs.ChimeraNFSException; import org.dcache.nfs.status.NfsIoException; import org.dcache.nfs.v4.NFS4State; @@ -51,8 +52,13 @@ public NfsMover(ReplicaDescriptor handle, PoolIoFileMessage message, CellPath pa NfsTransferService nfsTransferService, PnfsHandler pnfsHandler) { super(handle, message, pathToDoor, nfsTransferService); _nfsTransferService = nfsTransferService; - org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateid = getProtocolInfo().stateId(); - _state = new MoverState(null, new stateid4(legacyStateid.other, legacyStateid.seqid.value)); + + // REVISIT 11.0: remove drop legacy support + // stateid4 stateid = getProtocolInfo().stateId(); + Object stateObject = getProtocolInfo().stateId(); + stateid4 stateid = LegacyUtils.toStateid(stateObject); + + _state = new MoverState(null, stateid); _namespace = pnfsHandler; } diff --git a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsTransferService.java b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsTransferService.java index 63064c86794..f222ab1e4f4 100644 --- a/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsTransferService.java +++ b/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/mover/NfsTransferService.java @@ -44,6 +44,7 @@ import javax.annotation.Nullable; import org.dcache.auth.Subjects; import org.dcache.cells.CellStub; +import org.dcache.chimera.nfsv41.common.LegacyUtils; import org.dcache.chimera.nfsv41.common.StatsDecoratedOperationExecutor; import org.dcache.commons.stats.RequestExecutionTimeGauges; import org.dcache.nfs.ChimeraNFSException; @@ -342,11 +343,16 @@ public Cancellable executeMover(final NfsMover mover, public void notifyDoorWithRedirect(NfsMover mover) { CellPath directDoorPath = new CellPath(mover.getPathToDoor().getDestinationAddress()); - final org.dcache.chimera.nfs.v4.xdr.stateid4 legacyStateId = mover.getProtocolInfo() - .stateId(); + + // REVISIT 11.0: remove drop legacy support + // stateid4 stateid = mover.getProtocolInfo().stateId(); + Object stateObject = mover.getProtocolInfo().stateId(); + stateid4 stateid = LegacyUtils.toStateid(stateObject); + + // never send legacy stateid. _door.notify(directDoorPath, new PoolPassiveIoFileMessage<>(_cellAddress.getCellName(), _localSocketAddresses, - legacyStateId, + stateid, _bootVerifier)); }