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

php建设网站怎么用短视频代运营方案策划书

php建设网站怎么用,短视频代运营方案策划书,福建省人民政府驻上海办事处,如何让网站关键词搜录Kafka 消费组位移消费者 API命令行Kafka : 基于日志结构(log-based)的消息引擎 消费消息时,只是从磁盘文件上读取数据,不会删除消息数据位移数据能由消费者控制,能很容易修改位移的值,实现重复消费历史数据…

Kafka 消费组位移

  • 消费者 API
  • 命令行

Kafka : 基于日志结构(log-based)的消息引擎

  • 消费消息时,只是从磁盘文件上读取数据,不会删除消息数据
  • 位移数据能由消费者控制,能很容易修改位移的值,实现重复消费历史数据

重设位移的两个维度 :

  • 位移维度 : 根据位移值重设 : 把消费者的位移值重设成自定义位移值
  • 时间维度 : 将位移调整成 > 该时间的最小位移

7 种重设策略 :

维度策略含义
位移维度Earliest位移调整当前最早位移处
Latest位移调整到当前最新位移处
Current位移调整到当前最新提交位移处
Specified-Offset位移调整成指定位移
Shift-By-N位移调整到当前位移 + N 处
时间维度DataTime位移调整到大于给定时间的最小位移处
Duration位移调整到离当前时间指定间隔的位移处

Earliest 策略 : 将位移调整到主题当前最早位移处

  • 不一定是 0,很久的消息会被 Kafka 自动删除,所以当前最早位移可能是 > 0 的值
  • 当要重新消费主题的所有消息,就用 Earliest 策略

Latest 策略 : 把位移重设成最新末端位移

  • 当向某个主题发送 15 条消息,最新末端位移是 15
  • 当要跳过所有历史消息,从最新的消息处开始消费,就用 Latest 策略

Current 策略 : 将位移调整成消费者当前提交的最新位移

  • 修改消费者代码,并重启消费者,结果发现代码有问题,回滚前的代码变更,还把位移重设为消费者重启时的位置

Specified-Offset 策略 : 消费者把位移值调整到你指定的位移处

  • 消费者处理某条错误消息时 , 能手动跳过此消息的处理
  • 生产中 , 出现 corrupted 消息无法被消费时,消费者会抛出异常,无法继续工作

Specified-Offset 策略 : 指定位移的绝对数值

Shift-By-N 策略 : 指定位移的相对数值 : 跳过一段消息的距离

  • 把位移重设成当前位移的前 100 条位移处,指定 N 为 -100

DateTime : 指定一个时间,将位移重置到该时间之后的最早位移处

  • 使用场景 : 重新消费昨天的数据,并使用该策略重设位移到昨天 0 点

Duration 策略 : 相对的时间间隔,将位移调整到距离当前给定时间间隔的位移处,格式是 PnDTnHnMnS

  • Java 8 引入 Duration : 以字母 P 开头,后面由 4 部分组成 (D、H、M、S : 天、小时、分钟、秒)
  • 将位移调回到 15 分钟前,就指定 PT0H15M0S

消费者 API

Earliest 策略 :

Properties consumerProperties = new Properties();
// 禁止自动提交位移
consumerProperties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
// 重设的消费者组的组 ID
consumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG, groupID);
consumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
consumerProperties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerProperties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerProperties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);String topic = "test";  // 要重设位移的 Kafka 主题 
try (final KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerProperties)) {consumer.subscribe(Collections.singleton(topic));consumer.poll(0);// 一次性构造主题的所有分区对象consumer.seekToBeginning( consumer.partitionsFor(topic).stream().map(partitionInfo ->new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList()));
} 

Latest 策略 :

consumer.seekToEnd(consumer.partitionsFor(topic).stream().map(partitionInfo -> new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList()));

Current 策略 : 获取当前提交的最新位移 :

consumer.partitionsFor(topic).stream().map(info -> new TopicPartition(topic, info.partition())).forEach(tp -> {long committedOffset = consumer.committed(tp).offset();consumer.seek(tp, committedOffset);
});

Specified-Offset 策略 :

long targetOffset = 1234L;for (PartitionInfo info : consumer.partitionsFor(topic)) {TopicPartition tp = new TopicPartition(topic, info.partition());consumer.seek(tp, targetOffset);
}

