T
- public abstract class AbstractRestApiTask<T> extends AbstractApiTask<T>
Modifier and Type | Field and Description |
---|---|
protected javax.servlet.http.HttpServletRequest |
req
The
HttpServletRequest . |
protected javax.servlet.http.HttpServletResponse |
resp
The
HttpServletResponse . |
protected UUID |
uuid
The
UUID associated with this task. |
namespace, timestamp
Modifier | Constructor and Description |
---|---|
protected |
AbstractRestApiTask(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String namespace,
long timestamp) |
protected |
AbstractRestApiTask(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String namespace,
long timestamp,
boolean isGRSRequired) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildResponse(int status,
String mimeType,
String content,
NV... headers)
Generate a response having the indicated http status code, mime type, and
content.
|
void |
flushAndClose()
Flush and close the
ServletOutputStream or PrintWriter
depending on which was obtained. |
OutputStream |
getOutputStream()
Return the
ServletOutputStream associated with the request (and
stash a copy). |
PrintWriter |
getWriter()
Return the
PrintWriter associated with the request (and stash a
copy). |
protected void |
reportModifiedCount(long nmodified,
long elapsed)
Reports the mutation count and elapsed operation time as specified by the
REST API for mutation operations.
|
String |
toString() |
getConnection, getIndexManager, getMutationCount, getNamespace, getQueryConnection, getQueryConnection, getTimestamp, getUnisolatedSailConnection, isGRSRequired, isReadOnly, setIndexManager, submitApiTask
protected final javax.servlet.http.HttpServletRequest req
HttpServletRequest
.protected final javax.servlet.http.HttpServletResponse resp
HttpServletResponse
.protected AbstractRestApiTask(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String namespace, long timestamp)
req
- The HttpServletRequest
.resp
- The HttpServletResponse
.namespace
- The namespace of the target KB instance.timestamp
- The timestamp of the view of that KB instance.protected AbstractRestApiTask(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String namespace, long timestamp, boolean isGRSRequired)
req
- The HttpServletRequest
.resp
- The HttpServletResponse
.namespace
- The namespace of the target KB instance.timestamp
- The timestamp of the view of that KB instance.isGSRRequired
- true
iff the task requires a lock on the GRS
index.public OutputStream getOutputStream() throws IOException
ServletOutputStream
associated with the request (and
stash a copy).IOException
IllegalStateException
- per the servlet API if the writer has been requested already.public PrintWriter getWriter() throws IOException
PrintWriter
associated with the request (and stash a
copy).IOException
IllegalStateException
- per the servlet API if the ServletOutputStream
has
been requested already.public void flushAndClose() throws IOException
ServletOutputStream
or PrintWriter
depending on which was obtained.IOException
public String toString()
toString
in class AbstractApiTask<T>
protected void reportModifiedCount(long nmodified, long elapsed) throws IOException
Note: When GROUP_COMMIT (#566) is enabled the http output stream MUST NOT
be closed by this method. Doing so would permit the client to conclude
that the operation was finished before the group commit actually occurs.
This situation arises because the AbstractApiTask implementation has
invoked conn.commit() and hence believes that it was successful, but the
AbstractTask
itself has not yet been through a checkpoint and the
write set for the commit group has not yet been melded into a stable
commit point. By NOT closing the output stream here we defer the signal
to the client until control is returned to the servlet container layer,
which does not occur until the task has finished executing and the group
commit is done. The servlet container then closes the output stream and
the client notices that the mutation operation is done and that its
applied mutation is now visible to a client reading against that commit
point. (Mind you, there might be other mutations in the same group commit
or even in subsequent commits so the client does not have a strong
guarantee that their mutation is visible in a post-commit read unless
they are controlling all writers.)
Note: The other code path for signaling to the client that a mutation is done is SPARQL UPDATE. See that code for a similar caution.
nmodified
- The number of modified triples/quads.elapsed
- The elapsed time for the operation.IOException
protected void buildResponse(int status, String mimeType, String content, NV... headers) throws IOException
status
- The http status code.mimeType
- The MIME type of the response.content
- The contentheaders
- Zero or more headers to be included in the response.IOException
AssertionError
- if the caller attempts to use this method for a non-success
(2xx) outcome. The correct pattern is to throw an
HttpOperationException
instead once you are inside of
an AbstractRestApiTask
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.