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

学生求职网站的需求分析怎么做个人网页背景图片

学生求职网站的需求分析怎么做,个人网页背景图片,网站建设电话着么打,怎么设计图片文章目录 1. Partitioner分区器2. 自定义分区器3. RecordAccumulator数据收集器 1. Partitioner分区器 clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#xff0c;中doSend方法#xff0c;记录了生产者将消息发送的流程#xff0c;其中有一步… 文章目录 1. Partitioner分区器2. 自定义分区器3. RecordAccumulator数据收集器 1. Partitioner分区器 clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java中doSend方法记录了生产者将消息发送的流程其中有一步就是计算当前消息应该发送往对应Topic哪一个分区 int partition partition(record, serializedKey, serializedValue, cluster);private final Partitioner partitioner;private int partition(ProducerRecordK, V record, byte[] serializedKey, byte[] serializedValue, Cluster cluster) {//当record的分区已存在则直接返回这对应了创建Record时可以手动传入partition参数if (record.partition() ! null)return record.partition();// 如果存在partitioner分区器则使用Partitioner.partition方法计算分区数据if (partitioner ! null) {int customPartition partitioner.partition(record.topic(), record.key(), serializedKey, record.value(), serializedValue, cluster);if (customPartition 0) {throw new IllegalArgumentException(String.format(The partitioner generated an invalid partition number: %d. Partition number should always be non-negative., customPartition));}return customPartition;}// 如果没有分区器的情况if (serializedKey ! null !partitionerIgnoreKeys) {// hash the keyBytes to choose a partitionreturn BuiltInPartitioner.partitionForKey(serializedKey, cluster.partitionsForTopic(record.topic()).size());} else {return RecordMetadata.UNKNOWN_PARTITION;}}// 利用键的哈希值来选择分区 public static int partitionForKey(final byte[] serializedKey, final int numPartitions) {return Utils.toPositive(Utils.murmur2(serializedKey)) % numPartitions;}2. 自定义分区器 新建类实现Partitioner接口key是字符串数字奇数送到分区0偶数送到分区1 。 public class MyKafkaPartitioner implements Partitioner {Overridepublic int partition(String s, Object key, byte[] bytes, Object o1, byte[] bytes1, Cluster cluster) {// Ensure the key is a non-null stringif (key null || !(key instanceof String)) {throw new IllegalArgumentException(Key must be a non-null String);}// Parse the key as an integerint keyInt;try {keyInt Integer.parseInt((String) key);} catch (NumberFormatException e) {throw new IllegalArgumentException(Key must be a numeric string, e);}// Determine the partition based on the keys odd/even natureif (keyInt % 2 0) {return 1; // Even keys go to partition 2} else {return 0; // Odd keys go to partition 0}}Overridepublic void close() {}Overridepublic void configure(MapString, ? map) {} }新建一个存在多分区的Topic。 public class KafkaProducerPartitionorTest {public static void main(String[] args) throws InterruptedException {//创建producerHashMapString, Object config new HashMap();config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, localhost:19092);config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());//指定拦截器config.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, ValueInterceptorTest.class.getName());//指定分区器config.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, MyKafkaPartitioner.class.getName());KafkaProducerString, String producer new KafkaProducerString, String(config);for (int i 0; i 10; i) {//创建recordProducerRecordString, String record new ProducerRecordString, String(test1,keyi,我是你爹i);//发送recordproducer.send(record);Thread.sleep(500);}//关闭producerproducer.close();} }配置好PARTITIONER_CLASS_CONFIG后发送消息。 可以分区器成功起作用了。 3. RecordAccumulator数据收集器 通过数据校验后数据从分区器来到数据收集器。 数据收集器的工作机制 队列缓存RecordAccumulator为每个分区维护一个队列。默认情况下每个队列的批次大小buffer size是16KB这个大小可以通过配置参数batch.size来调整。 缓冲区管理 每个分区都有一个或多个批次每个批次包含多条消息。当一个批次填满即达到batch.size或者达到发送条件如linger.ms时间窗口即发送消息前等待的时间时批次会被标记为可发送状态并被传递给Sender线程。 满批次处理 当某个分区的队列中的某个批次大小超过了16KB默认值或满足linger.ms的时间条件RecordAccumulator会将该批次加入到一个待发送的队列中。Sender线程会从待发送队列中获取这些满批次并将其发送到Kafka集群。
http://www.hkea.cn/news/14268359/

相关文章:

  • 制作 网站 盈利flash同视频做网站
  • 当地建设局网站营销型和展示型网站
  • 重庆市建设岗培中心网站网站建设费用说明
  • 重庆建设网官网深圳债务优化公司
  • 电商网站开发设计文档wordpress 调用导航栏
  • wordpress站群做京挑客的网站有哪些
  • 建网站义乌外贸网站推广优化
  • 五大类型网站输入文字生成图片app
  • 浙江省住房和城乡建设厅网站查询wordpress personal主题
  • 网站开发应如何入账网站后台管理的超链接怎么做
  • 永清县建设局网站网上哪里可以注册公司
  • 安徽做网站哪家好seo入门书籍推荐
  • 安徽省建设干校网站做商品网站数据库有哪些内容
  • 网站设计创意方案郫都区规划建设局网站
  • 网站集约化后如何建设网站负责人核验照
  • 车牌照损坏在网站做的能用吗开发公司竣工员工奖励计划
  • 手机网站有什么不同某企业集团网站建设方案论文
  • 免费网站如何赚钱西安口碑较好的财务公司
  • 新闻文章网站源码中国十大证券公司排名
  • wordpress注册提示404新网站怎么做seo 风享
  • 淮安新港建设有限公司网站免费做代理
  • 河北邯郸手机网站建设时事新闻2022最新10月
  • 南宁市优化网站公司曲周网站建设
  • 湘西建设监理协会网站手机制作ppt
  • 怎么修改自己的网站品牌设计公司介绍
  • 河南省工程建设业协会网站绥化建设网站
  • wordpress自带功能大连seo外包
  • 中英 网站模板 带手机版定制一个企业网站多少钱
  • 湛江网站制作推广做网站要通过网信办备案吗
  • 2013影响网站百度搜索排名的关键因素统计win2008 r2 搭建网站