当前位置: 首页 > news >正文

网页制作与网站建设实战教程视频教程云南建设学院的网站

网页制作与网站建设实战教程视频教程,云南建设学院的网站,建设银行网站怎么取消短信服务,搜狗收录提交入口网址背景 算子的联合列表状态是平时使用的比较少的一种状态,本文通过kafka的消费者实现来看一下怎么使用算子列表联合状态 算子联合列表状态 首先我们看一下算子联合列表状态的在进行故障恢复或者从某个保存点进行扩缩容启动应用时状态的恢复情况 算子联合列表状态主…

背景

算子的联合列表状态是平时使用的比较少的一种状态,本文通过kafka的消费者实现来看一下怎么使用算子列表联合状态

算子联合列表状态

首先我们看一下算子联合列表状态的在进行故障恢复或者从某个保存点进行扩缩容启动应用时状态的恢复情况
在这里插入图片描述
算子联合列表状态主要由这两个方法处理:
1初始化方法

public final void initializeState(FunctionInitializationContext context) throws Exception {OperatorStateStore stateStore = context.getOperatorStateStore();// 在初始化方法中获取联合列表状态this.unionOffsetStates =stateStore.getUnionListState(new ListStateDescriptor<>(OFFSETS_STATE_NAME,createStateSerializer(getRuntimeContext().getExecutionConfig())));if (context.isRestored()) {restoredState = new TreeMap<>(new KafkaTopicPartition.Comparator());
// 把联合列表状态的数据都恢复成类的本地变量中// populate actual holder for restored statefor (Tuple2<KafkaTopicPartition, Long> kafkaOffset : unionOffsetStates.get()) {restoredState.put(kafkaOffset.f0, kafkaOffset.f1);}LOG.info("Consumer subtask {} restored state: {}.",getRuntimeContext().getIndexOfThisSubtask(),restoredState);} else {LOG.info("Consumer subtask {} has no restore state.",getRuntimeContext().getIndexOfThisSubtask());}}

2.开始通知检查点开始的方法:

public final void snapshotState(FunctionSnapshotContext context) throws Exception {if (!running) {LOG.debug("snapshotState() called on closed source");} else {unionOffsetStates.clear();final AbstractFetcher<?, ?> fetcher = this.kafkaFetcher;if (fetcher == null) {// the fetcher has not yet been initialized, which means we need to return the// originally restored offsets or the assigned partitionsfor (Map.Entry<KafkaTopicPartition, Long> subscribedPartition :subscribedPartitionsToStartOffsets.entrySet()) {// 进行checkpoint时,把数据保存到联合列表状态中进行保存unionOffsetStates.add(Tuple2.of(subscribedPartition.getKey(), subscribedPartition.getValue()));}if (offsetCommitMode == OffsetCommitMode.ON_CHECKPOINTS) {// the map cannot be asynchronously updated, because only one checkpoint call// can happen// on this function at a time: either snapshotState() or// notifyCheckpointComplete()pendingOffsetsToCommit.put(context.getCheckpointId(), restoredState);}} else {HashMap<KafkaTopicPartition, Long> currentOffsets = fetcher.snapshotCurrentState();if (offsetCommitMode == OffsetCommitMode.ON_CHECKPOINTS) {// the map cannot be asynchronously updated, because only one checkpoint call// can happen// on this function at a time: either snapshotState() or// notifyCheckpointComplete()pendingOffsetsToCommit.put(context.getCheckpointId(), currentOffsets);}for (Map.Entry<KafkaTopicPartition, Long> kafkaTopicPartitionLongEntry :currentOffsets.entrySet()) {unionOffsetStates.add(Tuple2.of(kafkaTopicPartitionLongEntry.getKey(),kafkaTopicPartitionLongEntry.getValue()));}}if (offsetCommitMode == OffsetCommitMode.ON_CHECKPOINTS) {// truncate the map of pending offsets to commit, to prevent infinite growthwhile (pendingOffsetsToCommit.size() > MAX_NUM_PENDING_CHECKPOINTS) {pendingOffsetsToCommit.remove(0);}}}}
http://www.yayakq.cn/news/502362/

相关文章:

  • 优惠券领取网站开发百度搜索引擎使用技巧
  • 注册域名成功后怎样建设网站泰安人才网广纳英才招聘信息
  • 爱ppt网站百度健康
  • 网站目录在哪免费的ppt模板下载网站有哪些
  • 网站打不开 域名做解析如何设置网站关键词
  • 四川华海建设集团有限公司网站佛山手机网站建设
  • 建设专业网站哪家比较好蚁坊软件舆情监测系统
  • 网站开发工资一般多少深圳网站开发antnw
  • 网站开发详细设计文档模板黑马程序员培训费用
  • 制作注册会员的网站科技赋能千年残像
  • 自助建设影视网站前端 模板 网站
  • 网站的展现形式WordPress购物按钮
  • 线在科技成都网站推广公司重庆seo技术博客
  • 单个页面的网站mvc5网站开发用户注册
  • 永康公司网站开发怎么设计页面
  • 网站界面风格网络服务提供者无正当理由拒绝提供或者拖延
  • 博客网站建设设计论文总结优化绿松石是什么意思
  • 网站设计作品案例讲解网站建设产品编辑的工作内容
  • 长沙做网站哪个最好网页制作模板怎么做
  • 优化网站的目的wordpress 适合外贸站
  • 企业网站管理制度建设响应式表白网站源码
  • 想把自己做的网站放到网上沧州到黄骅
  • wordpress 建视频网站吗昆明网络营销线上广告
  • 简约手机网站源码小型企业网络配置实例
  • 家具网站怎么做太原市建设局网站
  • 发布程序后网站有很多网页翻译软件哪个好
  • 网站平台建设的流程wordpress通过标题调用相关文章
  • 如何做网站网站的教程wordpress 插件语言包
  • 网站备案幕布多少钱淘宝网站开发
  • 遵义网站建设制作商标网官网