Class AbstractMetadataStore

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.ScheduledExecutorService executor  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(Notification n)  
      void close()  
      java.util.concurrent.CompletableFuture<java.lang.Void> delete​(java.lang.String path, java.util.Optional<java.lang.Long> expectedVersion)  
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteRecursive​(java.lang.String path)
      Delete a key-value pair and all the children nodes.
      void execute​(java.lang.Runnable task, java.util.concurrent.CompletableFuture<?> future)
      Run the task in the executor thread and fail the future if the executor is shutting down.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> exists​(java.lang.String path)
      Read whether a specific path exists.
      protected abstract java.util.concurrent.CompletableFuture<java.lang.Boolean> existsFromStore​(java.lang.String path)  
      java.util.concurrent.CompletableFuture<java.util.Optional<GetResult>> get​(java.lang.String path)
      Read the value of one key, identified by the path The async call will return a future that yields a GetResult that will contain the value and the associated Stat object.
      java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getChildren​(java.lang.String path)
      Return all the nodes (lexicographically sorted) that are children to the specific path.
      protected abstract java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getChildrenFromStore​(java.lang.String path)  
      <T> MetadataCache<T> getMetadataCache​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef, MetadataCacheConfig cacheConfig)
      Create a metadata cache specialized for a specific class.
      <T> MetadataCache<T> getMetadataCache​(java.lang.Class<T> clazz, MetadataCacheConfig cacheConfig)
      Create a metadata cache specialized for a specific class.
      <T> MetadataCache<T> getMetadataCache​(MetadataSerde<T> serde, MetadataCacheConfig cacheConfig)
      Create a metadata cache that uses a particular serde object.
      void invalidateAll()  
      protected void notifyParentChildrenChanged​(java.lang.String path)  
      protected static java.lang.String parent​(java.lang.String path)  
      java.util.concurrent.CompletableFuture<Stat> put​(java.lang.String path, byte[] value, java.util.Optional<java.lang.Long> expectedVersion)
      Put a new value for a given key.
      java.util.concurrent.CompletableFuture<Stat> put​(java.lang.String path, byte[] data, java.util.Optional<java.lang.Long> optExpectedVersion, java.util.EnumSet<CreateOption> options)
      Put a new value for a given key.
      protected java.util.concurrent.CompletableFuture<java.lang.Void> receivedNotification​(Notification notification)  
      protected void receivedSessionEvent​(SessionEvent event)  
      void registerListener​(java.util.function.Consumer<Notification> listener)
      Register a listener that will be called on changes in the underlying store.
      void registerSessionListener​(java.util.function.Consumer<SessionEvent> listener)
      Register a session listener that will get notified of changes in status of the current session.
      protected abstract java.util.concurrent.CompletableFuture<java.lang.Void> storeDelete​(java.lang.String path, java.util.Optional<java.lang.Long> expectedVersion)  
      protected abstract java.util.concurrent.CompletableFuture<java.util.Optional<GetResult>> storeGet​(java.lang.String path)  
      protected abstract java.util.concurrent.CompletableFuture<Stat> storePut​(java.lang.String path, byte[] data, java.util.Optional<java.lang.Long> optExpectedVersion, java.util.EnumSet<CreateOption> options)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Consumer

        andThen
    • Field Detail

      • executor

        protected final java.util.concurrent.ScheduledExecutorService executor
    • Constructor Detail

      • AbstractMetadataStore

        protected AbstractMetadataStore()
    • Method Detail

      • getChildrenFromStore

        protected abstract java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getChildrenFromStore​(java.lang.String path)
      • existsFromStore

        protected abstract java.util.concurrent.CompletableFuture<java.lang.Boolean> existsFromStore​(java.lang.String path)
      • getMetadataCache

        public <T> MetadataCache<T> getMetadataCache​(java.lang.Class<T> clazz,
                                                     MetadataCacheConfig cacheConfig)
        Description copied from interface: MetadataStore
        Create a metadata cache specialized for a specific class.
        Specified by:
        getMetadataCache in interface MetadataStore
        Parameters:
        clazz - the class type to be used for serialization/deserialization
        cacheConfig - the cache configuration to be used
        Returns:
        the metadata cache object
      • getMetadataCache

        public <T> MetadataCache<T> getMetadataCache​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef,
                                                     MetadataCacheConfig cacheConfig)
        Description copied from interface: MetadataStore
        Create a metadata cache specialized for a specific class.
        Specified by:
        getMetadataCache in interface MetadataStore
        Parameters:
        typeRef - the type ref description to be used for serialization/deserialization
        cacheConfig - the cache configuration to be used
        Returns:
        the metadata cache object
      • getMetadataCache

        public <T> MetadataCache<T> getMetadataCache​(MetadataSerde<T> serde,
                                                     MetadataCacheConfig cacheConfig)
        Description copied from interface: MetadataStore
        Create a metadata cache that uses a particular serde object.
        Specified by:
        getMetadataCache in interface MetadataStore
        Parameters:
        serde - the custom serialization/deserialization object
        cacheConfig - the cache configuration to be used
        Returns:
        the metadata cache object
      • get

        public java.util.concurrent.CompletableFuture<java.util.Optional<GetResult>> get​(java.lang.String path)
        Description copied from interface: MetadataStore
        Read the value of one key, identified by the path The async call will return a future that yields a GetResult that will contain the value and the associated Stat object. If the value is not found, the future will yield an empty Optional.
        Specified by:
        get in interface MetadataStore
        Parameters:
        path - the path of the key to get from the store
        Returns:
        a future to track the async request
      • storeGet

        protected abstract java.util.concurrent.CompletableFuture<java.util.Optional<GetResult>> storeGet​(java.lang.String path)
      • put

        public java.util.concurrent.CompletableFuture<Stat> put​(java.lang.String path,
                                                                byte[] value,
                                                                java.util.Optional<java.lang.Long> expectedVersion)
        Description copied from interface: MetadataStore
        Put a new value for a given key. The caller can specify an expected version to be atomically checked against the current version of the stored data. The future will return the Stat object associated with the newly inserted value.
        Specified by:
        put in interface MetadataStore
        Parameters:
        path - the path of the key to delete from the store
        value - the value to
        expectedVersion - if present, the version will have to match with the currently stored value for the operation to succeed. Use -1 to enforce a non-existing value.
        Returns:
        a future to track the async request
      • getChildren

        public final java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getChildren​(java.lang.String path)
        Description copied from interface: MetadataStore
        Return all the nodes (lexicographically sorted) that are children to the specific path. If the path itself does not exist, it will return an empty list.
        Specified by:
        getChildren in interface MetadataStore
        Parameters:
        path - the path of the key to get from the store
        Returns:
        a future to track the async request
      • exists

        public final java.util.concurrent.CompletableFuture<java.lang.Boolean> exists​(java.lang.String path)
        Description copied from interface: MetadataStore
        Read whether a specific path exists. Note: In case of keys with multiple levels (eg: '/a/b/c'), checking the existence of a parent (eg. '/a') might not necessarily return true, unless the key had been explicitly created.
        Specified by:
        exists in interface MetadataStore
        Parameters:
        path - the path of the key to check on the store
        Returns:
        a future to track the async request
      • registerListener

        public void registerListener​(java.util.function.Consumer<Notification> listener)
        Description copied from interface: MetadataStore
        Register a listener that will be called on changes in the underlying store.
        Specified by:
        registerListener in interface MetadataStore
        Parameters:
        listener - a consumer of notifications
      • receivedNotification

        protected java.util.concurrent.CompletableFuture<java.lang.Void> receivedNotification​(Notification notification)
      • accept

        public void accept​(Notification n)
        Specified by:
        accept in interface java.util.function.Consumer<Notification>
      • storeDelete

        protected abstract java.util.concurrent.CompletableFuture<java.lang.Void> storeDelete​(java.lang.String path,
                                                                                              java.util.Optional<java.lang.Long> expectedVersion)
      • delete

        public final java.util.concurrent.CompletableFuture<java.lang.Void> delete​(java.lang.String path,
                                                                                   java.util.Optional<java.lang.Long> expectedVersion)
        Specified by:
        delete in interface MetadataStore
        Parameters:
        path - the path of the key to delete from the store
        expectedVersion - if present, the version will have to match with the currently stored value for the operation to succeed
        Returns:
        a future to track the async request
      • deleteRecursive

        public java.util.concurrent.CompletableFuture<java.lang.Void> deleteRecursive​(java.lang.String path)
        Description copied from interface: MetadataStore
        Delete a key-value pair and all the children nodes. Note: the operation might not be carried in an atomic fashion. If the operation fails, the deletion of the tree might be only partial.
        Specified by:
        deleteRecursive in interface MetadataStore
        Parameters:
        path - the path of the key to delete from the store
        Returns:
        a future to track the async request
      • storePut

        protected abstract java.util.concurrent.CompletableFuture<Stat> storePut​(java.lang.String path,
                                                                                 byte[] data,
                                                                                 java.util.Optional<java.lang.Long> optExpectedVersion,
                                                                                 java.util.EnumSet<CreateOption> options)
      • put

        public final java.util.concurrent.CompletableFuture<Stat> put​(java.lang.String path,
                                                                      byte[] data,
                                                                      java.util.Optional<java.lang.Long> optExpectedVersion,
                                                                      java.util.EnumSet<CreateOption> options)
        Description copied from interface: MetadataStoreExtended
        Put a new value for a given key. The caller can specify an expected version to be atomically checked against the current version of the stored data. The future will return the Stat object associated with the newly inserted value.
        Specified by:
        put in interface MetadataStoreExtended
        Parameters:
        path - the path of the key to delete from the store
        data - the value to
        optExpectedVersion - if present, the version will have to match with the currently stored value for the operation to succeed. Use -1 to enforce a non-existing value.
        options - a set of CreateOption to use if the the key-value pair is being created
        Returns:
        a future to track the async request
      • registerSessionListener

        public void registerSessionListener​(java.util.function.Consumer<SessionEvent> listener)
        Description copied from interface: MetadataStoreExtended
        Register a session listener that will get notified of changes in status of the current session.
        Specified by:
        registerSessionListener in interface MetadataStoreExtended
        Parameters:
        listener - the session listener
      • receivedSessionEvent

        protected void receivedSessionEvent​(SessionEvent event)
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • invalidateAll

        public void invalidateAll()
      • execute

        public void execute​(java.lang.Runnable task,
                            java.util.concurrent.CompletableFuture<?> future)
        Run the task in the executor thread and fail the future if the executor is shutting down.
      • parent

        protected static java.lang.String parent​(java.lang.String path)
      • notifyParentChildrenChanged

        protected void notifyParentChildrenChanged​(java.lang.String path)