Class AbstractTrsStore
- java.lang.Object
-
- com.sodius.oslc.server.trs.store.AbstractTrsStore
-
- All Implemented Interfaces:
ResourceEventStore
,Store
,TrsStore
- Direct Known Subclasses:
FileTrsStore
public abstract class AbstractTrsStore extends Object implements TrsStore
Partial implementation of aTrsStore
fulfilling the contract ofResourceEventStore
.- Since:
- 3.3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
BASE_BUFFER_SIZE
Proven buffer size for base members consumption with good performance for memory and db storage.protected static int
EVENTS_BUFFER_SIZE
Proven buffer size for resource events consumption with good performance for memory and db storage.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTrsStore(URI domain)
Creates a new store instance representing the given OSLC domain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertNoOrderOverflow(int order)
Asserts whether the given order can be safely incremented after this call, to add a new change event.protected URI
getDomain()
Returns the OSLC domain represented by this store.boolean
isStoringEventsOf(Optional<String> projectAreaId)
Determines whether the store is currently able to store events and, optionally, for a particular project.void
store(ResourceEvent... resourceEvents)
Stores one or a fewresource events
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sodius.oslc.server.trs.store.ResourceEventStore
store
-
Methods inherited from interface com.sodius.oslc.server.trs.store.Store
corrupt, isCorrupted
-
Methods inherited from interface com.sodius.oslc.server.trs.store.TrsStore
addBaseMembers, collectBaseMembers, collectChangeEventSeeds, countChangeEventSeeds, createSynchronizer, getControl, getFirstChangeEventSince, getStagingResourceEventStore, isResourceExposed, pollChangeEventSeeds, pushResourceEvents, rebase, removeChangeEventSeedsBefore, restore, saveControl, synchronizeResourceEvents
-
-
-
-
Field Detail
-
BASE_BUFFER_SIZE
protected static final int BASE_BUFFER_SIZE
Proven buffer size for base members consumption with good performance for memory and db storage.- See Also:
- Constant Field Values
-
EVENTS_BUFFER_SIZE
protected static final int EVENTS_BUFFER_SIZE
Proven buffer size for resource events consumption with good performance for memory and db storage.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractTrsStore
protected AbstractTrsStore(URI domain)
Creates a new store instance representing the given OSLC domain.- Parameters:
domain
- the OSLC domain- Throws:
NullPointerException
- if the domain isnull
- Since:
- 3.11.0
-
-
Method Detail
-
getDomain
protected final URI getDomain()
Returns the OSLC domain represented by this store.- Since:
- 3.11.0
-
isStoringEventsOf
public boolean isStoringEventsOf(Optional<String> projectAreaId)
Description copied from interface:ResourceEventStore
Determines whether the store is currently able to store events and, optionally, for a particular project.This method must not raise any exception,
false
must be returned silently if any of them occurred while computing the result. Implementation must verify theTRS store is not corrupted
, the correspondingbase is computed
and afunctional user
is set. If a project is given, it is then recommended to rely onTrsFeedManager.isExposedProjectArea(String)
.- Specified by:
isStoringEventsOf
in interfaceResourceEventStore
- Parameters:
projectAreaId
- the optional project identifier.- Returns:
true
if TRS events should be stored
-
store
public void store(ResourceEvent... resourceEvents)
Description copied from interface:ResourceEventStore
Stores one or a fewresource events
. If a larger volume of events is to send at once, client is recommended to rather use theResourceEventStore.store(Function)
method.Implementations MUST store events, without blocking the application, only if the
ResourceEventStore.isStoringEventsOf(Optional)
method returnstrue
, for each of the givenevent seeds
, and must keep them hidden from the TRS feed up to theTrsStore.synchronizeResourceEvents()
method is called.This method is intended to avoid raising
TrsStoreException
, if something went wrong preventing the storage of the event, implementations must handle it silently.- Specified by:
store
in interfaceResourceEventStore
- Parameters:
resourceEvents
- events to store.
-
assertNoOrderOverflow
protected void assertNoOrderOverflow(int order)
Asserts whether the given order can be safely incremented after this call, to add a new change event. If the given number is yet the maximum value, this methodcorrupts
the store and throws an exception.- Parameters:
order
- the last event order used and that is to increment after this call- Throws:
CompletionException
- if the given order is yet the maximum value- Since:
- 3.11.0
-
-