hadoop-cos

org.apache.hadoop.fs.CosNFileSystem

复制代码
Preconditions.checkArgument(uploadThreadPoolSize > 0,
                String.format("The uploadThreadPoolSize[%d] should be positive.", uploadThreadPoolSize));
        Preconditions.checkArgument(readAheadPoolSize > 0,
                String.format("The readAheadQueueSize[%d] should be positive.", readAheadPoolSize));
        // 核心线程数取用户配置的为准,最大线程数结合用户配置和IO密集型任务的最优线程数来看
        int ioCoreTaskSize = uploadThreadPoolSize + readAheadPoolSize;
        int ioMaxTaskSize = Math.max(uploadThreadPoolSize + readAheadPoolSize,
                Runtime.getRuntime().availableProcessors() * 2 + 1);
        if (this.getConf().get(CosNConfigKeys.IO_THREAD_POOL_MAX_SIZE_KEY) != null) {
            int ioThreadPoolMaxSize = this.getConf().getInt(
                    CosNConfigKeys.IO_THREAD_POOL_MAX_SIZE_KEY, CosNConfigKeys.DEFAULT_IO_THREAD_POOL_MAX_SIZE);
            Preconditions.checkArgument(ioThreadPoolMaxSize > 0,
                    String.format("The ioThreadPoolMaxSize[%d] should be positive.", ioThreadPoolMaxSize));
            // 如果设置了 IO 线程池的最大限制,则整个线程池需要被限制住
            ioCoreTaskSize = Math.min(ioCoreTaskSize, ioThreadPoolMaxSize);
            ioMaxTaskSize = ioThreadPoolMaxSize;
        }

int readAheadPoolSize = this.getConf().getInt(
                CosNConfigKeys.READ_AHEAD_QUEUE_SIZE,
                CosNConfigKeys.DEFAULT_READ_AHEAD_QUEUE_SIZE
        );
  • java/org/apache/hadoop/fs/CosNFSInputStream.java

以下是顺序读,随机读的判断

复制代码
private synchronized void reopen(long pos) throws IOException {
...
		boolean isRandomIO = true;
        if (pos == this.nextPos) {
            isRandomIO = false;
        } else {
            while (this.readBufferQueue.size() != 0) {
                if (this.readBufferQueue.element().getStart() != pos) {
                    this.readBufferQueue.poll();
                } else {
                    break;
                }
            }
        }
...
}

        this.maxReadPartNumber = conf.getInt(
                CosNConfigKeys.READ_AHEAD_QUEUE_SIZE,
                CosNConfigKeys.DEFAULT_READ_AHEAD_QUEUE_SIZE);
        this.socketErrMaxRetryTimes = conf.getInt(
                CosNConfigKeys.CLIENT_SOCKET_ERROR_MAX_RETRIES,
                CosNConfigKeys.DEFAULT_CLIENT_SOCKET_ERROR_MAX_RETRIES);

public static final String CLIENT_SOCKET_ERROR_MAX_RETRIES = "fs.cosn.socket.error.maxRetries";
    public static final int DEFAULT_CLIENT_SOCKET_ERROR_MAX_RETRIES = 5;

this.readBufferQueue =
                new ArrayDeque<ReadBuffer>(this.maxReadPartNumber);
相关推荐
captain_AIouo3 分钟前
聚焦实操赋能,Captain AI系统功能实操指南及价值解读
大数据·人工智能·经验分享·aigc
个微管理5 分钟前
小红书新规深度拆解:从被封到破局,2026年矩阵号生存手册
大数据·人工智能·矩阵
2601_956414146 分钟前
适合 Reddit 多账号运营的指纹浏览器推荐哪款?
大数据
chaofan98016 分钟前
GPT-5.5 深度评测:15项基准测试全优,视觉理解精度跃升 42%
大数据·人工智能·gpt·计算机视觉·api
2301_7760452320 分钟前
估值和市值的区别(股票与加密资产)
大数据·人工智能
珠海西格电力1 小时前
零碳园区产业园管理系统的全场景源网荷储氢协同调度功能是如何实现的
大数据·运维·人工智能·物联网·能源
ai大模型中转api测评1 小时前
解密 GPT-5.5:原生多模态架构如何重定义 AI 逻辑推理与精准制图
大数据·人工智能·gpt·架构·api
数据皮皮侠AI1 小时前
中国城市可再生能源数据集(2005-2021)|顶刊 Sci Data 11 种能源面板
大数据·人工智能·笔记·能源·1024程序员节
G31135422731 小时前
如何用 QClaw 龙虾做一个规律作息健康助理 Agent
大数据·人工智能·ai·云计算
幂律智能1 小时前
零售行业合同管理数智化转型解决方案
大数据·人工智能·零售