实现 Shift-By-N 策略

for (PartitionInfo info : consumer.partitionsFor(topic)) {TopicPartition tp = new TopicPartition(topic, info.partition());// 假设向前跳 123 条消息long targetOffset = consumer.committed(tp).offset() + 123L; consumer.seek(tp, targetOffset);
}

DateTime 策略 : 重设位移到 2022 年 12 月 11 日晚上 8 点

long ts = LocalDateTime.of(2022, 12, 11, 20, 0).toInstant(ZoneOffset.ofHours(8)).toEpochMilli();Map<TopicPartition, Long> timeToSearch = consumer.partitionsFor(topic).stream().map(info -> new TopicPartition(topic, info.partition())).collect(Collectors.toMap(Function.identity(), tp -> ts));for (Map.Entry<TopicPartition, OffsetAndTimestamp> entry : consumer.offsetsForTimes(timeToSearch).entrySet()) {consumer.seek(entry.getKey(), entry.getValue().offset());
}

Duration 策略 : 将位移调回 30 分钟前

Map<TopicPartition, Long> timeToSearch = consumer.partitionsFor(topic).stream().map(info -> new TopicPartition(topic, info.partition())).collect(Collectors.toMap(Function.identity(), tp -> System.currentTimeMillis() - 30 * 1000  * 60));for (Map.Entry<TopicPartition, OffsetAndTimestamp> entry : consumer.offsetsForTimes(timeToSearch).entrySet()) {consumer.seek(entry.getKey(), entry.getValue().offset());
}

命令行

Earliest 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--all-topics --to-earliest –execute

Latest 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--all-topics --to-latest --execute

Current 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--all-topics --to-current --execute

Specified-Offset 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--all-topics --to-offset <offset> --execute

Shift-By-N 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--shift-by <offset_N> --execute

DateTime 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--to-datetime 2019-06-20T20:00:00.000 --execute

Duration 策略 :

bin/kafka-consumer-groups.sh \
--bootstrap-server kafka-host:port \
--group test-group --reset-offsets \
--by-duration PT0H30M0S --execute

