接口 BaseContext

  • 所有已知子接口:
    Context

    @Public
    @Stable
    public interface BaseContext
    BaseContext provides base contextual information to the executing function/source/sink. It allows to propagate information, such as pulsar environment, logs, metrics, states etc.
    • 方法概要

      所有方法 实例方法 抽象方法 默认方法 
      修饰符和类型 方法 说明
      void deleteState​(java.lang.String key)
      Delete the state value for the key.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteStateAsync​(java.lang.String key)
      Delete the state value for the key, but don't wait for the operation to be completed
      long getCounter​(java.lang.String key)
      Retrieve the counter value for the key.
      java.util.concurrent.CompletableFuture<java.lang.Long> getCounterAsync​(java.lang.String key)
      Retrieve the counter value for the key, but don't wait for the operation to be completed
      int getInstanceId()
      The id of the instance that invokes this component.
      org.slf4j.Logger getLogger()
      The logger object that can be used to log in a component.
      java.lang.String getNamespace()
      The namespace this component belongs to.
      int getNumInstances()
      Get the number of instances that invoke this component.
      java.lang.String getSecret​(java.lang.String secretName)
      Get the secret associated with this key.
      java.nio.ByteBuffer getState​(java.lang.String key)
      Retrieve the state value for the key.
      java.util.concurrent.CompletableFuture<java.nio.ByteBuffer> getStateAsync​(java.lang.String key)
      Retrieve the state value for the key, but don't wait for the operation to be completed
      default <S extends StateStore>
      S
      getStateStore​(java.lang.String name)
      Get the state store with the provided store name in the tenant & namespace.
      default <S extends StateStore>
      S
      getStateStore​(java.lang.String tenant, java.lang.String ns, java.lang.String name)
      Get the state store with the provided store name.
      java.lang.String getTenant()
      The tenant this component belongs to.
      void incrCounter​(java.lang.String key, long amount)
      Increment the builtin distributed counter referred by key.
      java.util.concurrent.CompletableFuture<java.lang.Void> incrCounterAsync​(java.lang.String key, long amount)
      Increment the builtin distributed counter referred by key but dont wait for the completion of the increment operation
      void putState​(java.lang.String key, java.nio.ByteBuffer value)
      Update the state value for the key.
      java.util.concurrent.CompletableFuture<java.lang.Void> putStateAsync​(java.lang.String key, java.nio.ByteBuffer value)
      Update the state value for the key, but don't wait for the operation to be completed
      void recordMetric​(java.lang.String metricName, double value)
      Record a user defined metric
    • 方法详细资料

      • getTenant

        java.lang.String getTenant()
        The tenant this component belongs to.
        返回:
        the tenant this component belongs to
      • getNamespace

        java.lang.String getNamespace()
        The namespace this component belongs to.
        返回:
        the namespace this component belongs to
      • getInstanceId

        int getInstanceId()
        The id of the instance that invokes this component.
        返回:
        the instance id
      • getNumInstances

        int getNumInstances()
        Get the number of instances that invoke this component.
        返回:
        the number of instances that invoke this component.
      • getLogger

        org.slf4j.Logger getLogger()
        The logger object that can be used to log in a component.
        返回:
        the logger object
      • getSecret

        java.lang.String getSecret​(java.lang.String secretName)
        Get the secret associated with this key.
        参数:
        secretName - The name of the secret
        返回:
        The secret if anything was found or null
      • getStateStore

        default <S extends StateStore> S getStateStore​(java.lang.String name)
        Get the state store with the provided store name in the tenant & namespace.
        类型参数:
        S - the type of interface of the store to return
        参数:
        name - the state store name
        返回:
        the state store instance.
        抛出:
        java.lang.ClassCastException - if the return type isn't a type or interface of the actual returned store.
      • getStateStore

        default <S extends StateStore> S getStateStore​(java.lang.String tenant,
                                                       java.lang.String ns,
                                                       java.lang.String name)
        Get the state store with the provided store name.
        类型参数:
        S - the type of interface of the store to return
        参数:
        tenant - the state tenant name
        ns - the state namespace name
        name - the state store name
        返回:
        the state store instance.
        抛出:
        java.lang.ClassCastException - if the return type isn't a type or interface of the actual returned store.
      • putState

        void putState​(java.lang.String key,
                      java.nio.ByteBuffer value)
        Update the state value for the key.
        参数:
        key - name of the key
        value - state value of the key
      • putStateAsync

        java.util.concurrent.CompletableFuture<java.lang.Void> putStateAsync​(java.lang.String key,
                                                                             java.nio.ByteBuffer value)
        Update the state value for the key, but don't wait for the operation to be completed
        参数:
        key - name of the key
        value - state value of the key
      • getState

        java.nio.ByteBuffer getState​(java.lang.String key)
        Retrieve the state value for the key.
        参数:
        key - name of the key
        返回:
        the state value for the key.
      • getStateAsync

        java.util.concurrent.CompletableFuture<java.nio.ByteBuffer> getStateAsync​(java.lang.String key)
        Retrieve the state value for the key, but don't wait for the operation to be completed
        参数:
        key - name of the key
        返回:
        the state value for the key.
      • deleteState

        void deleteState​(java.lang.String key)
        Delete the state value for the key.
        参数:
        key - name of the key
      • deleteStateAsync

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteStateAsync​(java.lang.String key)
        Delete the state value for the key, but don't wait for the operation to be completed
        参数:
        key - name of the key
      • incrCounter

        void incrCounter​(java.lang.String key,
                         long amount)
        Increment the builtin distributed counter referred by key.
        参数:
        key - The name of the key
        amount - The amount to be incremented
      • incrCounterAsync

        java.util.concurrent.CompletableFuture<java.lang.Void> incrCounterAsync​(java.lang.String key,
                                                                                long amount)
        Increment the builtin distributed counter referred by key but dont wait for the completion of the increment operation
        参数:
        key - The name of the key
        amount - The amount to be incremented
      • getCounter

        long getCounter​(java.lang.String key)
        Retrieve the counter value for the key.
        参数:
        key - name of the key
        返回:
        the amount of the counter value for this key
      • getCounterAsync

        java.util.concurrent.CompletableFuture<java.lang.Long> getCounterAsync​(java.lang.String key)
        Retrieve the counter value for the key, but don't wait for the operation to be completed
        参数:
        key - name of the key
        返回:
        the amount of the counter value for this key
      • recordMetric

        void recordMetric​(java.lang.String metricName,
                          double value)
        Record a user defined metric
        参数:
        metricName - The name of the metric
        value - The value of the metric