Class TransactionalResource
java.lang.Object
dev.getelements.elements.rt.transact.TransactionalResource
- All Implemented Interfaces:
Resource,AutoCloseable
-
Field Summary
Fields inherited from interface dev.getelements.elements.rt.Resource
DEFAULT_IO_BUFFER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquire()voidclose()Closes and destroys this Resource.voidRestores the entire state of thisResourcefrom the suppliedInputStream.voidRestores the entire state of thisResourcefrom the suppliedInputStream.Gets theAttributesassociated with thisResourcegetId()Returns the immutable and globally-unique ID of this resource.org.slf4j.LoggerGets theLoggerused by thisResource.getMethodDispatcher(String name) Returns an instance ofMethodDispatcher, which is used to invoke methods against thisResource.getTasks()booleanbooleanReturns true if the resource is set to enable verbose mode.intrelease()voidResumes the supplied task with theTaskIdand the list of results.voidresumeFromNetwork(TaskId taskId, Object result) Resumes a suspended task, accepting the task id.voidresumeFromScheduler(TaskId taskId, double elapsedTime) Resumes a suspended task, accepting the task id.voidresumeWithError(TaskId taskId, Throwable throwable) Resumes a suspended task, accepting the task id.voidDumps the entire contents of thisResourceto the suppliedOutputStreamwhere it can be reconstituted later using theResource.deserialize(InputStream)method.voidDumps the entire contents of thisResourceto the suppliedWritableByteChannelwhere it can be reconstituted later using theResource.deserialize(InputStream)method.voidsetVerbose(boolean verbose) Sets the verbose mode.voidunload()Closes and destroys this Resource.
-
Constructor Details
-
TransactionalResource
-
-
Method Details
-
getId
Description copied from interface:ResourceReturns the immutable and globally-unique ID of this resource. Though a resource may exist at any path, this is the resource's ID. All resources are assigned a unique ID upon creation. The ID must remain unique for the life of the resource. -
getAttributes
Description copied from interface:ResourceGets theAttributesassociated with thisResource- Specified by:
getAttributesin interfaceResource- Returns:
- this instance's
Attributes
-
getMethodDispatcher
Description copied from interface:ResourceReturns an instance ofMethodDispatcher, which is used to invoke methods against thisResource. The reurnedMethodDispatcherwill defer actually invoking the method until the final call in the chainResultAcceptor.dispatch(Consumer, Consumer).- Specified by:
getMethodDispatcherin interfaceResource- Parameters:
name- the name of the method- Returns:
- the
MethodDispatcher, never null
-
resume
Description copied from interface:ResourceResumes the supplied task with theTaskIdand the list of results. -
resumeFromNetwork
Description copied from interface:ResourceResumes a suspended task, accepting the task id. The task will be resumed as soon as possible. This is used when the network resumes the call. This is assumed that the resume was successful. The response to the, invocation whatever it may be, was successful.- Specified by:
resumeFromNetworkin interfaceResource- Parameters:
taskId- theTaskIdif the running taskresult- the resulting object from the call
-
resumeWithError
Description copied from interface:ResourceResumes a suspended task, accepting the task id. The task will be resumed as soon as possible. This is used when suspended coroutine encountered an error. The coroutine will be resume with the error that caused the underlying failure.- Specified by:
resumeWithErrorin interfaceResource- Parameters:
taskId-throwable-
-
resumeFromScheduler
Description copied from interface:ResourceResumes a suspended task, accepting the task id. The task will be resumed as soon as possible. This method must succeed at the scheduling process, or else throw an exception. Note that this does not guarantee successful execution of the task, but rather successful scheduling.- Specified by:
resumeFromSchedulerin interfaceResource- Parameters:
taskId- theTaskIdif the running taskelapsedTime- the amount of time elapsed since the task was last activated
-
serialize
Description copied from interface:ResourceDumps the entire contents of thisResourceto the suppliedOutputStreamwhere it can be reconstituted later using theResource.deserialize(InputStream)method.- Specified by:
serializein interfaceResource- Parameters:
os- theOutputStreamused to receive the serializedResource- Throws:
IOException- if something failed during serialization
-
deserialize
Description copied from interface:ResourceRestores the entire state of thisResourcefrom the suppliedInputStream. This assumes theInputStreamwas produced by a call toResource.serialize(OutputStream).- Specified by:
deserializein interfaceResource- Parameters:
is- theInputStreamfrom which to read the serialized resource- Throws:
IOException- if something failed during deserialization
-
serialize
Description copied from interface:ResourceDumps the entire contents of thisResourceto the suppliedWritableByteChannelwhere it can be reconstituted later using theResource.deserialize(InputStream)method.- Specified by:
serializein interfaceResource- Parameters:
wbc- theOutputStreamused to receive the serializedResource- Throws:
IOException- if something failed during serialization
-
deserialize
Description copied from interface:ResourceRestores the entire state of thisResourcefrom the suppliedInputStream. This assumes theInputStreamwas produced by a call toResource.serialize(OutputStream).- Specified by:
deserializein interfaceResource- Parameters:
is- theInputStreamfrom which to read the serialized resource- Throws:
IOException- if something failed during deserialization
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:ResourceSets the verbose mode. This will enable enhanced logging for debug purposes.- Specified by:
setVerbosein interfaceResource- Parameters:
verbose- true if verbose, false otherwise
-
isVerbose
public boolean isVerbose()Description copied from interface:ResourceReturns true if the resource is set to enable verbose mode. -
getTasks
Description copied from interface:Resource -
getLogger
public org.slf4j.Logger getLogger()Description copied from interface:ResourceGets theLoggerused by thisResource. -
close
public void close()Description copied from interface:ResourceCloses and destroys this Resource. A resource, once destroyed, cannot be used again. Any tasks pending on the resource will be completed with aResourceDestroyedExceptionimmediately. This is simlar toResource.close()in that it frees up memory associated with thisResource. However, its key difference is that it also propagates exceptions which indicate that it has reached a final state. In contrast toResource.unload()which indicates that theResourcemy be reconstituted later to continue performing work.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResource
-
unload
public void unload()Description copied from interface:ResourceCloses and destroys this Resource. A resource, once destroyed, cannot be used again. Any tasks pending on ths resource will not be destroyed or unregistered. It is possible that later a newResourcewould be made and the contents of this deserialized back into this one. -
acquire
-
release
public int release() -
getDelegate
-
isFullyReleased
public boolean isFullyReleased()
-