Class LocalBackend

java.lang.Object
com.vaadin.collaborationengine.Backend
com.vaadin.collaborationengine.LocalBackend

public class LocalBackend extends Backend
A simple backend implementation that only distributes events locally and assumes that there is no previous history for event logs.
Author:
Vaadin Ltd
  • Constructor Details

    • LocalBackend

      public LocalBackend()
  • Method Details

    • openEventLog

      public Backend.EventLog openEventLog(String topicId)
      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 until Backend.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 class Backend
      Parameters:
      topicId - the id of the event log to open, not null
      Returns:
      an object representing the event log, not null
    • addMembershipListener

      public Registration addMembershipListener(MembershipListener membershipListener)
      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 class Backend
      Parameters:
      membershipListener - the listener, not null
      Returns:
      a registration that can be used to remove the listener, not null
    • getNodeId

      public UUID getNodeId()
      Description copied from class: Backend
      Gets the unique identifier of this backend node.
      Specified by:
      getNodeId in class Backend
      Returns:
      the node id, not null
    • loadLatestSnapshot

      public CompletableFuture<Backend.Snapshot> loadLatestSnapshot(String name)
      Description copied from class: Backend
      Loads the latest snapshot of data identified by the given name. To submit a snapshot see Backend.replaceSnapshot(String, UUID, UUID, String).
      Specified by:
      loadLatestSnapshot in class Backend
      Parameters:
      name - the name identifying the data, not null
      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 with Backend.loadLatestSnapshot(String).
      Specified by:
      replaceSnapshot in class Backend
      Parameters:
      name - the name identifying the date, not null
      expectedId - the unique ID of the expected current snapshot
      newId - the unique ID that the new snapshot will be stored with, not null
      payload - the snapshot payload, not null
      Returns:
      a completable future that will be resolved when the operation completes, not null