NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::RequestProcessor::AbstractRequest Class Referenceabstract

#include <AbstractRequest.hpp>

Collaboration diagram for NES::RequestProcessor::AbstractRequest:
[legend]

Public Member Functions

 AbstractRequest (uint8_t maxRetries)
 constructor More...
 
void setId (RequestId requestId)
 set the id of this object. This has to be done before any resource is locked. More...
 
virtual std::vector< AbstractRequestPtrexecute (const StorageHandlerPtr &storageHandle)=0
 Acquires locks on the needed resources and executes the request logic. More...
 
virtual std::vector< AbstractRequestPtrrollBack (std::exception_ptr ex, const StorageHandlerPtr &storageHandle)=0
 Roll back any changes made by a request that did not complete due to errors. More...
 
std::vector< AbstractRequestPtrhandleError (const std::exception_ptr &ex, const StorageHandlerPtr &storageHandle)
 Calls rollBack and executes additional error handling based on the exception if necessary. More...
 
bool retry ()
 Check if the request has already reached the maximum allowed retry attempts or if it can be retried again. If the maximum is not reached yet, increase the amount of recorded actual retries. More...
 
std::future< AbstractRequestResponsePtrgetFuture ()
 creates a future which will contain the response supplied by this request More...
 
virtual ~AbstractRequest ()=default
 destructor More...
 
template<class RequestType >
bool instanceOf ()
 Checks if this object is of type AbstractRequest. More...
 
template<class RequestType >
std::shared_ptr< RequestTypeas ()
 Dynamically casts the exception to the given type. More...
 

Protected Member Functions

virtual void preRollbackHandle (std::exception_ptr ex, const StorageHandlerPtr &storageHandle)=0
 Performs request specific error handling to be done before changes to the storage are rolled back. More...
 
virtual void postRollbackHandle (std::exception_ptr ex, const StorageHandlerPtr &storageHandle)=0
 Performs request specific error handling to be done after changes to the storage are rolled back. More...
 
void trySetExceptionInPromise (std::exception_ptr exception)
 if no exception or value has been set in this requests response promise yet, set the supplied exception. If a value has already been set, this method has no effect More...
 
void setExceptionInPromiseOrRethrow (std::exception_ptr exception)
 set and exception on the response promise if no value or exception has been set yet. If the promise already has a value or exception set, rethrow the exception in thsi thread More...
 

Protected Attributes

RequestId requestId {INVALID_REQUEST_ID}
 
std::promise< AbstractRequestResponsePtrresponsePromise
 

Constructor & Destructor Documentation

◆ AbstractRequest()

NES::RequestProcessor::AbstractRequest::AbstractRequest ( uint8_t  maxRetries)
explicit

constructor

Parameters
maxRetriesamount of retries to execute the request after execution failed due to errors

◆ ~AbstractRequest()

virtual NES::RequestProcessor::AbstractRequest::~AbstractRequest ( )
virtualdefault

destructor

Member Function Documentation

◆ as()

template<class RequestType >
std::shared_ptr<RequestType> NES::RequestProcessor::AbstractRequest::as ( )
inline

Dynamically casts the exception to the given type.

Template Parameters
RequestTypea subclass ob AbstractRequest
Returns
returns a shared pointer of the given type

◆ execute()

virtual std::vector<AbstractRequestPtr> NES::RequestProcessor::AbstractRequest::execute ( const StorageHandlerPtr storageHandle)
pure virtual

Acquires locks on the needed resources and executes the request logic.

Parameters
storageHandlea handle to access the coordinators data structures which might be needed for executing the request
Returns
a list of follow up requests to be executed (can be empty if no further actions are required)

Implemented in NES::RequestProcessor::AbstractUniRequest, and NES::RequestProcessor::AbstractMultiRequest.

◆ getFuture()

std::future< AbstractRequestResponsePtr > NES::RequestProcessor::AbstractRequest::getFuture ( )

creates a future which will contain the response supplied by this request

Returns
a future containing a pointer to the response object

References responsePromise.

Referenced by NES::RequestProcessor::TEST_F().

Here is the caller graph for this function:

◆ handleError()

std::vector< AbstractRequestPtr > NES::RequestProcessor::AbstractRequest::handleError ( const std::exception_ptr &  ex,
const StorageHandlerPtr storageHandle 
)

Calls rollBack and executes additional error handling based on the exception if necessary.

Parameters
exThe exception thrown during request execution. std::exception_ptr is used to be able to allow setting an exception state on the requests response promise without losing data to slicing in case the request cannot handle the exception itself
storageHandleThe storage access handle that was used by the request to modify the system state.
Returns
a list of follow up requests to be executed (can be empty if no further actions are required)

References NES_ERROR, postRollbackHandle(), preRollbackHandle(), retry(), and rollBack().

Referenced by NES::RequestProcessor::ISQPRequest::executeRequestLogic(), NES::RequestProcessor::StopQueryRequest::executeRequestLogic(), NES::RequestProcessor::AddQueryRequest::executeRequestLogic(), and NES::RequestProcessor::ExplainRequest::executeRequestLogic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instanceOf()

template<class RequestType >
bool NES::RequestProcessor::AbstractRequest::instanceOf ( )
inline

Checks if this object is of type AbstractRequest.

Template Parameters
RequestTypea subclass ob AbstractRequest
Returns
bool true if object is of type AbstractRequest

◆ postRollbackHandle()

