Class TransactionalResourceService
java.lang.Object
dev.getelements.elements.rt.transact.TransactionalResourceService
- All Implemented Interfaces:
ResourceService
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.rt.ResourceService
ResourceService.Listing, ResourceService.ResourceAcquisition, ResourceService.ResourceTransaction, ResourceService.Unlink -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquire(ResourceId resourceId) Acquires aResourceguaranteeing it will remain in-memory until the resource is released.Acquires aResourceguaranteeing it will remain in-memory until the resource is released.acquireWithTransaction(ResourceId resourceId) Opens aResourceService.ResourceTransaction.acquireWithTransaction(Path path) Opens aResourceService.ResourceTransaction.addAndAcquireResource(Path path, Resource resource) Adds an acquires thisResource.voidaddAndReleaseResource(Path path, Resource resource) Adds aResourceto this resource service.booleanexists(ResourceId resourceId) Without affecting acquisition or releases, this performs a simple check to see if theResourcewith the suppliedResourceIdexists in thisResourceService.longvoidlink(ResourceId sourceResourceId, Path destination) Given the providedResourceId, this will create an additional alias for the provided destinationPath.voidlistStream(Path path) Returns aStream<ResourceId>matching the providedPath.Removes all resources from.removeResource(ResourceId resourceId) Removes aResourceinstance from this resource service.removeResources(Path path, int max, Consumer<Resource> removed) voidvoidsetPersistence(TransactionalResourceServicePersistence persistence) voidsetResourceLoader(ResourceLoader resourceLoader) voidstart()Called on start-up to ensure that theResourceServicehas created and started any internal processes that it may need to perform its work.voidstop()Releases all memory associated with thisResourceService.unlinkMultiple(Path path, int max, Consumer<Resource> removed) Unlinks multipleResources.unlinkPath(Path path, Consumer<Resource> removed) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.rt.ResourceService
destroy, destroy, destroyResources, removeAndCloseAllResources, removeResource, removeResources, unlinkMultiple, unlinkPath
-
Constructor Details
-
TransactionalResourceService
public TransactionalResourceService()
-
-
Method Details
-
start
public void start()Description copied from interface:ResourceServiceCalled on start-up to ensure that theResourceServicehas created and started any internal processes that it may need to perform its work.- Specified by:
startin interfaceResourceService
-
stop
public void stop()Description copied from interface:ResourceServiceReleases all memory associated with thisResourceService. The actual action that happens here is dependent on the specific implementation. For in-memory implementations, this will simply close all resources and exit. For persistence-backed implementations this should flush all resources to disk before closing all. Once closed this instance may only be used after it has been restarted.- Specified by:
stopin interfaceResourceService
-
exists
Description copied from interface:ResourceServiceWithout affecting acquisition or releases, this performs a simple check to see if theResourcewith the suppliedResourceIdexists in thisResourceService.- Specified by:
existsin interfaceResourceService- Parameters:
resourceId- theResourceId- Returns:
- true if exists, false otherwise.
-
acquire
Description copied from interface:ResourceServiceAcquires aResourceguaranteeing it will remain in-memory until the resource is released.- Specified by:
acquirein interfaceResourceService- Returns:
- the
ResourceService.ResourceAcquisition
-
acquire
Description copied from interface:ResourceServiceAcquires aResourceguaranteeing it will remain in-memory until the resource is released.- Specified by:
acquirein interfaceResourceService- Returns:
- the
ResourceService.ResourceAcquisition
-
acquireWithTransaction
Description copied from interface:ResourceServiceOpens aResourceService.ResourceTransaction.- Specified by:
acquireWithTransactionin interfaceResourceService- Returns:
- the
ResourceService.ResourceTransaction
-
acquireWithTransaction
Description copied from interface:ResourceServiceOpens aResourceService.ResourceTransaction.- Specified by:
acquireWithTransactionin interfaceResourceService- Returns:
- the
ResourceService.ResourceTransaction
-
addAndAcquireResource
Description copied from interface:ResourceServiceAdds an acquires thisResource. This is used for the initial insert into theResourceService. If linking to an additionalPathis necessary, then the methodsResourceService.linkPath(Path, Path)orResourceService.link(ResourceId, Path)must be used to perform additional aliasing operations. It is strongly recommended that newly insertedResourceinstances be given a globally unique path initially, which can be thought of as the primary path, and then subsequent aliases or links be maintained, even if those particularPaths may collide. This is only safe to use with freshly createdResourceinstances whoseResourceIdhas never before been seen by the system.- Specified by:
addAndAcquireResourcein interfaceResourceService- Parameters:
path-resource-- Returns:
- the managed version of the supplied
Resource
-
addAndReleaseResource
Description copied from interface:ResourceServiceAdds aResourceto this resource service. This is used for the initial insert into theResourceService. If linking to an additionalPathis necessary, then the methodsResourceService.linkPath(Path, Path)orResourceService.link(ResourceId, Path)must be used to perform additional aliasing operations. It is strongly recommended that newly insertedResourceinstances be given a globally unique path initially, which can be thought of as the primary path, and then subsequent aliases or links be maintained, even if those particularPaths may collide. Once aResourceis passed ot this method, thisResourceServicewill take ownership of it. This means the theResourcemay be closed after this call. Therefore, subsequent operations may require theResourcebe fetched from serialization later for subsequent operations.- Specified by:
addAndReleaseResourcein interfaceResourceService- Parameters:
path- the initial path for theResourceresource- the resource to insert
-
listStream
Description copied from interface:ResourceServiceReturns aStream<ResourceId>matching the providedPath.- Specified by:
listStreamin interfaceResourceService- Parameters:
path- thePathto match- Returns:
- a
Stream<ResourceId>
-
link
Description copied from interface:ResourceServiceGiven the providedResourceId, this will create an additional alias for the provided destinationPath.- Specified by:
linkin interfaceResourceService- Parameters:
sourceResourceId-destination-
-
linkPath
Description copied from interface:ResourceService- Specified by:
linkPathin interfaceResourceService- Parameters:
source- the sourcePathdestination- the destinationPath
-
unlinkPath
Description copied from interface:ResourceServiceUnlinks theResourcefor the providedPath. If the unlinkedPathis the final path, then this will remove thePathfrom theResourceService. If thisPathis the last alias for the associatedResource, then the removedResourceIdwill be passed to the suppliedConsumer. The suppliedConsumerwill not be called if there still exist aliases for the associatedResource. Only oneResourcemay be unlinked at a time. Therefore, the supplied,Pathmost not be a wildcard path.- Specified by:
unlinkPathin interfaceResourceService- Parameters:
path- aPathto unlinkremoved- a Consumer which will receive the removedResource- Returns:
- true if the
Resourceassociated with thePathwas removed, false otherwise
-
unlinkMultiple
Description copied from interface:ResourceService- Specified by:
unlinkMultiplein interfaceResourceService- Parameters:
path- the path to removemax- the maximum count to removeremoved- aConsumer<Resource>to process each removal- Returns:
- the final
ResourceService.Unlinkoperations
-
removeResource
Description copied from interface:ResourceServiceRemoves aResourceinstance from this resource service.- Specified by:
removeResourcein interfaceResourceService- Parameters:
resourceId- the resourceId to the resource
-
removeResources
Description copied from interface:ResourceService- Specified by:
removeResourcesin interfaceResourceService- Parameters:
path- the thePathfor the resource.max-removed- aConsumer<Resource>which accepts the removed resource
-
removeAllResources
Description copied from interface:ResourceServiceRemoves all resources from. The returnedStream<Resource>returns anyResources that are still occupying memory and must be closed. The returned stream may be empty if all have been persisted. This operation may lock the wholeResourceServiceto accomplish its task.- Specified by:
removeAllResourcesin interfaceResourceService
-
getInMemoryResourceCount
public long getInMemoryResourceCount()- Specified by:
getInMemoryResourceCountin interfaceResourceService
-
getNodeId
-
setNodeId
-
getResourceLoader
-
setResourceLoader
-
getPersistence
-
setPersistence
-