Skip to content

Commit

Permalink
nfs: introduce NFS4Client#getOwnerId
Browse files Browse the repository at this point in the history
Motivation:
client's long-hand owner id is a client side identifier which is used by
server identify client on initial EXCHANGE_ID or SETCLIENT_ID (v4.0).
Moreover, during reboot recovery server uses owner id to find records
associated with a previous instance of the server.

Modification:
add NFS4Client#getOwnerId to make it possible to get client's owner id.
Remove NFS4Client#isOwner.

Result:
Client's long-hand owner id is available for later use.

Acked-by: Marina Sahakyan
Target: master
  • Loading branch information
kofemann committed Jul 31, 2018
1 parent d40d475 commit 6834b8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
19 changes: 8 additions & 11 deletions core/src/main/java/org/dcache/nfs/v4/NFS4Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,15 @@ public class NFS4Client {
*/

/**
* The client identifier string, from the eia_clientowner structure
* of the EXCHANGE_ID4args structure
* Variable length string that uniquely defines the client.
*/
private final byte[] _ownerId;

/**
* A client-specific value used to indicate reboots, from
* the eia_clientowner structure of the EXCHANGE_ID4args structure
* Verifier that is used to detect client reboots.
*/

private final verifier4 _verifier;

/**
* The RPCSEC_GSS principal sent via the RPC headers.
*/
Expand Down Expand Up @@ -192,7 +190,7 @@ public NFS4Client(NFSv4StateHandler stateHandler, clientid4 clientId, int minorV
byte[] ownerID, verifier4 verifier, Principal principal, long leaseTime, boolean calbackNeeded) {

_stateHandler = stateHandler;
_ownerId = ownerID;
_ownerId = Arrays.copyOf(ownerID, ownerID.length);
_verifier = verifier;
_principal = principal;
_clientId = clientId;
Expand Down Expand Up @@ -222,12 +220,11 @@ public int getMinorVersion() {
}

/**
* Check whatever client belongs to the provider owner.
* @param other client owner to test.
* @return <tt>true</tt> iff client belongs to the provider owner.
* Get client's long-hand unique identifier.
* @return client's unique identifier.
*/
public boolean isOwner(byte[] other) {
return Arrays.equals(_ownerId, other);
public byte[] getOwnerId() {
return _ownerId;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/java/org/dcache/nfs/v4/NFSv4StateHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.net.InetSocketAddress;
import java.security.Principal;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -186,11 +187,17 @@ public synchronized NFS4Client getClient(sessionid4 id) throws ChimeraNFSExcepti
return client;
}

/**
* Get existing, possibly not valid, client record that matches given client side generated long-hand owner identifier.
* @param ownerid client side generated long-hand owner identifier.
*
* @return an existing client record or null, if not matching record found.
*/
public synchronized NFS4Client clientByOwner(byte[] ownerid) {
return _clientsByServerId.entries()
.stream()
.map(CacheElement::getObject)
.filter(c -> c.isOwner(ownerid))
.filter(c -> Arrays.equals(c.getOwnerId(), ownerid))
.findAny()
.orElse(null);
}
Expand Down

0 comments on commit 6834b8a

Please sign in to comment.