Skip to content

Commit 48d80f5

Browse files
committed
nfs: add CompoundContextBuilder#withSession
to keep fluent syntax Acked-by: Paul Millar Target: master
1 parent 5138fd7 commit 48d80f5

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

core/src/main/java/org/dcache/nfs/v4/CompoundContext.java

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public CompoundContext(CompoundContextBuilder builder) {
118118
_exchangeIdFlags = builder.getExchangeIdFlags();
119119
_rebootVerifier = builder.getRebootVerifier();
120120
_implId = builder.getImplementationId();
121+
_session = builder.getSession();
121122
}
122123

123124
public RpcCall getRpcCall() {

core/src/main/java/org/dcache/nfs/v4/CompoundContextBuilder.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 - 2023 Deutsches Elektronen-Synchroton,
2+
* Copyright (c) 2009 - 2025 Deutsches Elektronen-Synchroton,
33
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
44
*
55
* This library is free software; you can redistribute it and/or modify
@@ -40,6 +40,7 @@ public class CompoundContextBuilder {
4040
private ExportTable exportTable = null;
4141
private int exchangeIdFlags = nfs4_prot.EXCHGID4_FLAG_USE_NON_PNFS;
4242
private verifier4 rebootVerifier;
43+
private NFSv41Session session;
4344

4445
private nfs_impl_id4 implId;
4546

@@ -151,4 +152,13 @@ public CompoundContextBuilder withRebootVerifier(verifier4 verifier) {
151152
public verifier4 getRebootVerifier() {
152153
return rebootVerifier;
153154
}
155+
156+
public CompoundContextBuilder withSession(NFSv41Session session) {
157+
this.session = session;
158+
return this;
159+
}
160+
161+
public NFSv41Session getSession() {
162+
return session;
163+
}
154164
}

core/src/test/java/org/dcache/nfs/v4/OperationREADTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public void testLeaseUpdateForV40Client() throws UnknownHostException, ChimeraNF
7070

7171
CompoundContext context = new CompoundContextBuilder()
7272
.withStateHandler(stateHandler)
73+
.withSession(session)
7374
.withFs(vfs)
7475
.withMinorversion(0)
7576
.withCall(generateRpcCall())
7677
.build();
7778

78-
context.setSession(session);
7979
execute(context, readArgs);
8080
verify(stateHandler, times(1)).updateClientLeaseTime(stateid);
8181
}
@@ -106,12 +106,12 @@ public void testNoLeaseUpdateForV41Client() throws UnknownHostException, Chimera
106106

107107
CompoundContext context = new CompoundContextBuilder()
108108
.withStateHandler(stateHandler)
109+
.withSession(session)
109110
.withFs(vfs)
110111
.withMinorversion(1)
111112
.withCall(generateRpcCall())
112113
.build();
113114

114-
context.setSession(session);
115115
execute(context, readArgs);
116116
verify(stateHandler, never()).updateClientLeaseTime(stateid);
117117
}

core/src/test/java/org/dcache/nfs/v4/OperationWRITETest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public void testLeaseUpdateForV40Client() throws UnknownHostException, ChimeraNF
7373

7474
CompoundContext context = new CompoundContextBuilder()
7575
.withStateHandler(stateHandler)
76+
.withSession(session)
7677
.withFs(vfs)
7778
.withMinorversion(0)
7879
.withCall(generateRpcCall())
7980
.build();
8081

81-
context.setSession(session);
8282
execute(context, writeArgs);
8383
verify(stateHandler, times(1)).updateClientLeaseTime(stateid);
8484
}
@@ -109,12 +109,12 @@ public void testNoLeaseUpdateForV41Client() throws UnknownHostException, Chimera
109109

110110
CompoundContext context = new CompoundContextBuilder()
111111
.withStateHandler(stateHandler)
112+
.withSession(session)
112113
.withFs(vfs)
113114
.withMinorversion(1)
114115
.withCall(generateRpcCall())
115116
.build();
116117

117-
context.setSession(session);
118118
execute(context, writeArgs);
119119
verify(stateHandler, never()).updateClientLeaseTime(stateid);
120120
}
@@ -147,12 +147,12 @@ public void testReturnWriteVerifier() throws UnknownHostException, ChimeraNFSExc
147147

148148
CompoundContext context = new CompoundContextBuilder()
149149
.withStateHandler(stateHandler)
150+
.withSession(session)
150151
.withFs(vfs)
151152
.withMinorversion(1)
152153
.withRebootVerifier(verifier)
153154
.withCall(generateRpcCall())
154155
.build();
155-
context.setSession(session);
156156

157157
COMPOUND4res res = execute(context, writeArgs);
158158
assertSame(verifier, res.resarray.get(1).opwrite.resok4.writeverf);

0 commit comments

Comments
 (0)