Skip to content

Commit eb08513

Browse files
author
ehennum
committed
Merge branch 'develop-72' into develop
2 parents a078cd9 + 19c5e69 commit eb08513

Some content is hidden

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

46 files changed

+3513
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2019 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.dataservices;
17+
18+
import com.marklogic.client.DatabaseClient;
19+
import com.marklogic.client.SessionState;
20+
import com.marklogic.client.dataservices.impl.ExecEndpointImpl;
21+
import com.marklogic.client.io.marker.JSONWriteHandle;
22+
23+
import java.io.InputStream;
24+
25+
/**
26+
* Provides an interface for calling an endpoint that doesn't take
27+
* input data structures or return output data structures.
28+
*/
29+
public interface ExecEndpoint extends IOEndpoint {
30+
/**
31+
* Constructs an instance of the ExecEndpoint interface
32+
* for calling the specified endpoint.
33+
* @param client the database client to use for making calls
34+
* @param apiDecl the JSON api declaration specifying how to call the endpoint
35+
* @return the ExecEndpoint instance for calling the endpoint
36+
*/
37+
static ExecEndpoint on(DatabaseClient client, JSONWriteHandle apiDecl) {
38+
return new ExecEndpointImpl(client, apiDecl);
39+
}
40+
41+
/**
42+
* Makes one call to the endpoint for the instance.
43+
* @param endpointState the current mutable state of the endpoint (which must be null if not accepted by the endpoint)
44+
* @param session the identifier for the server cache of the endpoint (which must be null if not accepted by the endpoint)
45+
* @param workUnit the definition of a unit of work (which must be null if not accepted by the endpoint)
46+
* @return the endpoint state for the next call, if returned by the endpoint, or null
47+
*/
48+
InputStream call(InputStream endpointState, SessionState session, InputStream workUnit);
49+
50+
/**
51+
* Constructs an instance of a bulk caller, which completes
52+
* a unit of work by repeated calls to the endpoint.
53+
* @return the bulk caller for the endpoint
54+
*/
55+
BulkExecCaller bulkCaller();
56+
57+
/**
58+
* Provides an interface for completing a unit of work
59+
* by repeated calls to an endpoint that doesn't take input
60+
* data structure or return output data structures.
61+
*
62+
* Use the inherited methods to set the endpoint state
63+
* and / or work unit if accepted by the endpoint.
64+
* Then, call awaitCompletion() to start making calls.
65+
*/
66+
interface BulkExecCaller extends IOEndpoint.BulkIOEndpointCaller {
67+
}
68+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2019 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.dataservices;
17+
18+
import com.marklogic.client.SessionState;
19+
import com.marklogic.client.io.marker.BufferableHandle;
20+
21+
import java.io.InputStream;
22+
import java.util.function.Consumer;
23+
24+
/**
25+
* Base interface providing the methods common to all endpoints.
26+
*/
27+
public interface IOEndpoint {
28+
/**
29+
* Identifies the path of the endpoint in the modules database on the server.
30+
* @return the path
31+
*/
32+
String getEndpointPath();
33+
34+
/**
35+
* Identifies whether the endpoint accepts and returns a data structure
36+
* that provides a snapshot of the mutable state of the endpoint.
37+
* @return whether the endpoint takes a state
38+
*/
39+
boolean allowsEndpointState();
40+
/**
41+
* Identifies whether the endpoint accepts a session identifier that
42+
* the endpoint can use to access a session cache on the server.
43+
* @return whether the endpoint takes a session
44+
*/
45+
boolean allowsSession();
46+
/**
47+
* Identifies whether the endpoint accepts a data structure that defines
48+
* the unit of work to be done by the endpoint.
49+
* @return whether the endpoint takes a work unit
50+
*/
51+
boolean allowsWorkUnit();
52+
/**
53+
* Identifies whether the endpoint accepts one or more input data structures
54+
* to work on.
55+
* @return whether the endpoint takes input data structures
56+
*/
57+
boolean allowsInput();
58+
59+
/**
60+
* Generates an identifier for an endpoint to use when accessing a session cache
61+
* on the server. The identifier can be reused for multiple calls.
62+
* @return a new identifier for a session cache on the server
63+
*/
64+
SessionState newSessionState();
65+
66+
/**
67+
* Base interface providing the methods common to all bulk endpoint callers.
68+
*/
69+
interface BulkIOEndpointCaller {
70+
/**
71+
* Gets the current snapshot of the mutable endpoint state.
72+
* @return the data structure with the endpoint state
73+
*/
74+
InputStream getEndpointState();
75+
/**
76+
* Initializes the endpoint state, typically prior to the first call.
77+
* @param endpointState the data structure for the endpoint state as a byte[] array
78+
*/
79+
void setEndpointState(byte[] endpointState);
80+
/**
81+
* Initializes the endpoint state, typically prior to the first call.
82+
* @param endpointState the data structure for the endpoint state as an InputStream
83+
*/
84+
void setEndpointState(InputStream endpointState);
85+
/**
86+
* Initializes the endpoint state, typically prior to the first call.
87+
* @param endpointState the data structure for the endpoint state as a bufferable handle
88+
*/
89+
void setEndpointState(BufferableHandle endpointState);
90+
91+
/**
92+
* Gets the definition for the unit of work to be done by the endpoint.
93+
* @return the data structure for the unit of work
94+
*/
95+
InputStream getWorkUnit();
96+
/**
97+
* Initializes the defintion of the work unit prior to the first call.
98+
* @param workUnit the data structure for the work unit as a byte[] array
99+
*/
100+
void setWorkUnit(byte[] workUnit);
101+
/**
102+
* Initializes the defintion of the work unit prior to the first call.
103+
* @param workUnit the data structure for the work unit as an InputStream
104+
*/
105+
void setWorkUnit(InputStream workUnit);
106+
/**
107+
* Initializes the defintion of the work unit prior to the first call.
108+
* @param workUnit the data structure for the work unit as a bufferable handle
109+
*/
110+
void setWorkUnit(BufferableHandle workUnit);
111+
112+
/**
113+
* Waits for the bulk calling to complete, first starting the calls if appropriate.
114+
*/
115+
void awaitCompletion();
116+
117+
/**
118+
* Interrupts the iterative bulk calls prior to completion.
119+
*/
120+
void interrupt();
121+
}
122+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2019 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.dataservices;
17+
18+
import java.io.InputStream;
19+
20+
import com.marklogic.client.DatabaseClient;
21+
import com.marklogic.client.SessionState;
22+
import com.marklogic.client.dataservices.impl.InputEndpointImpl;
23+
import com.marklogic.client.io.marker.JSONWriteHandle;
24+
25+
/**
26+
* Provides an interface for calling an endpoint that takes input data structures.
27+
*/
28+
public interface InputEndpoint extends IOEndpoint {
29+
/**
30+
* Constructs an instance of the InputEndpoint interface.
31+
* @param client the database client to use for making calls
32+
* @param apiDecl the JSON api declaration specifying how to call the endpoint
33+
* @return the InputEndpoint instance for calling the endpoint.
34+
*/
35+
static InputEndpoint on(DatabaseClient client, JSONWriteHandle apiDecl) {
36+
return new InputEndpointImpl(client, apiDecl);
37+
}
38+
39+
/**
40+
* Makes one call to the endpoint for the instance
41+
* @param endpointState the current mutable state of the endpoint (which must be null if not accepted by the endpoint)
42+
* @param session the identifier for the server cache of the endpoint (which must be null if not accepted by the endpoint)
43+
* @param workUnit the definition of a unit of work (which must be null if not accepted by the endpoint)
44+
* @param input the request data sent to the endpoint
45+
* @return the endpoint state for the next call, if returned by the endpoint, or null
46+
*/
47+
InputStream call(InputStream endpointState, SessionState session, InputStream workUnit, InputStream[] input);
48+
/**
49+
* Constructs an instance of a bulk caller, which completes
50+
* a unit of work by repeated calls to the endpoint.
51+
* @return the bulk caller for the input endpoint
52+
*/
53+
BulkInputCaller bulkCaller();
54+
55+
/**
56+
* Provides an interface for completing a unit of work
57+
* by repeated calls to the input endpoint.
58+
*/
59+
interface BulkInputCaller extends IOEndpoint.BulkIOEndpointCaller {
60+
/**
61+
* Accepts an input item for the endpoint. Items are queued
62+
* and submitted to the endpoint in batches.
63+
* @param input one input item
64+
*/
65+
void accept(InputStream input);
66+
/**
67+
* Accepts multiple input items for the endpoint. Items are queued
68+
* and submitted to the endpoint in batches.
69+
* @param input multiple input items.
70+
*/
71+
void acceptAll(InputStream[] input);
72+
}
73+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2019 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.dataservices;
17+
18+
import com.marklogic.client.DatabaseClient;
19+
import com.marklogic.client.SessionState;
20+
import com.marklogic.client.dataservices.impl.InputOutputEndpointImpl;
21+
import com.marklogic.client.io.marker.JSONWriteHandle;
22+
23+
import java.io.InputStream;
24+
import java.util.function.Consumer;
25+
26+
/**
27+
* Provides an interface for calling an endpoint that takes input data structures and
28+
* returns output data structures.
29+
*/
30+
public interface InputOutputEndpoint extends IOEndpoint {
31+
static InputOutputEndpoint on(DatabaseClient client, JSONWriteHandle apiDecl) {
32+
return new InputOutputEndpointImpl(client, apiDecl);
33+
}
34+
35+
/**
36+
* Makes one call to the endpoint for the instance
37+
* @param endpointState the current mutable state of the endpoint (which must be null if not accepted by the endpoint)
38+
* @param session the identifier for the server cache of the endpoint (which must be null if not accepted by the endpoint)
39+
* @param workUnit the definition of a unit of work (which must be null if not accepted by the endpoint)
40+
* @param input the request data sent to the endpoint
41+
* @return the endpoint state if produced by the endpoint followed by the response data from the endpoint
42+
*/
43+
InputStream[] call(InputStream endpointState, SessionState session, InputStream workUnit, InputStream[] input);
44+
45+
/**
46+
* Constructs an instance of a bulk caller, which completes
47+
* a unit of work by repeated calls to the endpoint.
48+
* @return the bulk caller for the input-output endpoint
49+
*/
50+
BulkInputOutputCaller bulkCaller();
51+
52+
/**
53+
* Provides an interface for completing a unit of work
54+
* by repeated calls to the input-output endpoint.
55+
*/
56+
interface BulkInputOutputCaller extends IOEndpoint.BulkIOEndpointCaller {
57+
/**
58+
* Specifies the function to call on receiving output from the endpoint.
59+
* @param listener a function for processing the endpoint output
60+
*/
61+
void setOutputListener(Consumer<InputStream> listener);
62+
/**
63+
* Accepts an input item for the endpoint. Items are queued
64+
* and submitted to the endpoint in batches.
65+
* @param input one input item
66+
*/
67+
void accept(InputStream input);
68+
/**
69+
* Accepts multiple input items for the endpoint. Items are queued
70+
* and submitted to the endpoint in batches.
71+
* @param input multiple input items.
72+
*/
73+
void acceptAll(InputStream[] input);
74+
}
75+
}

0 commit comments

Comments
 (0)