• FastDFS的配置、部署与API使用解读(4)FastDFS配置详解之Client配置(转)


    一种方式是通过调用ClientGlobal类的初始化方法对配置文件进行加载,另一种是通过调用API逐一设置配置参数。后一种方式对于使用Zookeeper等加载属性的方式很方便。


    1. 加载配置文件:

    1 String configFileName = "conf/dfs-client.conf";  
    2             try {  
    3                 ClientGlobal.init(configFileName); 

    2. 主动设置配置参数:

     1     //连接超时的时限,单位为毫秒  
     2     ClientGlobal.setG_connect_timeout(2000);  
     3       
     4     //网络超时的时限,单位为毫秒  
     5     ClientGlobal.setG_network_timeout(30000);  
     6       
     7     ClientGlobal.setG_anti_steal_token(false);  
     8       
     9     //字符集  
    10     ClientGlobal.setG_charset("UTF-8");  
    11       
    12     ClientGlobal.setG_secret_key(null);  
    13       
    14     //HTTP访问服务的端口号    
    15     ClientGlobal.setG_tracker_http_port(7271);  
    16       
    17     //Tracker服务器列表  
    18     InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.length];  
    19     tracker_servers[0] = "200.200.200.200:8080";  
    20     tracker_servers[1] = "200.200.201.200:8080";  
    21     tracker_servers[2] = "200.200.202.200:8080";  
    22     ClientGlobal.setG_tracker_group(new TrackerGroup(trackerServers));  

    3. 参数含义

    connect_timeout,连接超时时间

    network_timeout,网络超时时间

    anti_steal_token,防盗链Token

    charset,字符集

    secret_key,密钥

    tracker_http_port,Tracker Server提供HTTP服务的端口

    tracker_group,Tracker Server Group的地址列表

  • 相关阅读:
    nconf修改密码
    快速清空一个文
    freebsd安装snmp
    -bash: mail: command not found
    重置Cacti密码
    cacti添加被监控机全过程
    cacti图形字符乱码
    博客链接
    tar命令详解
    MainPresenter 实现类
  • 原文地址:https://www.cnblogs.com/sandea/p/4439284.html
Copyright © 2020-2023  润新知