virtual void NES::RequestProcessor::AbstractRequest::postRollbackHandle ( std::exception_ptr  ex,
const StorageHandlerPtr storageHandle 
)
protectedpure virtual

Performs request specific error handling to be done after changes to the storage are rolled back.

Parameters
exThe exception thrown during request execution. std::exception_ptr is used to be able to allow setting an exception state on the requests response promise without losing data to slicing in case the request cannot handle the exception itself
storageHandleThe storage access handle used by the request

Implemented in NES::RequestProcessor::DummyRequest, NES::RequestProcessor::DummyRequest, NES::RequestProcessor::Experimental::DummyMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureRequest, NES::RequestProcessor::Experimental::DummyConcatRequest, NES::RequestProcessor::StopQueryRequest, NES::RequestProcessor::FailQueryRequest, NES::RequestProcessor::ExplainRequest, NES::RequestProcessor::AddQueryRequest, NES::RequestProcessor::UpdateSourceCatalogRequest, NES::RequestProcessor::GetSourceCatalogRequest, and NES::RequestProcessor::ISQPRequest.

Referenced by handleError().

Here is the caller graph for this function:

◆ preRollbackHandle()

virtual void NES::RequestProcessor::AbstractRequest::preRollbackHandle ( std::exception_ptr  ex,
const StorageHandlerPtr storageHandle 
)
protectedpure virtual

Performs request specific error handling to be done before changes to the storage are rolled back.

Parameters
exThe exception thrown during request execution. std::exception_ptr is used to be able to allow setting an exception state on the requests response promise without losing data to slicing in case the request cannot handle the exception itself
storageHandleThe storage access handle used by the request

Implemented in NES::RequestProcessor::DummyRequest, NES::RequestProcessor::DummyRequest, NES::RequestProcessor::Experimental::DummyMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureRequest, NES::RequestProcessor::Experimental::DummyConcatRequest, NES::RequestProcessor::StopQueryRequest, NES::RequestProcessor::FailQueryRequest, NES::RequestProcessor::ExplainRequest, NES::RequestProcessor::AddQueryRequest, NES::RequestProcessor::UpdateSourceCatalogRequest, NES::RequestProcessor::GetSourceCatalogRequest, and NES::RequestProcessor::ISQPRequest.

Referenced by handleError().

Here is the caller graph for this function:

◆ retry()

bool NES::RequestProcessor::AbstractRequest::retry ( )

Check if the request has already reached the maximum allowed retry attempts or if it can be retried again. If the maximum is not reached yet, increase the amount of recorded actual retries.

Returns
true if the actual retries are less than the allowed maximum

Referenced by handleError().

Here is the caller graph for this function:

◆ rollBack()

virtual std::vector<AbstractRequestPtr> NES::RequestProcessor::AbstractRequest::rollBack ( std::exception_ptr  ex,
const StorageHandlerPtr storageHandle 
)
pure virtual

Roll back any changes made by a request that did not complete due to errors.

Parameters
exThe exception thrown during request execution. std::exception_ptr is used to be able to allow setting an exception state on the requests response promise without losing data to slicing in case the request cannot handle the exception itself
storageHandleThe storage access handle that was used by the request to modify the system state.
Returns
a list of follow up requests to be executed (can be empty if no further actions are required)

Implemented in NES::RequestProcessor::DummyRequest, NES::RequestProcessor::DummyRequest, NES::RequestProcessor::Experimental::DummyMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureMultiRequest, NES::RequestProcessor::Experimental::DummyWaitOnFutureRequest, NES::RequestProcessor::Experimental::DummyConcatRequest, NES::RequestProcessor::StopQueryRequest, NES::RequestProcessor::UpdateSourceCatalogRequest, NES::RequestProcessor::GetSourceCatalogRequest, NES::RequestProcessor::ISQPRequest, NES::RequestProcessor::FailQueryRequest, NES::RequestProcessor::ExplainRequest, and NES::RequestProcessor::AddQueryRequest.

Referenced by handleError().

Here is the caller graph for this function:

◆ setExceptionInPromiseOrRethrow()

void NES::RequestProcessor::AbstractRequest::setExceptionInPromiseOrRethrow ( std::exception_ptr  exception)
protected

set and exception on the response promise if no value or exception has been set yet. If the promise already has a value or exception set, rethrow the exception in thsi thread

Parameters
exceptionthe exception to give to the promise

References responsePromise.

Referenced by NES::RequestProcessor::AddQueryRequest::rollBack(), and NES::RequestProcessor::StopQueryRequest::rollBack().

Here is the caller graph for this function:

◆ setId()

void NES::RequestProcessor::AbstractRequest::setId ( RequestId  requestId)

set the id of this object. This has to be done before any resource is locked.

Parameters
requestId

References requestId.

Referenced by NES::RequestProcessor::TEST_F().

Here is the caller graph for this function:

◆ trySetExceptionInPromise()

void NES::RequestProcessor::AbstractRequest::trySetExceptionInPromise ( std::exception_ptr  exception)
protected

if no exception or value has been set in this requests response promise yet, set the supplied exception. If a value has already been set, this method has no effect

Parameters
exceptionthe exception to give to the promise

References backward::details::move(), and responsePromise.

Referenced by NES::RequestProcessor::AddQueryRequest::rollBack(), NES::RequestProcessor::FailQueryRequest::rollBack(), and NES::RequestProcessor::StopQueryRequest::rollBack().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ requestId

◆ responsePromise


The documentation for this class was generated from the following files: