From c60a913ea323a13d930e596a34a38cb74aeb6ce7 Mon Sep 17 00:00:00 2001 From: Anayigeren <15659576701@163.com> Date: Tue, 8 Apr 2025 16:30:55 +0800 Subject: [PATCH] lzh --- .../org/csource/fastdfs/ClientGlobal.java | 61 +++++++++---------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/csource/fastdfs/ClientGlobal.java b/src/main/java/org/csource/fastdfs/ClientGlobal.java index 63fce64..01f1502 100644 --- a/src/main/java/org/csource/fastdfs/ClientGlobal.java +++ b/src/main/java/org/csource/fastdfs/ClientGlobal.java @@ -1,11 +1,3 @@ -/** -* Copyright (C) 2008 Happy Fish / YuQing -* -* FastDFS Java Client may be copied only under the terms of the GNU Lesser -* General Public License (LGPL). -* Please visit the FastDFS Home Page http://www.csource.org/ for more detail. -**/ - package org.csource.fastdfs; import java.net.*; @@ -13,11 +5,6 @@ import java.io.*; import java.net.*; import org.csource.common.*; -/** -* Global variables -* @author Happy Fish / YuQing -* @version Version 1.11 -*/ public class ClientGlobal { public static int g_connect_timeout; //millisecond @@ -27,18 +14,14 @@ public class ClientGlobal public static boolean g_anti_steal_token; //if anti-steal token public static String g_secret_key; //generage token secret key public static TrackerGroup g_tracker_group; - public static final int DEFAULT_CONNECT_TIMEOUT = 5; //second public static final int DEFAULT_NETWORK_TIMEOUT = 30; //second private ClientGlobal() { } - -/** -* load global variables -* @param conf_filename config filename -*/ + + // 初始化ClientGlobal public static void init(String conf_filename) throws FileNotFoundException, IOException, MyException { IniFileReader iniReader; @@ -47,6 +30,7 @@ public class ClientGlobal iniReader = new IniFileReader(conf_filename); + // 读取连接超时时间 g_connect_timeout = iniReader.getIntValue("connect_timeout", DEFAULT_CONNECT_TIMEOUT); if (g_connect_timeout < 0) { @@ -54,6 +38,7 @@ public class ClientGlobal } g_connect_timeout *= 1000; //millisecond + // 读取网络超时时间 g_network_timeout = iniReader.getIntValue("network_timeout", DEFAULT_NETWORK_TIMEOUT); if (g_network_timeout < 0) { @@ -61,18 +46,21 @@ public class ClientGlobal } g_network_timeout *= 1000; //millisecond + // 读取字符集 g_charset = iniReader.getStrValue("charset"); if (g_charset == null || g_charset.length() == 0) { g_charset = "ISO8859-1"; } + // 读取tracker服务器地址 szTrackerServers = iniReader.getValues("tracker_server"); if (szTrackerServers == null) { throw new MyException("item \"tracker_server\" in " + conf_filename + " not found"); } + // 将tracker服务器地址转换为InetSocketAddress数组 InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.length]; for (int i=0; i