Class StreamHandlerAbstract<I,O>
java.lang.Object
io.clonecloudstore.common.quarkus.server.service.StreamHandlerAbstract<I,O>
- Direct Known Subclasses:
AbstractObjectStreamHandler
,FakeStreamHandlerAbstract
,LocalReplicatorStreamHandler
,RemoteReplicatorStreamHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CountDownLatch
protected final AtomicReference
<Exception> protected final AtomicReference
<O> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkDigestToCompute
(I businessIn) Default based on QuarkusProperties.serverComputeSha256protected void
checkEndOfPush
(boolean remote) protected abstract boolean
checkPullAble
(I businessIn, io.vertx.core.MultiMap headers) The implementation must check using business object that get inputStream request (server sending InputStream as result) is valid according to the businessIn from te Rest API and the headers.protected abstract void
checkPushAble
(I businessIn, MultipleActionsInputStream inputStream) Check if the request for POST is valid, and if so, adapt the given MultipleActionsInputStream that will be used to consume the original InputStream.protected void
clear()
Clear all contextprotected jakarta.ws.rs.core.Response
protected void
endPush()
protected abstract O
getAnswerPushInputStream
(I businessIn, String finalHash, long size) Returns a BusinessOut in case of POST (receiving InputStream on server side).protected I
protected io.quarkus.resteasy.reactive.server.Closer
getHeaderError
(I businessIn, int status) Return headers for error message.getHeaderPullInputStream
(I businessIn) Returns a Map for Headers response in case of GET, added to InputStream get above (server is sending the InputStream back to the client) (example: headers for object name, object size...)getHeaderPushInputStream
(I businessIn, String finalHash, long size, O businessOut) Returns a Map for Headers response in case of POST (receiving InputStream on server side).long
protected String
getOpId()
protected abstract InputStream
getPullInputStream
(I businessIn) Returns the InputStream required for GET (server is sending the InputStream back to the client).io.vertx.core.http.HttpServerRequest
protected ServerStreamHandlerResponseException
getServerStreamHandlerResponseException
(jakarta.ws.rs.core.Response.Status status) io.vertx.mutiny.core.Vertx
getVertx()
protected boolean
boolean
boolean
boolean
True means the stream will be kept compressed if source (from client) is compressed or do not recompress getInputStreamboolean
True means the incoming stream is compressed (ZSTD)protected boolean
isUpload()
protected void
Method to override for post setupprotected void
jakarta.ws.rs.core.Response
pull()
jakarta.ws.rs.core.Response
pullList()
protected void
protected void
void
setKeepInputStreamCompressed
(boolean change) void
setResponseCompressed
(boolean change) protected void
setResultFromRemote
(O businessOut) void
setup
(io.vertx.core.http.HttpServerRequest request, io.quarkus.resteasy.reactive.server.Closer closer, boolean isUpload, I businessIn, long inputLength, String optionalHash, boolean keepInputStreamCompressed, boolean external) Constructor, while inputLength could be 0 (valid for both POST and GET, signifying the posted InputStream length or the supposed returned InputStream length).boolean
protected boolean
protected void
jakarta.ws.rs.core.Response
upload
(InputStream inputStream)
-
Field Details
-
exceptionAtomicReference
-
countDownLatch
-
resultProxy
-
-
Constructor Details
-
StreamHandlerAbstract
protected StreamHandlerAbstract()
-
-
Method Details
-
postSetup
protected void postSetup()Method to override for post setup -
setup
public void setup(io.vertx.core.http.HttpServerRequest request, io.quarkus.resteasy.reactive.server.Closer closer, boolean isUpload, I businessIn, long inputLength, String optionalHash, boolean keepInputStreamCompressed, boolean external) Constructor, while inputLength could be 0 (valid for both POST and GET, signifying the posted InputStream length or the supposed returned InputStream length). When the stream is incoming (server side, so using POST, stream coming from client), if compressed, the configuration shall decide if the stream is kept compressed or decompressed before passing the stream to its final usage.- Parameters:
isUpload
- True for incoming InputStream, False for outgoing InputStreaminputLength
- might be 0 if unknown sizeoptionalHash
- Hash optional (might be null); if POST InputStream, if empty, Hash will be computedkeepInputStreamCompressed
- True means the stream will be kept compressed if source (from client) is compressed (for push only)external
-
-
pullList
-
pull
-
upload
public jakarta.ws.rs.core.Response upload(InputStream inputStream) throws ServerStreamHandlerResponseException -
doGetInputStream
protected jakarta.ws.rs.core.Response doGetInputStream() -
preparePull
-
sendError
-
sendError
protected void sendError(jakarta.ws.rs.core.Response.Status status, Throwable t) throws ServerStreamHandlerResponseException -
getServerStreamHandlerResponseException
protected ServerStreamHandlerResponseException getServerStreamHandlerResponseException(jakarta.ws.rs.core.Response.Status status) -
clear
protected void clear()Clear all context -
setResultFromRemote
-
endPush
protected void endPush() -
checkEndOfPush
protected void checkEndOfPush(boolean remote) -
throwTrappedException
protected void throwTrappedException() -
isUpload
protected boolean isUpload()- Returns:
- True if Write (client sends an InputStream), False if Read (client receives an InputStream)
-
getOpId
- Returns:
- the Operation Id (unique)
-
isAlreadyCompressed
protected boolean isAlreadyCompressed()- Returns:
- True if the InputStream is already compressed (POST)
-
shallCompress
public boolean shallCompress()- Returns:
- True if the InputStream shall be compressed (GET)
-
shallDecompress
protected boolean shallDecompress()- Returns:
- True if the InputStream shall be decompressed (GET and POST)
-
getBusinessIn
- Returns:
- the passed BusinessIn during construction
-
getRequest
public io.vertx.core.http.HttpServerRequest getRequest() -
isKeepAlive
public boolean isKeepAlive() -
isKeepInputStreamCompressed
public boolean isKeepInputStreamCompressed()True means the stream will be kept compressed if source (from client) is compressed or do not recompress getInputStream -
setKeepInputStreamCompressed
public void setKeepInputStreamCompressed(boolean change) -
isResponseCompressed
public boolean isResponseCompressed()True means the incoming stream is compressed (ZSTD) -
setResponseCompressed
public void setResponseCompressed(boolean change) -
getOriginalHash
-
getVertx
public io.vertx.mutiny.core.Vertx getVertx() -
getInputStreamLength
public long getInputStreamLength() -
isExternal
public boolean isExternal() -
getCloser
protected io.quarkus.resteasy.reactive.server.Closer getCloser() -
checkDigestToCompute
Default based on QuarkusProperties.serverComputeSha256- Returns:
- True if the digest is to be computed on the fly
-
checkPushAble
protected abstract void checkPushAble(I businessIn, MultipleActionsInputStream inputStream) throws CcsClientGenericException, CcsServerGenericException Check if the request for POST is valid, and if so, adapt the given MultipleActionsInputStream that will be used to consume the original InputStream. The implementation shall use the business logic to check the validity for this InputStream reception (from client to server) and, if valid, use the MultipleActionsInputStream, either as is or as a standard InputStream. (example: check through Object Storage that object does not exist yet, and if so add the consumption of the stream for the Object Storage object creation). Note that the stream might be kept compressed if keepInputStreamCompressed was specified at construction. -
getAnswerPushInputStream
protected abstract O getAnswerPushInputStream(I businessIn, String finalHash, long size) throws CcsClientGenericException, CcsServerGenericException Returns a BusinessOut in case of POST (receiving InputStream on server side). The implementation shall use the business logic to get the right BusinessOut object to return. (example: getting the StorageObject object, including the computed or given Hash)- Parameters:
businessIn
- businessIn as passed in constructorfinalHash
- the final Hash if computed on the fly, or the original given onesize
- the real size read (from received stream, could be compressed size if decompression is off at construction)- Throws:
CcsClientGenericException
CcsServerGenericException
-
getHeaderPushInputStream
protected abstract Map<String,String> getHeaderPushInputStream(I businessIn, String finalHash, long size, O businessOut) throws CcsClientGenericException, CcsServerGenericException Returns a Map for Headers response in case of POST (receiving InputStream on server side). (example: headers for object name, object size, ...)- Parameters:
businessIn
- businessIn as passed in constructorfinalHash
- the final Hash if computed on the fly, or the original given onesize
- the real size readbusinessOut
- previously constructed from getAnswerPushInputStream- Throws:
CcsClientGenericException
CcsServerGenericException
-
checkPullAble
protected abstract boolean checkPullAble(I businessIn, io.vertx.core.MultiMap headers) throws CcsClientGenericException, CcsServerGenericException The implementation must check using business object that get inputStream request (server sending InputStream as result) is valid according to the businessIn from te Rest API and the headers. (example: ObjectStorage check of existence of object)- Returns:
- True if the read action is valid for this businessIn object and headers
- Throws:
CcsClientGenericException
CcsServerGenericException
-
getPullInputStream
protected abstract InputStream getPullInputStream(I businessIn) throws CcsClientGenericException, CcsServerGenericException Returns the InputStream required for GET (server is sending the InputStream back to the client). The implementation shall use the business logic and controls to get the InputStream to return. (example: getting the Object Storage object stream)- Parameters:
businessIn
- businessIn as passed in constructor- Throws:
CcsClientGenericException
CcsServerGenericException
-
getHeaderPullInputStream
protected abstract Map<String,String> getHeaderPullInputStream(I businessIn) throws CcsClientGenericException, CcsServerGenericException Returns a Map for Headers response in case of GET, added to InputStream get above (server is sending the InputStream back to the client) (example: headers for object name, object size...)- Parameters:
businessIn
- businessIn as passed in constructor- Throws:
CcsClientGenericException
CcsServerGenericException
-
getHeaderError
Return headers for error message. (example: get headers in case of error as Object name, Bucket name...)
-