One way is to load the configuration file by invoking the initialization method of the Clientglobal class, and the other is to set the configuration parameters one by two by invoking the API. The latter approach is convenient for loading properties using zookeeper.
1. Load the configuration file:
[Java]View Plaincopyprint?
- String configfilename = "conf/dfs-client.conf";
- try {
- Clientglobal.init (Configfilename);
String configfilename = "conf/dfs-client.conf"; try {clientglobal.init (configfilename);
2. Actively set configuration parameters:
[Java]View Plaincopyprint?
- Time limit for connection timeout, in milliseconds
- Clientglobal.setg_connect_timeout (2000);
- Network time-out time, in milliseconds
- Clientglobal.setg_network_timeout (30000);
- Clientglobal.setg_anti_steal_token (false);
- Character
- Clientglobal.setg_charset ("UTF-8");
- Clientglobal.setg_secret_key (null);
- Port number of the HTTP access service
- Clientglobal.setg_tracker_http_port (7271);
- Tracker Server List
- inetsocketaddress[] Tracker_servers = new Inetsocketaddress[sztrackerservers.length];
- tracker_servers[0] = "200.200.200.200:8080";
- tracker_servers[1] = "200.200.201.200:8080";
- tracker_servers[2] = "200.200.202.200:8080";
- Clientglobal.setg_tracker_group (new Trackergroup (trackerservers));
The time limit for the connection timeout, in milliseconds Clientglobal.setg_connect_timeout (2000);//Network Time-out time in milliseconds clientglobal.setg_network_timeout (30000) ; Clientglobal.setg_anti_steal_token (false);//Character Set Clientglobal.setg_charset ("UTF-8"); Clientglobal.setg_secret_key (null); The port number of the//http Access Service Clientglobal.setg_tracker_http_port (7271);// Tracker Server List inetsocketaddress[] tracker_servers = new Inetsocketaddress[sztrackerservers.length];tracker_servers[0 ] = "200.200.200.200:8080"; tracker_servers[1] = "200.200.201.200:8080"; tracker_servers[2] = "200.200.202.200:8080"; Clientglobal.setg_tracker_group (New Trackergroup (trackerservers));
3. Parameter meaning
Connect_timeout, connection time-out
Network_timeout, Network timeout time
Anti_steal_token, anti-theft chain token
CharSet, Character set
Secret_key, key
Tracker_http_port,tracker Server provides the port for the HTTP service
Address List for Tracker_group,tracker Server Group
FASTDFS configuration, deployment and API usage interpretation (4) FASTDFS configuration detailed Client Configuration