启用有状态函数
note
当需要Pulsar Functions的有状态API时——例如,putState()和queryState()相关的接口——你需要在函数工作者中启用有状态函数功能。
要在函数工作者中启用有状态函数功能,请完成以下步骤。
-
在BookKeeper中启用
streamStorage服务。 目前,该服务使用NAR包,因此您需要在conf/bookkeeper.conf文件中设置配置。##################################################################
##################################################################
# Settings below are used by stream/table service
##################################################################
##################################################################
### Grpc Server ###
# the grpc server port to listen on. default is 4181
storageserver.grpc.port=4181
### Dlog Settings for table service ###
#### Replication Settings
dlog.bkcEnsembleSize=3
dlog.bkcWriteQuorumSize=2
dlog.bkcAckQuorumSize=2
### Storage ###
# local storage directories for storing table ranges data (e.g. rocksdb sst files)
storage.range.store.dirs=data/bookkeeper/ranges
# whether the storage server capable of serving readonly tables. default is false.
storage.serve.readonly.tables=false
# the cluster controller schedule interval, in milliseconds. default is 30 seconds.
storage.cluster.controller.schedule.interval.ms=30000 -
启动bookie后,使用以下方法检查
streamStorage服务是否已成功启动。-
输入:
telnet localhost 4181 -
输出:
正在尝试 127.0.0.1...
已连接到本地主机。
转义字符是 '^]'.
-
-
在
conf/functions_worker.yml文件中配置stateStorageServiceUrl。bk-service-url是指向BookKeeper表服务的服务URL。stateStorageServiceUrl: bk://<bk-service-url>:4181