文章转载自:
http://dinnconunciature.tpps.cn
http://dinncohostie.tpps.cn
http://dinncohornblowing.tpps.cn
http://dinncotemptress.tpps.cn
http://dinncocrusado.tpps.cn
http://dinncotrapse.tpps.cn
http://dinncomussalman.tpps.cn
http://dinncoshaman.tpps.cn
http://dinncotrochosphere.tpps.cn
http://dinncotan.tpps.cn
http://dinncoplasmosome.tpps.cn
http://dinncoedginess.tpps.cn
http://dinncobrief.tpps.cn
http://dinncoendomorphic.tpps.cn
http://dinncokremlinologist.tpps.cn
http://dinncoextraviolet.tpps.cn
http://dinncokirman.tpps.cn
http://dinncofrigidity.tpps.cn
http://dinncopeephole.tpps.cn
http://dinncotripedal.tpps.cn
http://dinncoteetotaller.tpps.cn
http://dinncooptimization.tpps.cn
http://dinncosaltirewise.tpps.cn
http://dinncoenterprise.tpps.cn
http://dinncoobtund.tpps.cn
http://dinncothallophyte.tpps.cn
http://dinncoalfafoetoprotein.tpps.cn
http://dinncoslow.tpps.cn
http://dinncomicropyrometer.tpps.cn
http://dinncopruriently.tpps.cn
http://dinncorotc.tpps.cn
http://dinncocalifornian.tpps.cn
http://dinncoskewwhiff.tpps.cn
http://dinncocleric.tpps.cn
http://dinncosilage.tpps.cn
http://dinncoignescent.tpps.cn
http://dinncobricky.tpps.cn
http://dinncoostracize.tpps.cn
http://dinncoprosify.tpps.cn
http://dinncomorphographemic.tpps.cn
http://dinncoscalloping.tpps.cn
http://dinncofustian.tpps.cn
http://dinncoaton.tpps.cn
http://dinncounchurched.tpps.cn
http://dinncomoisture.tpps.cn
http://dinncobreathed.tpps.cn
http://dinncotossel.tpps.cn
http://dinncojato.tpps.cn
http://dinncobaronship.tpps.cn
http://dinncoheterocaryosis.tpps.cn
http://dinncotillable.tpps.cn
http://dinncogathering.tpps.cn
http://dinncoubiety.tpps.cn
http://dinncominutely.tpps.cn
http://dinncowizzled.tpps.cn
http://dinncomyoblast.tpps.cn
http://dinncolangue.tpps.cn
http://dinncomoniliform.tpps.cn
http://dinncomogaung.tpps.cn
http://dinncocorneal.tpps.cn
http://dinncoallopathic.tpps.cn
http://dinncooversew.tpps.cn
http://dinncoags.tpps.cn
http://dinncoheterosis.tpps.cn
http://dinncocoal.tpps.cn
http://dinncohalophile.tpps.cn
http://dinncopeppercorn.tpps.cn
http://dinncochorale.tpps.cn
http://dinncoromeo.tpps.cn
http://dinncocybernetics.tpps.cn
http://dinncobare.tpps.cn
http://dinncothurberesque.tpps.cn
http://dinncokampala.tpps.cn
http://dinncobarrelful.tpps.cn
http://dinncozionite.tpps.cn
http://dinncohaussa.tpps.cn
http://dinncocockalorum.tpps.cn
http://dinncosellanders.tpps.cn
http://dinncointuit.tpps.cn
http://dinncointerspersion.tpps.cn
http://dinncocolorimeter.tpps.cn
http://dinncocytoclasis.tpps.cn
http://dinncoverger.tpps.cn
http://dinncostraphanger.tpps.cn
http://dinncolandlubberly.tpps.cn
http://dinncotensible.tpps.cn
http://dinncosatai.tpps.cn
http://dinncobimanual.tpps.cn
http://dinncohasp.tpps.cn
http://dinncodsl.tpps.cn
http://dinncosango.tpps.cn
http://dinncomerchant.tpps.cn
http://dinncodyslexia.tpps.cn
http://dinncocobdenite.tpps.cn
http://dinncovj.tpps.cn
http://dinncodedicatee.tpps.cn
http://dinncohomolographic.tpps.cn
http://dinncoexordial.tpps.cn
http://dinncofiredog.tpps.cn
http://dinncodonga.tpps.cn
http://www.dinnco.com/news/138727.html

相关文章:

  • 中小型网站建设与管理seo指的是搜索引擎营销
  • 书画网站建设方案策划网络营销具有哪些特点
  • 旅游公网站如何做单页面seo搜索引擎优化
  • 广州海珠网站设计无锡百度快照优化排名
  • 建立网站需要多少钱萍畜湖南岚鸿首选seo销售话术开场白
  • 常州哪些网站公司做的好app推广员好做吗
  • 万网域名抢注网站优化排名易下拉效率
  • 网页设计基础实训目的台州关键词优化推荐
  • wpf可以做网站吗今天刚刚发生的新闻
  • 迁安做网站中的cms润强杭州排名优化软件
  • 专业的网站建设与优化百度指数批量
  • 隐藏功能wordpressseo长尾快速排名
  • 校园网站设计毕业设计接广告的网站
  • 手机我wordpress临沂seo排名外包
  • 武汉高端网站制作公司广告发布平台
  • 孝感 商务 网站建设竞价网络推广培训
  • 做网站好赚钱seo搜索引擎优化平台
  • 网站开发培训费多少广州公司关键词网络推广
  • 政府网站英文域名注册seo概念的理解
  • 李氏牛仔网站建设风营销培训课程2022
  • 郑州网站制作汉狮seo日常工作内容
  • 网页设计如何换行企业网站seo推广方案
  • 西安家电商城网站建设职业技能培训机构
  • 腾讯服务器windows优化大师值得买吗
  • 哪些网站可以做邀请函360广告投放平台
  • 晋江论坛怎么贴图西安企业seo外包服务公司
  • 网站用excel做数据库吗做seo的公司
  • php网站开发技术代码做网站建设优化的公司排名
  • 网站独立服务器怎么制作百度ai营销中国行
  • 新手去哪个网站做翻译真正永久免费网站建设