Package com.vaadin.collaborationengine
Class LocalBackend
java.lang.Object
com.vaadin.collaborationengine.Backend
com.vaadin.collaborationengine.LocalBackend
A simple backend implementation that only distributes events locally and
assumes that there is no previous history for event logs.
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.collaborationengine.Backend
Backend.EventIdNotFoundException, Backend.EventLog, Backend.Snapshot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMembershipListener
(MembershipListener membershipListener) Adds a listener of membership events.Gets the unique identifier of this backend node.loadLatestSnapshot
(String name) Loads the latest snapshot of data identified by the given name.openEventLog
(String topicId) Opens an event log with the given id.replaceSnapshot
(String name, UUID expectedId, UUID newId, String payload) Submits a snapshot payload of data identified by the given name.Methods inherited from class com.vaadin.collaborationengine.Backend
getCollaborationEngine, setCollaborationEngine
-
Constructor Details
-
LocalBackend
public LocalBackend()
-
-
Method Details
-
openEventLog
Description copied from class:Backend
Opens an event log with the given id. The returned object can be used to capture any common state related to this particular event log. An actual underlying connection is not needed untilBackend.EventLog.subscribe(UUID, BiConsumer)
} is invoked, but it is still recommended to make this method fail fast in case it would not be possible to open an actual underlying connection later.- Specified by:
openEventLog
in classBackend
- Parameters:
topicId
- the id of the event log to open, notnull
- Returns:
- an object representing the event log, not
null
-
addMembershipListener
Description copied from class:Backend
Adds a listener of membership events. The listener will be notified of events dispatched when a node joins or leaves the backend.- Specified by:
addMembershipListener
in classBackend
- Parameters:
membershipListener
- the listener, notnull
- Returns:
- a registration that can be used to remove the listener, not
null
-
getNodeId
Description copied from class:Backend
Gets the unique identifier of this backend node. -
loadLatestSnapshot
Description copied from class:Backend
Loads the latest snapshot of data identified by the given name. To submit a snapshot seeBackend.replaceSnapshot(String, UUID, UUID, String)
.- Specified by:
loadLatestSnapshot
in classBackend
- Parameters:
name
- the name identifying the data, notnull
- Returns:
- a completable future resolved with the UUID and snapshot, not
null
-
replaceSnapshot
public CompletableFuture<Void> replaceSnapshot(String name, UUID expectedId, UUID newId, String payload) Description copied from class:Backend
Submits a snapshot payload of data identified by the given name. The latest submitted snapshot for that name can be loaded withBackend.loadLatestSnapshot(String)
.- Specified by:
replaceSnapshot
in classBackend
- Parameters:
name
- the name identifying the date, notnull
expectedId
- the unique ID of the expected current snapshotnewId
- the unique ID that the new snapshot will be stored with, notnull
payload
- the snapshot payload, notnull
- Returns:
- a completable future that will be resolved when the operation
completes, not
null
-