Class FilePersister

java.lang.Object
net.sodacan.core.persist.AbstractPersister
net.sodacan.core.persist.file.FilePersister
All Implemented Interfaces:
Persister

public class FilePersister extends AbstractPersister
Persist all @Save fields for one actor into a file. We collect all the fields and then write them together on a commit. This persister is devoted to a single actorid as are all persisters.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FilePersister(Config config, ActorId actorId)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    If we've already loaded the Actor, no need to do it again.
    void
    This method is called when the framework has concluded a series of writes that could be rolled back in case of an error.
    byte[]
    read(String key)
    This method is called by the framework when an actor's processMessage method is about to be called for the first time after the Actor has been instantiated.
    void
    When a series of writes should be rolled back: not written in the first place, replaced with a previous version, etc.
    void
    write(String key, byte[] bytes)
    The save method is called by the framework when an actor's state has been updated.

    Methods inherited from class net.sodacan.core.persist.AbstractPersister

    getActorId, getConfig, makeFile, makeFolder, makeTypeFolder

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FilePersister

      public FilePersister(Config config, ActorId actorId)
  • Method Details

    • begin

      public void begin()
      If we've already loaded the Actor, no need to do it again. Otherwise, load it up.
    • commit

      public void commit()
      Description copied from interface: Persister
      This method is called when the framework has concluded a series of writes that could be rolled back in case of an error.
    • rollback

      public void rollback()
      Description copied from interface: Persister
      When a series of writes should be rolled back: not written in the first place, replaced with a previous version, etc.
    • write

      public void write(String key, byte[] bytes)
      Description copied from interface: Persister
      The save method is called by the framework when an actor's state has been updated. The key provided is unique id within an actor instance. The key can be anything but by convention it is either "actor" meaning all of the scalar attributes of the actor with @Save annotation. For collections, the key is a combination of the @Save name, a dollar sign, and the key used in a map collection. For a set, the key is the unique id of the set entry, the same as used in the equals method for the set. The ActorId was provided during construction of this persister.
      Parameters:
      key -
      bytes -
    • read

      public byte[] read(String key)
      Description copied from interface: Persister
      This method is called by the framework when an actor's processMessage method is about to be called for the first time after the Actor has been instantiated.
      Parameters:
      key -