Skip to content

Commit 82a2df3

Browse files
author
ehennum
committed
rename workUnit to endpointConstants #1250
1 parent 07395c8 commit 82a2df3

File tree

60 files changed

+298
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+298
-261
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/ExecCaller.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ static ExecCaller on(DatabaseClient client, JSONWriteHandle apiDecl) {
3636
}
3737

3838
/**
39-
* Makes one call to an endpoint that doesn't take an endpoint state, session, or work unit.
39+
* Makes one call to an endpoint that doesn't take endpoint constants, endpoint state, or a session.
4040
*/
4141
void call();
4242
/**
4343
* Makes one call to the endpoint for the instance and sets the endpoint state in the Call Context.
44-
* @param callContext the collection of endpointState, sessionState and workUnit
44+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
4545
*/
4646
void call(CallContext callContext);
4747

@@ -54,7 +54,7 @@ static ExecCaller on(DatabaseClient client, JSONWriteHandle apiDecl) {
5454
/**
5555
* Constructs an instance of a bulk caller, which completes
5656
* a unit of work by repeated calls to the endpoint. The calls occur in the current thread.
57-
* @param callContext the collection of endpointState, sessionState and workUnit
57+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
5858
* @return the bulk caller for the endpoint
5959
*/
6060
BulkExecCaller bulkCaller(CallContext callContext);
@@ -79,9 +79,7 @@ static ExecCaller on(DatabaseClient client, JSONWriteHandle apiDecl) {
7979
* by repeated calls to an endpoint that doesn't take input
8080
* data structure or return output data structures.
8181
*
82-
* Use the inherited methods to set the endpoint state
83-
* and / or work unit if accepted by the endpoint.
84-
* Then, call awaitCompletion() to start making calls.
82+
* Call awaitCompletion() to start making calls.
8583
*/
8684
interface BulkExecCaller extends BulkIOEndpointCaller {
8785
void setErrorListener(ErrorListener errorListener);

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/ExecEndpoint.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ private BulkLocal(EndpointLocal<I,O> endpoint) {
7373
* by repeated calls to an endpoint that doesn't take input
7474
* data structure or return output data structures.
7575
*
76-
* Use the inherited methods to set the endpoint state
77-
* and / or work unit if accepted by the endpoint.
78-
* Then, call awaitCompletion() to start making calls.
76+
* Call awaitCompletion() to start making calls.
7977
*/
8078
@Deprecated
8179
interface BulkExecCaller extends ExecCaller.BulkExecCaller {

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/IOEndpoint.java

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ public interface IOEndpoint {
4949
* the unit of work to be done by the endpoint.
5050
* @return whether the endpoint takes a work unit
5151
*/
52+
@Deprecated
5253
boolean allowsWorkUnit();
54+
/**
55+
* Identifies whether the endpoint accepts a data structure that defines
56+
* constant input to provide to the endpoint.
57+
* @return whether the endpoint takes endpoint constants
58+
*/
59+
boolean allowsEndpointConstants();
5360
/**
5461
* Identifies whether the endpoint accepts one or more input data structures
5562
* to work on.
@@ -70,49 +77,57 @@ public interface IOEndpoint {
7077
interface BulkIOEndpointCaller {
7178
/**
7279
* Gets the current snapshot of the mutable endpoint state.
80+
* Provide a CallContext when constructing the bulk caller instead of using this deprecated method.
7381
* @return the data structure with the endpoint state
7482
*/
7583
@Deprecated
7684
InputStream getEndpointState();
7785
/**
7886
* Initializes the endpoint state, typically prior to the first call.
87+
* Provide a CallContext when constructing the bulk caller instead of using this deprecated method.
7988
* @param endpointState the data structure for the endpoint state as a byte[] array
8089
*/
8190
@Deprecated
8291
void setEndpointState(byte[] endpointState);
8392
/**
8493
* Initializes the endpoint state, typically prior to the first call.
94+
* Provide a CallContext when constructing the bulk caller instead of using this deprecated method.
8595
* @param endpointState the data structure for the endpoint state as an InputStream
8696
*/
8797
@Deprecated
8898
void setEndpointState(InputStream endpointState);
8999
/**
90100
* Initializes the endpoint state, typically prior to the first call.
101+
* Provide a CallContext when constructing the bulk caller instead of using this deprecated method.
91102
* @param endpointState the data structure for the endpoint state as a bufferable handle
92103
*/
93104
@Deprecated
94105
void setEndpointState(BufferableHandle endpointState);
95106

96107
/**
97108
* Gets the definition for the unit of work to be done by the endpoint.
109+
* Provide a CallContext with endpoint constants when constructing the bulk caller instead of using this deprecated method.
98110
* @return the data structure for the unit of work
99111
*/
100112
@Deprecated
101113
InputStream getWorkUnit();
102114
/**
103-
* Initializes the defintion of the work unit prior to the first call.
115+
* Initializes the definition of the work unit prior to the first call.
116+
* Provide a CallContext with endpoint constants when constructing the bulk caller instead of using this deprecated method.
104117
* @param workUnit the data structure for the work unit as a byte[] array
105118
*/
106119
@Deprecated
107120
void setWorkUnit(byte[] workUnit);
108121
/**
109-
* Initializes the defintion of the work unit prior to the first call.
122+
* Initializes the definition of the work unit prior to the first call.
123+
* Provide a CallContext with endpoint constants when constructing the bulk caller instead of using this deprecated method.
110124
* @param workUnit the data structure for the work unit as an InputStream
111125
*/
112126
@Deprecated
113127
void setWorkUnit(InputStream workUnit);
114128
/**
115-
* Initializes the defintion of the work unit prior to the first call.
129+
* Initializes the definition of the work unit prior to the first call.
130+
* Provide a CallContext with endpoint constants when constructing the bulk caller instead of using this deprecated method.
116131
* @param workUnit the data structure for the work unit as a bufferable handle
117132
*/
118133
@Deprecated
@@ -128,52 +143,68 @@ interface BulkIOEndpointCaller {
128143
*/
129144
void interrupt();
130145

146+
/**
147+
* Indicates the disposition of an error.
148+
*/
131149
enum ErrorDisposition {
132-
RETRY, SKIP_CALL, STOP_CONTEXT_CALLS, STOP_ALL_CALLS;
150+
RETRY, SKIP_CALL, STOP_ALL_CALLS;
133151
}
134152
}
135153
/**
136-
* Gets the current snapshot of the endpoint state, work unit and session.
137-
* @return the data structure with the endpoint state, work unit and session.
154+
* Constructs a context for the calls that specifying the optional endpoint constants,
155+
* endpoint state, and session.
156+
* @return the context for calls
138157
*/
139158
CallContext newCallContext();
140159

160+
/**
161+
* Provides the optional endpoint constants, endpoint state, and session as a context
162+
* for calls to the server.
163+
*/
141164
interface CallContext {
142165
/**
143-
* Gets the current snapshot of the mutable endpoint state.
166+
* Gets the current snapshot of the mutable state of the endpoint.
144167
* @return the data structure with the endpoint state
145168
*/
146169
BytesHandle getEndpointState();
147170
/**
148-
* Initializes the endpoint state.
149-
* @param endpointState the data structure for the endpoint state as a bufferable handle
171+
* Initializes the stateful properties of the endpoint prior to the first call to the endpoint.
172+
* The endpoint returns the state as the first value in the response.
173+
* The caller resends the modified state on the next call to the endpoint.
174+
* @param endpointState the data structure for the endpoint state in a representation supported by a bufferable content handle
150175
* @return the callContext
151176
*/
152177
CallContext withEndpointState(BufferableHandle endpointState);
153178
/**
154-
* Initializes the endpoint state.
155-
* @param endpointState the data structure for the endpoint state as an InputStream
179+
* Initializes the stateful properties of the endpoint prior to the first call to the endpoint.
180+
* The endpoint returns the state as the first value in the response.
181+
* The caller resends the modified state on the next call to the endpoint.
182+
* @param endpointState the data structure for the endpoint state in a representation supported by a bufferable content handle
156183
* @return the callContext
157184
*/
158185
CallContext withEndpointStateAs(Object endpointState);
159186

160187
/**
161-
* Gets the definition for the unit of work to be done by the endpoint.
162-
* @return the data structure for the unit of work
188+
* Gets the definition for constant inputs to the endpoint.
189+
* @return the data structure for the constants
163190
*/
164-
BytesHandle getWorkUnit();
191+
BytesHandle getEndpointConstants();
165192
/**
166-
* Initializes the defintion of the work unit.
167-
* @param workUnit the data structure for the work unit as a bufferable handle
193+
* Sets the constant inputs prior to the first call to the endpoint.
194+
* Examples of such constants might include the query when paging
195+
* over a result set or the provenance when ingesting records.
196+
* @param constants the data structure in a representation supported by a bufferable content handle
168197
* @return the callContext
169198
*/
170-
CallContext withWorkUnit(BufferableHandle workUnit);
199+
CallContext withEndpointConstants(BufferableHandle constants);
171200
/**
172-
* Initializes the defintion of the work unit.
173-
* @param workUnit the data structure for the work unit as an InputStream
201+
* Sets the constant inputs prior to the first call to the endpoint.
202+
* Examples of such constants might include the query when paging
203+
* over a result set or the provenance when ingesting records.
204+
* @param constants the data structure in a representation supported by a bufferable content handle
174205
* @return the callContext
175206
*/
176-
CallContext withWorkUnitAs(Object workUnit);
207+
CallContext withEndpointConstantsAs(Object constants);
177208

178209
/**
179210
* Returns an identifier for an endpoint to use when accessing a session cache on the server.

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/InputCaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ static <I> InputCaller<I> on(DatabaseClient client, JSONWriteHandle apiDecl, Buf
3737
}
3838

3939
/**
40-
* Makes one call to an endpoint that doesn't take an endpoint state, session, or work unit.
40+
* Makes one call to an endpoint that doesn't take endpoint constants, endpoint state, or a session.
4141
* @param input the request data sent to the endpoint
4242
*/
4343
void call(I[] input);
4444
/**
4545
* Makes one call to the endpoint for the instance and sets the endpoint state in the Call Context.
46-
* @param callContext the collection of endpointState, sessionState and workUnit
46+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
4747
* @param input the request data sent to the endpoint
4848
*/
4949
void call(CallContext callContext, I[] input);
@@ -57,7 +57,7 @@ static <I> InputCaller<I> on(DatabaseClient client, JSONWriteHandle apiDecl, Buf
5757
/**
5858
* Constructs an instance of a bulk caller, which completes
5959
* a unit of work by repeated calls to the endpoint. The calls occur in the current thread.
60-
* @param callContext the collection of endpointState, sessionState and workUnit
60+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
6161
* @return the bulk caller for the input endpoint
6262
*/
6363
BulkInputCaller<I> bulkCaller(CallContext callContext);

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/InputOutputCaller.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ static <I,O> InputOutputCaller<I,O> on(
4545
}
4646

4747
/**
48-
* Makes one call to an endpoint that doesn't take an endpoint state, session, or work unit.
48+
* Makes one call to an endpoint that doesn't take endpoint constants, endpoint state, or a session.
4949
* @param input the request data sent to the endpoint
5050
* @return the response data from the endpoint
5151
*/
5252
O[] call(I[] input);
5353
/**
54-
* Makes one call to an endpoint that doesn't take an endpoint state, session, or work unit and sets the
55-
* endpoint state in the Call Context.
56-
* @param callContext the collection of endpointState, sessionState and workUnit
54+
* Makes one call to an endpoint that sets endpoint constants, endpoint state, or a session
55+
* in the Call Context.
56+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
5757
* @param input the request data sent to the endpoint
5858
* @return the response data from the endpoint
5959
*/
@@ -68,7 +68,7 @@ static <I,O> InputOutputCaller<I,O> on(
6868
/**
6969
* Constructs an instance of a bulk caller, which completes
7070
* a unit of work by repeated calls to the endpoint. The calls occur in the current thread.
71-
* @param callContext the collection of endpointState, sessionState and workUnit
71+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
7272
* @return the bulk caller for the input-output endpoint
7373
*/
7474
BulkInputOutputCaller<I,O> bulkCaller(CallContext callContext);

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/OutputCaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ static <O> OutputCaller<O> on(
4141
}
4242

4343
/**
44-
* Makes one call to an endpoint that doesn't take an endpoint state, session, or work unit.
44+
* Makes one call to an endpoint that doesn't take endpoint constants, endpoint state, or a session.
4545
* @return the response data from the endpoint
4646
*/
4747
O[] call();
4848
/**
4949
* Makes one call to the endpoint for the instance and sets the endpoint state in the Call Context.
50-
* @param callContext the collection of endpointState, sessionState and workUnit
50+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
5151
* @return the response data from the endpoint
5252
*/
5353
O[] call(CallContext callContext);
@@ -61,7 +61,7 @@ static <O> OutputCaller<O> on(
6161
/**
6262
* Constructs an instance of a bulk caller, which completes
6363
* a unit of work by repeated calls to the endpoint. The calls occur in current thread.
64-
* @param callContext the collection of endpointState, sessionState and workUnit
64+
* @param callContext the context consisting of the optional endpointConstants, endpointState, and session
6565
* @return the bulk caller for the output endpoint
6666
*/
6767
BulkOutputCaller<O> bulkCaller(CallContext callContext);

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/impl/CallContextImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CallContextImpl<I,O> implements IOEndpoint.CallContext {
3333
private final boolean legacyContext;
3434

3535
private BytesHandle endpointState;
36-
private BytesHandle workUnit;
36+
private BytesHandle endpointConstants;
3737
private SessionState session;
3838

3939
CallContextImpl(IOEndpointImpl<I,O> endpoint, boolean legacyContext) {
@@ -42,8 +42,8 @@ class CallContextImpl<I,O> implements IOEndpoint.CallContext {
4242
if (endpoint.allowsEndpointState()) {
4343
endpointState = new BytesHandle().withFormat(endpoint.getEndpointStateParamdef().getFormat());
4444
}
45-
if (endpoint.allowsWorkUnit()) {
46-
workUnit = new BytesHandle().withFormat(endpoint.getWorkUnitParamdef().getFormat());
45+
if (endpoint.allowsEndpointConstants()) {
46+
endpointConstants = new BytesHandle().withFormat(endpoint.getEndpointConstantsParamdef().getFormat());
4747
}
4848
}
4949

@@ -58,6 +58,9 @@ DatabaseClient getClient() {
5858
boolean isLegacyContext() {
5959
return legacyContext;
6060
}
61+
String getEndpointConstantsParamName() {
62+
return isLegacyContext() ? "workUnit" : "endpointConstants";
63+
}
6164

6265
@Override
6366
public BytesHandle getEndpointState() {
@@ -80,19 +83,19 @@ public CallContextImpl<I,O> withEndpointStateAs(Object endpointState) {
8083
}
8184

8285
@Override
83-
public BytesHandle getWorkUnit() {
84-
return this.workUnit;
86+
public BytesHandle getEndpointConstants() {
87+
return this.endpointConstants;
8588
}
8689
@Override
87-
public CallContextImpl<I,O> withWorkUnit(BufferableHandle workUnit) {
88-
return assignBytes(this.workUnit, workUnit);
90+
public CallContextImpl<I,O> withEndpointConstants(BufferableHandle constants) {
91+
return assignBytes(this.endpointConstants, constants);
8992
}
90-
CallContextImpl<I,O> withWorkUnitAs(InputStream workUnit) {
91-
return assignBytes(this.workUnit, workUnit);
93+
CallContextImpl<I,O> withEndpointConstantsAs(InputStream contants) {
94+
return assignBytes(this.endpointConstants, contants);
9295
}
9396
@Override
94-
public CallContextImpl<I,O> withWorkUnitAs(Object workUnit) {
95-
return assignBytes(this.workUnit, workUnit);
97+
public CallContextImpl<I,O> withEndpointConstantsAs(Object constants) {
98+
return assignBytes(this.endpointConstants, constants);
9699
}
97100

98101
@Override

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/impl/ExecEndpointImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public void call(CallContext callContext) {
5353
}
5454

5555
@Deprecated
56-
public InputStream call(InputStream endpointState, SessionState session, InputStream workUnit) {
56+
public InputStream call(InputStream endpointState, SessionState session, InputStream endpointConstants) {
5757
CallContextImpl<I,O> callContext = newCallContext(true)
5858
.withEndpointStateAs(endpointState)
5959
.withSessionState(session)
60-
.withWorkUnitAs(workUnit);
60+
.withEndpointConstantsAs(endpointConstants);
6161
call(callContext);
6262
return callContext.getEndpointStateAsInputStream();
6363
}
@@ -215,14 +215,14 @@ private boolean processOutput(CallContextImpl<I,O> callContext){
215215
case INTERRUPTING:
216216
setPhase(WorkPhase.INTERRUPTED);
217217
logger.info("exec interrupted endpoint={} count={} work={}",
218-
callContext.getEndpoint().getEndpointPath(), getCallCount(), callContext.getWorkUnit());
218+
callContext.getEndpoint().getEndpointPath(), getCallCount(), callContext.getEndpointConstants());
219219
return false;
220220
case RUNNING:
221221
if (!continueCalling) {
222222
if(getCallerThreadPoolExecutor() == null || aliveCallContextCount.get() == 0)
223223
setPhase(WorkPhase.COMPLETED);
224224
logger.info("exec completed endpoint={} count={} work={}",
225-
callContext.getEndpoint().getEndpointPath(), getCallCount(), callContext.getWorkUnit());
225+
callContext.getEndpoint().getEndpointPath(), getCallCount(), callContext.getEndpointConstants());
226226
return false;
227227
}
228228
return true;

0 commit comments

Comments
 (0)