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

国家示范建设成果网站全国职业生涯规划大赛

国家示范建设成果网站,全国职业生涯规划大赛,自动生成logo的网站,外贸网站搭建用哪个平台比较好CommitLog ~ MappedFileQueue ~ MappedFile集合 正常情况下#xff0c;RocketMQ支持消息体字节数最多为1个G。注意该消息体并不单单是消息体body。如果生产的消息其字节数超过1个G则该消息是无法被落盘处理的。因为没有一个MapperFile文件可以承载该消息所有的字节数。 1.All…CommitLog ~ MappedFileQueue ~ MappedFile集合 正常情况下RocketMQ支持消息体字节数最多为1个G。注意该消息体并不单单是消息体body。如果生产的消息其字节数超过1个G则该消息是无法被落盘处理的。因为没有一个MapperFile文件可以承载该消息所有的字节数。 1.AllocateMappedFileService 参考文章 异步初始化CommitLog文件时优先初始化nextFilePath、nextNextFilePath两个文件。 同时创建nextFilePath【/data/rocketmq/commitlog/00000000000000000000】、nextNextFilePath【/data/rocketmq/commitlog/00000000000000000050】两个文件是如何使用的呢 优先返回nextFilePath并添加到MappedFileQueue集合属性mappedFiles中。此时队列requestQueue为空。requestTable集合元素为nextNextFilePath【/data/rocketmq/commitlog/00000000000000000050】。如果消息体的长度没有达到当前MapperFile中字节缓冲区capacity的大小则不会创建新的MapperFile文件。如果步骤2不成立则创建新的nextFilePath【/data/rocketmq/commitlog/00000000000000000050】、nextNextFilePath【/data/rocketmq/commitlog/00000000000000000100】对应的MapperFile文件。但是由于requestTable集合不为空即存在nextFilePath对应的MapperFile文件【/data/rocketmq/commitlog/00000000000000000050】则删除并返回当前集合元素。此时requestTable集合元素为nextNextFilePath【/data/rocketmq/commitlog/00000000000000000100】。MappedFileQueue中集合属性mappedFiles中存在00000000000000000000、00000000000000000050两个MappedFile文件。 如果真实发送的消息字节数没有超过当前字节缓冲区剩余空间则优先当前MapperFile文件处理。否则创建新的MapperFile文件。 public class AllocateMappedFileService extends ServiceThread {private static final Logger log LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);private static int waitTimeOut 1000 * 5;private ConcurrentMapString, AllocateRequest requestTable new ConcurrentHashMap();private PriorityBlockingQueueAllocateRequest requestQueue new PriorityBlockingQueue();private volatile boolean hasException false;private DefaultMessageStore messageStore;public AllocateMappedFileService(DefaultMessageStore messageStore) {this.messageStore messageStore;}// nextFilePathCommitLog文件路径 /data/rocketmq/commitlog/00000000000000000000public MappedFile putRequestAndReturnMappedFile(String nextFilePath, String nextNextFilePath, int fileSize) {int canSubmitRequests 2;...AllocateRequest nextReq new AllocateRequest(nextFilePath, fileSize);boolean nextPutOK this.requestTable.putIfAbsent(nextFilePath, nextReq) null;...boolean offerOK this.requestQueue.offer(nextReq);AllocateRequest nextNextReq new AllocateRequest(nextNextFilePath, fileSize);boolean nextNextPutOK this.requestTable.putIfAbsent(nextNextFilePath, nextNextReq) null;...boolean offerOK this.requestQueue.offer(nextNextReq);...// 每次只是返回nextFilePath对应的MappedFile。此时 requestQueue 队列为空requestTable集合中只是存在 nextNextFilePath 对应的MappedFile文件// 如果AllocateRequest result this.requestTable.get(nextFilePath);messageStore.getPerfCounter().startTick(WAIT_MAPFILE_TIME_MS);// 阻塞等待 线程AllocateMappedFileService 初始化MapperFile文件。默认时间为5秒boolean waitOK result.getCountDownLatch().await(waitTimeOut, TimeUnit.MILLISECONDS);messageStore.getPerfCounter().endTick(WAIT_MAPFILE_TIME_MS);if (!waitOK) {log.warn(create mmap timeout result.getFilePath() result.getFileSize());return null;} else {this.requestTable.remove(nextFilePath);// 返回nextFilePath对应的MappedFile文件并添加到MappedFileQueue中集合属性mappedFiles中return result.getMappedFile();}}...public void run() {// 初始化 MapperFile文件 任务while (!this.isStopped() this.mmapOperation()) {}}/*** 通过 putRequestAndReturnMappedFile 生成的文件名异步创建本地文件*/private boolean mmapOperation() {boolean isSuccess false;AllocateRequest req null;try {req this.requestQueue.take();//移除并返回元素否则阻塞等待AllocateRequest expectedRequest this.requestTable.get(req.getFilePath());...if (req.getMappedFile() null) {long beginTime System.currentTimeMillis();//创建对应对应大小、对应磁盘地址的本地文件。并且建立磁盘 内核映射关系MappedFile mappedFile new DefaultMappedFile(req.getFilePath(), req.getFileSize());;...// pre write mappedFile 预热处理if (mappedFile.getFileSize() mappedFileSizeCommitLog warmMapedFileEnable) {FlushDiskType flushDiskType this.messageStore.getMessageStoreConfig().getFlushDiskType();MessageStoreConfig messageStoreConfig this.messageStore.getMessageStoreConfig();int flushLeastPagesWhenWarmMapedFile messageStoreConfig.getFlushLeastPagesWhenWarmMapedFile();mappedFile.warmMappedFile(flushDiskType,flushLeastPagesWhenWarmMapedFile);}req.setMappedFile(mappedFile);this.hasException false;isSuccess true;}} finally {if (req ! null isSuccess)req.getCountDownLatch().countDown();//初始化完毕释放锁}return true;}static class AllocateRequest implements ComparableAllocateRequest {// Full file pathprivate String filePath;private int fileSize;private CountDownLatch countDownLatch new CountDownLatch(1);private volatile MappedFile mappedFile null;public AllocateRequest(String filePath, int fileSize) {this.filePath filePath;this.fileSize fileSize;}...public CountDownLatch getCountDownLatch() {return countDownLatch;}public void setCountDownLatch(CountDownLatch countDownLatch) {this.countDownLatch countDownLatch;}public MappedFile getMappedFile() {return mappedFile;}public void setMappedFile(MappedFile mappedFile) {this.mappedFile mappedFile;}} }2.DefaultMappedFile public class DefaultMappedFile extends AbstractMappedFile {public DefaultMappedFile(final String fileName, final int mappedFileSizeCommitLog) throws IOException {init(fileName, mappedFileSizeCommitLog);}private void init(final String fileName, final int mappedFileSizeCommitLog) throws IOException {this.fileName fileName;this.mappedFileSizeCommitLog mappedFileSizeCommitLog;this.file new File(fileName);this.fileFromOffset Long.parseLong(this.file.getName());boolean ok false;UtilAll.ensureDirOK(this.file.getParent());try {this.fileChannel new RandomAccessFile(this.file, rw).getChannel();this.mappedByteBuffer this.fileChannel.map(MapMode.READ_WRITE, 0, mappedFileSizeCommitLog);TOTAL_MAPPED_VIRTUAL_MEMORY.addAndGet(mappedFileSizeCommitLog);TOTAL_MAPPED_FILES.incrementAndGet();ok true;}finally {if (!ok this.fileChannel ! null) {this.fileChannel.close();}}} }
http://www.pierceye.com/news/132189/

