Interface SequencerService<T extends SequencerService.Token>

  • All Known Implementing Classes:
    SemaphoreSequencer

    public interface SequencerService<T extends SequencerService.Token>
    A general service to sequence potentially concurrent modifications using a key (e.g. a resource path) to ensure that only one thread makes modifications in the context of the key at a time.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  SequencerService.Token  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T acquire​(@NotNull String key)
      Ensures the exclusiveness regarding the 'key' bind to the returned token.
      void release​(T token)
      Stops the exclusive access to the 'key' encapsulated in the token which was generated by the corresponding 'acquire()'.
    • Method Detail

      • acquire

        @NotNull
        T acquire​(@NotNull
                  @NotNull String key)
        Ensures the exclusiveness regarding the 'key' bind to the returned token. Remember to use this in a try finally with release(Token).
        Returns:
        the token which is necessary to release the binding
        Throws:
        IllegalStateException - if we could not acquire the lock for one hour - there must be something broken.
      • release

        void release​(@NotNull
                     T token)
        Stops the exclusive access to the 'key' encapsulated in the token which was generated by the corresponding 'acquire()'. Must be called after a successful acquire(String), and the Token must be discarded afterwards.