相关文章:

  • 网站营销公司wordpress 无效的文章类型
  • 网站一级页面标题怎么做茶网站设计素材下载
  • 网站建设费用计入什么科目淘宝网站开发店铺什么类别
  • 四川平昌县建设局网站怎么把网站维护
  • 成都教育行业网站建设工业和信息化部反诈中心发短信
  • 高端开发网站系统网页设计与制作教程课后题答案
  • 网站制作的困难与解决方案无极在线最新招聘
  • 做设计比较好的网站推荐郑州做网站企起
  • 手机版自适应网站怎么做春节网页设计素材网站
  • 中国建设教育协会网站培训中心网站建设怎么报价表
  • 网站建设与推广好做吗wordpress+模板+国外
  • 建网站免费空间哪有做logo的网站
  • 找外包做网站要多久网站导航栏条源码
  • php网站开发实践襄樊seo排名
  • 衡水住房和城乡建设局网站939网站建设
  • 晋江网站建设价格中国建筑人才网证书查询
  • 国内永久免费crm系统网站推荐做网站需要学些什么软件
  • 做网站 怎么备案怎么用qq相册做网站
  • 网站建设 公众号免费的网站怎么做
  • 深圳公司网站设计公太原企业网站建设
  • 营销型网站的分类公众号开发信息什么意思
  • 爱写作网站最佳wordpress主机
  • 东山网站制作一站式做网站费用
  • seo针对网站做策划外贸淘宝网站建设
  • 电商网站的建设与运营百度推广营销怎么做
  • 做网站的核验单 是下载的吗北京建设工程招标公告网站
  • 网站建设与维护试卷第九章各网站文风
  • 熊掌号网站的基础建设费用网站的建设ppt模板
  • 有口碑的坪山网站建设王野天 演员
  • 建e网怎么赚钱衡水网站优化