mirror of
https://github.com/happyfish100/fastdfs-client-java.git
synced 2026-09-17 17:29:00 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e56870bdd8 | ||
|
|
4e7b6b3419 | ||
|
|
ac59ecec49 | ||
|
|
7825aa0b94 | ||
|
|
d29ca63106 | ||
|
|
91a5cc2e36 | ||
|
|
cc95bc0244 | ||
|
|
7b7a7d76f6 | ||
|
|
f4c00d7b2a | ||
|
|
1c1dc946e3 | ||
|
|
807be5acd9 | ||
|
|
1d75bb50d0 | ||
|
|
907239cb67 | ||
|
|
fa0b79527c | ||
|
|
496da3f0c4 | ||
|
|
0c954e697b | ||
|
|
7e644f1ba4 |
@@ -1,4 +1,46 @@
|
||||
|
||||
Version 1.40 2026-06-28
|
||||
* ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL protocol changed
|
||||
you must upgrade your FastDFS server V6.16.0 and higher version
|
||||
|
||||
Version 1.39 2025-12-19
|
||||
* ConnectionPool.getKey() use '-' instead of ':'
|
||||
* ConnectionManager.java: remove private AtomicInteger freeCount
|
||||
* ConnectionManager.java: prevent re-entrancy for closeConnection
|
||||
|
||||
Version 1.38 2025-11-28
|
||||
* bugfixed: loadStorageServersFromTracker correctly with rw option
|
||||
* throw IOException with msg "connection broken" when in.read() < 0
|
||||
|
||||
Version 1.37 2025-11-06
|
||||
* query file info support two combined flags:
|
||||
ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32
|
||||
ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE
|
||||
you must upgrade your FastDFS server V6.15.1 and higher version
|
||||
|
||||
Version 1.36 2025-10-26
|
||||
* monitor protocol compatible with IPv4/IPv6 address automatically
|
||||
* FastDFS server version requirements:
|
||||
# group and storage statistics / monitor APIs: FastDFS server >= V6.13.1
|
||||
# other APIs: FastDFS server >= V6.06
|
||||
|
||||
Version 1.35 2025-09-04
|
||||
* group and storage statistics / monitor API output reserved
|
||||
and available space
|
||||
* you must upgrade your FastDFS server V6.13.1 and higher version
|
||||
|
||||
Version 1.34 2025-08-28
|
||||
* adapt to FastDFS server V6.13 for read-write separation
|
||||
you must upgrade your FastDFS server V6.13 and higher version
|
||||
|
||||
Version 1.33 2025-07-21
|
||||
* protocol automatically compatible with IPv4/IPv6 address
|
||||
this version for FastDFS server V6.06 and higher version
|
||||
|
||||
Version 1.32 2024-02-12
|
||||
* change FDFS_VERSION_SIZE from 6 to 8
|
||||
you must upgrade your FastDFS server to V6.12 or higher version
|
||||
|
||||
Version 1.31 2023-12-13
|
||||
* adapt to FastDFS server V6.11 for IPv6
|
||||
you must upgrade your FastDFS server to V6.11 or higher version
|
||||
|
||||
@@ -26,7 +26,7 @@ mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java
|
||||
<dependency>
|
||||
<groupId>org.csource</groupId>
|
||||
<artifactId>fastdfs-client-java</artifactId>
|
||||
<version>1.31-SNAPSHOT</version>
|
||||
<version>1.39-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ tracker_server = 10.0.11.249:22122
|
||||
connection_pool.enabled = true
|
||||
connection_pool.max_count_per_entry = 500
|
||||
connection_pool.max_idle_time = 3600
|
||||
connection_pool.max_wait_time_in_ms = 1000
|
||||
connection_pool.max_wait_time_in_ms = 3000
|
||||
```
|
||||
|
||||
注1:tracker_server指向您自己IP地址和端口,1-n个
|
||||
@@ -89,7 +89,7 @@ fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122
|
||||
fastdfs.connection_pool.enabled = true
|
||||
fastdfs.connection_pool.max_count_per_entry = 500
|
||||
fastdfs.connection_pool.max_idle_time = 3600
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 1000
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 3000
|
||||
```
|
||||
|
||||
注1:properties 配置文件中属性名跟 conf 配置文件不尽相同,并且统一加前缀"fastdfs.",便于整合到用户项目配置文件
|
||||
@@ -135,7 +135,7 @@ ClientGlobal.configInfo(): {
|
||||
g_connection_pool_enabled = true
|
||||
g_connection_pool_max_count_per_entry = 500
|
||||
g_connection_pool_max_idle_time(ms) = 3600000
|
||||
g_connection_pool_max_wait_time_in_ms(ms) = 1000
|
||||
g_connection_pool_max_wait_time_in_ms(ms) = 3000
|
||||
trackerServers = 10.0.11.101:22122,10.0.11.102:22122
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<target name="init">
|
||||
<property name="project.name" value="fastdfs-client-java"/>
|
||||
<property name="project.version" value="1.27-SNAPSHOT"/>
|
||||
<property name="project.version" value="1.39-SNAPSHOT"/>
|
||||
<property name="project.java" value="${basedir}/src/main/java"/>
|
||||
<property name="project.resources" value="${basedir}/src/main/resources"/>
|
||||
<property name="project.build" value="${basedir}/build"/>
|
||||
|
||||
@@ -21,4 +21,4 @@ fastdfs.connection_pool.max_count_per_entry = 500
|
||||
fastdfs.connection_pool.max_idle_time = 3600
|
||||
|
||||
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 1000
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 3000
|
||||
|
||||
+1
-1
@@ -25,4 +25,4 @@ connect_first_by = tracker
|
||||
connection_pool.enabled = true
|
||||
connection_pool.max_count_per_entry = 500
|
||||
connection_pool.max_idle_time = 3600
|
||||
connection_pool.max_wait_time_in_ms = 1000
|
||||
connection_pool.max_wait_time_in_ms = 3000
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>org.csource</groupId>
|
||||
<artifactId>fastdfs-client-java</artifactId>
|
||||
<version>1.31-SNAPSHOT</version>
|
||||
<version>1.40-SNAPSHOT</version>
|
||||
<name>fastdfs-client-java</name>
|
||||
<description>fastdfs client for java</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Properties;
|
||||
* Global variables
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.11
|
||||
* @version Version 1.33
|
||||
*/
|
||||
public class ClientGlobal {
|
||||
|
||||
@@ -49,6 +49,8 @@ public class ClientGlobal {
|
||||
public static final String PROP_KEY_CONNECTION_POOL_MAX_IDLE_TIME = "fastdfs.connection_pool.max_idle_time";
|
||||
public static final String PROP_KEY_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS = "fastdfs.connection_pool.max_wait_time_in_ms";
|
||||
|
||||
public static final String PROP_KEY_HAVE_ALLOW_EMPTY_FIELD = "fastdfs.fetch_storage_ids.have_allow_empty_field";
|
||||
|
||||
public static final int DEFAULT_CONNECT_TIMEOUT = 5; //second
|
||||
public static final int DEFAULT_NETWORK_TIMEOUT = 30; //second
|
||||
public static final String DEFAULT_CHARSET = "UTF-8";
|
||||
@@ -79,6 +81,9 @@ public class ClientGlobal {
|
||||
public static int g_connection_pool_max_idle_time = DEFAULT_CONNECTION_POOL_MAX_IDLE_TIME * 1000; //millisecond
|
||||
public static int g_connection_pool_max_wait_time_in_ms = DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS; //millisecond
|
||||
|
||||
public static final boolean DEFAULT_HAVE_ALLOW_EMPTY_FIELD = true;
|
||||
public static boolean g_have_allow_empty_field = DEFAULT_HAVE_ALLOW_EMPTY_FIELD;
|
||||
|
||||
public static TrackerGroup g_tracker_group;
|
||||
|
||||
private ClientGlobal() {
|
||||
@@ -86,8 +91,12 @@ public class ClientGlobal {
|
||||
|
||||
private static void loadStorageServersFromTracker() throws IOException, MyException {
|
||||
TrackerClient tracker = new TrackerClient();
|
||||
StringBuilder builder = tracker.fetchStorageIds();
|
||||
if (builder.length() == 0) {
|
||||
StringBuilder builder = tracker.fetchStorageIds(g_have_allow_empty_field);
|
||||
if (builder == null && g_have_allow_empty_field) {
|
||||
builder = tracker.fetchStorageIds(false);
|
||||
}
|
||||
|
||||
if (builder == null || builder.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,7 +106,7 @@ public class ClientGlobal {
|
||||
String[] ipAddresses = new String[lines.length];
|
||||
for (String line : lines) {
|
||||
String[] cols = line.split(" ");
|
||||
if (cols.length != 3) {
|
||||
if (!(cols.length == 3 || cols.length == 4)) {
|
||||
throw new MyException("invalid line: " + line);
|
||||
}
|
||||
|
||||
@@ -226,6 +235,7 @@ public class ClientGlobal {
|
||||
g_connection_pool_max_wait_time_in_ms = DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS;
|
||||
}
|
||||
|
||||
g_have_allow_empty_field = iniReader.getBoolValue("fetch_storage_ids.have_allow_empty_field", DEFAULT_HAVE_ALLOW_EMPTY_FIELD);
|
||||
loadStorageServersFromTracker();
|
||||
}
|
||||
|
||||
@@ -305,6 +315,11 @@ public class ClientGlobal {
|
||||
g_connection_pool_max_wait_time_in_ms = Integer.parseInt(poolMaxWaitTimeInMS);
|
||||
}
|
||||
|
||||
String haveAllowEmptyField = props.getProperty(PROP_KEY_HAVE_ALLOW_EMPTY_FIELD);
|
||||
if (haveAllowEmptyField != null && haveAllowEmptyField.trim().length() != 0) {
|
||||
g_have_allow_empty_field = Boolean.parseBoolean(haveAllowEmptyField);
|
||||
}
|
||||
|
||||
loadStorageServersFromTracker();
|
||||
}
|
||||
|
||||
@@ -455,6 +470,7 @@ public class ClientGlobal {
|
||||
+ "\n g_connection_pool_max_count_per_entry = " + g_connection_pool_max_count_per_entry
|
||||
+ "\n g_connection_pool_max_idle_time(ms) = " + g_connection_pool_max_idle_time
|
||||
+ "\n g_connection_pool_max_wait_time_in_ms(ms) = " + g_connection_pool_max_wait_time_in_ms
|
||||
+ "\n g_have_allow_empty_field = " + g_have_allow_empty_field
|
||||
+ "\n trackerServers = " + trackerServers
|
||||
+ "\n}";
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -73,16 +74,20 @@ public class ProtoCommon {
|
||||
public static final int FDFS_PROTO_PKG_LEN_SIZE = 8;
|
||||
public static final int FDFS_PROTO_CMD_SIZE = 1;
|
||||
public static final int FDFS_GROUP_NAME_MAX_LEN = 16;
|
||||
public static final int FDFS_IPADDR_SIZE = 46;
|
||||
public static final int FDFS_DOMAIN_NAME_MAX_SIZE = 128;
|
||||
public static final int FDFS_VERSION_SIZE = 6;
|
||||
public static final int FDFS_IPV4_SIZE = 16;
|
||||
public static final int FDFS_IPV6_SIZE = 46;
|
||||
public static final int FDFS_VERSION_SIZE = 8;
|
||||
public static final int FDFS_STORAGE_ID_MAX_SIZE = 16;
|
||||
public static final String FDFS_RECORD_SEPERATOR = "\u0001";
|
||||
public static final String FDFS_FIELD_SEPERATOR = "\u0002";
|
||||
public static final int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final int TRACKER_QUERY_STORAGE_FETCH_IPV4_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPV4_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final int TRACKER_QUERY_STORAGE_FETCH_IPV6_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPV6_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final int TRACKER_QUERY_STORAGE_STORE_IPV4_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPV4_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final int TRACKER_QUERY_STORAGE_STORE_IPV6_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
|
||||
+ FDFS_IPV6_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
public static final byte FDFS_FILE_EXT_NAME_MAX_LEN = 6;
|
||||
public static final byte FDFS_FILE_PREFIX_MAX_LEN = 16;
|
||||
public static final byte FDFS_FILE_PATH_LEN = 10;
|
||||
@@ -103,6 +108,15 @@ public class ProtoCommon {
|
||||
protected static final int PROTO_HEADER_CMD_INDEX = FDFS_PROTO_PKG_LEN_SIZE;
|
||||
protected static final int PROTO_HEADER_STATUS_INDEX = FDFS_PROTO_PKG_LEN_SIZE + 1;
|
||||
|
||||
//read write mode
|
||||
public static final byte FDFS_RW_MODE_NONE = 0;
|
||||
public static final byte FDFS_RW_MODE_READONLY = 4;
|
||||
public static final byte FDFS_RW_MODE_WRITEONLY = 2;
|
||||
public static final byte FDFS_RW_MODE_BOTH = FDFS_RW_MODE_READONLY + FDFS_RW_MODE_WRITEONLY;
|
||||
|
||||
public static final byte FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 = 1;
|
||||
public static final byte FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE = 2;
|
||||
|
||||
private ProtoCommon() {
|
||||
}
|
||||
|
||||
@@ -161,35 +175,48 @@ public class ProtoCommon {
|
||||
* @param expect_body_len expect response package body length
|
||||
* @return RecvHeaderInfo: errno and pkg body length
|
||||
*/
|
||||
public static RecvHeaderInfo recvHeader(InputStream in, byte expect_cmd, long expect_body_len) throws IOException {
|
||||
byte[] header;
|
||||
int bytes;
|
||||
long pkg_len;
|
||||
public static RecvHeaderInfo recvHeader(InputStream in, InetSocketAddress socketAddr,
|
||||
byte expect_cmd, long expect_body_len) throws IOException
|
||||
{
|
||||
byte[] header;
|
||||
int bytes;
|
||||
long pkg_len;
|
||||
|
||||
header = new byte[FDFS_PROTO_PKG_LEN_SIZE + 2];
|
||||
header = new byte[FDFS_PROTO_PKG_LEN_SIZE + 2];
|
||||
bytes = in.read(header);
|
||||
if (bytes != header.length) {
|
||||
if (bytes < 0) {
|
||||
throw new IOException("server " + socketAddr.getAddress().getHostAddress()
|
||||
+ ":" + socketAddr.getPort() + ", connection broken");
|
||||
} else {
|
||||
throw new IOException("server " + socketAddr.getAddress().getHostAddress() + ":"
|
||||
+ socketAddr.getPort() + ", recv package size " + bytes + " != " + header.length);
|
||||
}
|
||||
}
|
||||
|
||||
if ((bytes = in.read(header)) != header.length) {
|
||||
throw new IOException("recv package size " + bytes + " != " + header.length);
|
||||
}
|
||||
if (header[PROTO_HEADER_CMD_INDEX] != expect_cmd) {
|
||||
throw new IOException("server " + socketAddr.getAddress().getHostAddress() + ":"
|
||||
+ socketAddr.getPort() + ", recv cmd: " + header[PROTO_HEADER_CMD_INDEX]
|
||||
+ " is not correct, expect cmd: " + expect_cmd);
|
||||
}
|
||||
|
||||
if (header[PROTO_HEADER_CMD_INDEX] != expect_cmd) {
|
||||
throw new IOException("recv cmd: " + header[PROTO_HEADER_CMD_INDEX] + " is not correct, expect cmd: " + expect_cmd);
|
||||
}
|
||||
if (header[PROTO_HEADER_STATUS_INDEX] != 0) {
|
||||
return new RecvHeaderInfo(header[PROTO_HEADER_STATUS_INDEX], 0);
|
||||
}
|
||||
|
||||
if (header[PROTO_HEADER_STATUS_INDEX] != 0) {
|
||||
return new RecvHeaderInfo(header[PROTO_HEADER_STATUS_INDEX], 0);
|
||||
}
|
||||
pkg_len = ProtoCommon.buff2long(header, 0);
|
||||
if (pkg_len < 0) {
|
||||
throw new IOException("server " + socketAddr.getAddress().getHostAddress() + ":"
|
||||
+ socketAddr.getPort() + ", recv body length: " + pkg_len + " < 0!");
|
||||
}
|
||||
|
||||
pkg_len = ProtoCommon.buff2long(header, 0);
|
||||
if (pkg_len < 0) {
|
||||
throw new IOException("recv body length: " + pkg_len + " < 0!");
|
||||
}
|
||||
if (expect_body_len >= 0 && pkg_len != expect_body_len) {
|
||||
throw new IOException("server " + socketAddr.getAddress().getHostAddress() + ":"
|
||||
+ socketAddr.getPort() + ", recv body length: " + pkg_len
|
||||
+ " is not correct, expect length: " + expect_body_len);
|
||||
}
|
||||
|
||||
if (expect_body_len >= 0 && pkg_len != expect_body_len) {
|
||||
throw new IOException("recv body length: " + pkg_len + " is not correct, expect length: " + expect_body_len);
|
||||
}
|
||||
|
||||
return new RecvHeaderInfo((byte) 0, pkg_len);
|
||||
return new RecvHeaderInfo((byte)0, pkg_len);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,31 +227,40 @@ public class ProtoCommon {
|
||||
* @param expect_body_len expect response package body length
|
||||
* @return RecvPackageInfo: errno and reponse body(byte buff)
|
||||
*/
|
||||
public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException {
|
||||
RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len);
|
||||
if (header.errno != 0) {
|
||||
return new RecvPackageInfo(header.errno, null);
|
||||
}
|
||||
|
||||
byte[] body = new byte[(int) header.body_len];
|
||||
int totalBytes = 0;
|
||||
int remainBytes = (int) header.body_len;
|
||||
int bytes;
|
||||
|
||||
while (totalBytes < header.body_len) {
|
||||
if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) {
|
||||
break;
|
||||
public static RecvPackageInfo recvPackage(InputStream in, InetSocketAddress socketAddr,
|
||||
byte expect_cmd, long expect_body_len) throws IOException
|
||||
{
|
||||
RecvHeaderInfo header = recvHeader(in, socketAddr, expect_cmd, expect_body_len);
|
||||
if (header.errno != 0) {
|
||||
return new RecvPackageInfo(header.errno, null);
|
||||
}
|
||||
|
||||
totalBytes += bytes;
|
||||
remainBytes -= bytes;
|
||||
}
|
||||
byte[] body = new byte[(int) header.body_len];
|
||||
int totalBytes = 0;
|
||||
int remainBytes = (int) header.body_len;
|
||||
int bytes = 0;
|
||||
|
||||
if (totalBytes != header.body_len) {
|
||||
throw new IOException("recv package size " + totalBytes + " != " + header.body_len);
|
||||
}
|
||||
while (totalBytes < header.body_len) {
|
||||
if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
return new RecvPackageInfo((byte) 0, body);
|
||||
totalBytes += bytes;
|
||||
remainBytes -= bytes;
|
||||
}
|
||||
|
||||
if (totalBytes != header.body_len) {
|
||||
String msg = "server " + socketAddr.getAddress().getHostAddress()
|
||||
+ ":" + socketAddr.getPort() + " connection broken";
|
||||
if (totalBytes == 0) {
|
||||
throw new IOException(msg);
|
||||
} else {
|
||||
throw new IOException(msg + ", recv length: " + totalBytes
|
||||
+ ", expect length: " + header.body_len);
|
||||
}
|
||||
}
|
||||
|
||||
return new RecvPackageInfo((byte)0, body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,7 +343,8 @@ public class ProtoCommon {
|
||||
header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte) 0);
|
||||
sock.getOutputStream().write(header);
|
||||
|
||||
RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0);
|
||||
InetSocketAddress socketAddr = new InetSocketAddress(sock.getInetAddress(), sock.getPort());
|
||||
RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), socketAddr, TRACKER_PROTO_CMD_RESP, 0);
|
||||
return headerInfo.errno == 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
@@ -656,7 +656,7 @@ public class StorageClient {
|
||||
out.write(wholePkg);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
@@ -801,7 +801,7 @@ public class StorageClient {
|
||||
}
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
@@ -907,7 +907,7 @@ public class StorageClient {
|
||||
}
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return this.errno;
|
||||
@@ -1004,7 +1004,7 @@ public class StorageClient {
|
||||
}
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return this.errno;
|
||||
@@ -1040,7 +1040,7 @@ public class StorageClient {
|
||||
try {
|
||||
this.send_package(ProtoCommon.STORAGE_PROTO_CMD_DELETE_FILE, group_name, remote_filename, connection);
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
|
||||
this.errno = pkgInfo.errno;
|
||||
return pkgInfo.errno;
|
||||
@@ -1122,7 +1122,7 @@ public class StorageClient {
|
||||
|
||||
out.write(wholePkg);
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
this.errno = pkgInfo.errno;
|
||||
return pkgInfo.errno;
|
||||
} catch (IOException ex) {
|
||||
@@ -1171,7 +1171,7 @@ public class StorageClient {
|
||||
|
||||
this.send_download_package(group_name, remote_filename, file_offset, download_bytes, connection);
|
||||
pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
@@ -1232,7 +1232,7 @@ public class StorageClient {
|
||||
this.send_download_package(group_name, remote_filename, file_offset, download_bytes, connection);
|
||||
|
||||
InputStream in = connection.getInputStream();
|
||||
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
header = ProtoCommon.recvHeader(in, connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
this.errno = header.errno;
|
||||
if (header.errno != 0) {
|
||||
return header.errno;
|
||||
@@ -1320,7 +1320,7 @@ public class StorageClient {
|
||||
this.send_download_package(group_name, remote_filename, file_offset, download_bytes, connection);
|
||||
|
||||
InputStream in = connection.getInputStream();
|
||||
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
header = ProtoCommon.recvHeader(in, connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
this.errno = header.errno;
|
||||
if (header.errno != 0) {
|
||||
return header.errno;
|
||||
@@ -1376,7 +1376,7 @@ public class StorageClient {
|
||||
|
||||
this.send_package(ProtoCommon.STORAGE_PROTO_CMD_GET_METADATA, group_name, remote_filename, connection);
|
||||
pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
@@ -1467,7 +1467,7 @@ public class StorageClient {
|
||||
}
|
||||
|
||||
pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, 0);
|
||||
|
||||
this.errno = pkgInfo.errno;
|
||||
return pkgInfo.errno;
|
||||
@@ -1540,9 +1540,14 @@ public class StorageClient {
|
||||
*
|
||||
* @param group_name the group name of storage server
|
||||
* @param remote_filename filename on storage server
|
||||
* @param flags combined flags as following:
|
||||
* ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 : do NOT calculate CRC32
|
||||
* for appender file or slave file
|
||||
* ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE : keep silence,
|
||||
* when this file not exist, do not log error on storage server
|
||||
* @return FileInfo object for success, return null for fail
|
||||
*/
|
||||
public FileInfo query_file_info(String group_name, String remote_filename) throws IOException, MyException {
|
||||
public FileInfo query_file_info(String group_name, String remote_filename, byte flags) throws IOException, MyException {
|
||||
boolean bNewStorageServer = this.newUpdatableStorageConnection(group_name, remote_filename);
|
||||
Connection connection = this.storageServer.getConnection();
|
||||
try {
|
||||
@@ -1566,7 +1571,7 @@ public class StorageClient {
|
||||
System.arraycopy(bs, 0, groupBytes, 0, groupLen);
|
||||
|
||||
header = ProtoCommon.packHeader(ProtoCommon.STORAGE_PROTO_CMD_QUERY_FILE_INFO,
|
||||
+groupBytes.length + filenameBytes.length, (byte) 0);
|
||||
groupBytes.length + filenameBytes.length, flags);
|
||||
OutputStream out = connection.getOutputStream();
|
||||
byte[] wholePkg = new byte[header.length + groupBytes.length + filenameBytes.length];
|
||||
System.arraycopy(header, 0, wholePkg, 0, header.length);
|
||||
@@ -1575,19 +1580,28 @@ public class StorageClient {
|
||||
out.write(wholePkg);
|
||||
|
||||
pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.STORAGE_PROTO_CMD_RESP,
|
||||
3 * ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE +
|
||||
ProtoCommon.FDFS_IPADDR_SIZE);
|
||||
connection.getInetSocketAddress(), ProtoCommon.STORAGE_PROTO_CMD_RESP, -1);
|
||||
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int front_len = 3 * ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
int ip_size;
|
||||
if (pkgInfo.body.length == front_len + ProtoCommon.FDFS_IPV6_SIZE) { //IPv6
|
||||
ip_size = ProtoCommon.FDFS_IPV6_SIZE;
|
||||
} else if (pkgInfo.body.length == front_len + ProtoCommon.FDFS_IPV4_SIZE) { //IPv4
|
||||
ip_size = ProtoCommon.FDFS_IPV4_SIZE;
|
||||
} else {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
long file_size = ProtoCommon.buff2long(pkgInfo.body, 0);
|
||||
int create_timestamp = (int) ProtoCommon.buff2long(pkgInfo.body, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
int crc32 = (int) ProtoCommon.buff2long(pkgInfo.body, 2 * ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
String source_ip_addr = (new String(pkgInfo.body, 3 * ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE, ProtoCommon.FDFS_IPADDR_SIZE)).trim();
|
||||
String source_ip_addr = (new String(pkgInfo.body, front_len, ip_size)).trim();
|
||||
return new FileInfo(true, FileInfo.FILE_TYPE_NORMAL, file_size,
|
||||
create_timestamp, crc32, source_ip_addr);
|
||||
} catch (IOException ex) {
|
||||
@@ -1604,6 +1618,11 @@ public class StorageClient {
|
||||
}
|
||||
}
|
||||
|
||||
public FileInfo query_file_info(String group_name, String remote_filename) throws IOException, MyException {
|
||||
final byte flags = 0;
|
||||
return this.query_file_info(group_name, remote_filename, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* check storage socket, if null create a new connection
|
||||
*
|
||||
|
||||
@@ -735,16 +735,26 @@ public class StorageClient1 extends StorageClient {
|
||||
* get file info from storage server
|
||||
*
|
||||
* @param file_id the file id(including group name and filename)
|
||||
* @param flags combined flags as following:
|
||||
* ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 : do NOT calculate CRC32
|
||||
* for appender file or slave file
|
||||
* ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE : keep silence,
|
||||
* when this file not exist, do not log error on storage server
|
||||
* @return FileInfo object for success, return null for fail
|
||||
*/
|
||||
public FileInfo query_file_info1(String file_id) throws IOException, MyException {
|
||||
String[] parts = new String[2];
|
||||
this.errno = this.split_file_id(file_id, parts);
|
||||
if (this.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
public FileInfo query_file_info1(String file_id, byte flags) throws IOException, MyException {
|
||||
String[] parts = new String[2];
|
||||
this.errno = this.split_file_id(file_id, parts);
|
||||
if (this.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.query_file_info(parts[0], parts[1]);
|
||||
return this.query_file_info(parts[0], parts[1], flags);
|
||||
}
|
||||
|
||||
public FileInfo query_file_info1(String file_id) throws IOException, MyException {
|
||||
final byte flags = 0;
|
||||
return this.query_file_info1(file_id, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,74 +12,94 @@ package org.csource.fastdfs;
|
||||
* C struct body decoder
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.18
|
||||
* @version Version 1.34
|
||||
*/
|
||||
public class StructGroupStat extends StructBase {
|
||||
protected static final int FIELD_INDEX_GROUP_NAME = 0;
|
||||
protected static final int FIELD_INDEX_TOTAL_MB = 1;
|
||||
protected static final int FIELD_INDEX_FREE_MB = 2;
|
||||
protected static final int FIELD_INDEX_TRUNK_FREE_MB = 3;
|
||||
protected static final int FIELD_INDEX_STORAGE_COUNT = 4;
|
||||
protected static final int FIELD_INDEX_STORAGE_PORT = 5;
|
||||
protected static final int FIELD_INDEX_STORAGE_HTTP_PORT = 6;
|
||||
protected static final int FIELD_INDEX_ACTIVE_COUNT = 7;
|
||||
protected static final int FIELD_INDEX_CURRENT_WRITE_SERVER = 8;
|
||||
protected static final int FIELD_INDEX_STORE_PATH_COUNT = 9;
|
||||
protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 10;
|
||||
protected static final int FIELD_INDEX_CURRENT_TRUNK_FILE_ID = 11;
|
||||
protected static final int FIELD_INDEX_RESERVED_MB = 3;
|
||||
protected static final int FIELD_INDEX_TRUNK_FREE_MB = 4;
|
||||
protected static final int FIELD_INDEX_STORAGE_COUNT = 5;
|
||||
protected static final int FIELD_INDEX_STORAGE_PORT = 6;
|
||||
protected static final int FIELD_INDEX_READABLE_SERVER_COUNT = 7;
|
||||
protected static final int FIELD_INDEX_WRITABLE_SERVER_COUNT = 8;
|
||||
protected static final int FIELD_INDEX_CURRENT_WRITE_SERVER = 9;
|
||||
protected static final int FIELD_INDEX_STORE_PATH_COUNT = 10;
|
||||
protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 11;
|
||||
protected static final int FIELD_INDEX_CURRENT_TRUNK_FILE_ID = 12;
|
||||
|
||||
protected static final int FIELD_COUNT = 13;
|
||||
|
||||
protected static int fieldsTotalSize;
|
||||
protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[12];
|
||||
protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[FIELD_COUNT];
|
||||
|
||||
static {
|
||||
int offset = 0;
|
||||
fieldsArray[FIELD_INDEX_GROUP_NAME] = new StructBase.FieldInfo("groupName", offset, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
|
||||
fieldsArray[FIELD_INDEX_GROUP_NAME] = new StructBase.FieldInfo(
|
||||
"groupName", offset, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
|
||||
offset += ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo("totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo(
|
||||
"totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo("freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo(
|
||||
"freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TRUNK_FREE_MB] = new StructBase.FieldInfo("trunkFreeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_RESERVED_MB] = new StructBase.FieldInfo(
|
||||
"reservedMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORAGE_COUNT] = new StructBase.FieldInfo("storageCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_TRUNK_FREE_MB] = new StructBase.FieldInfo(
|
||||
"trunkFreeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo("storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_STORAGE_COUNT] = new StructBase.FieldInfo(
|
||||
"storageCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT] = new StructBase.FieldInfo("storageHttpPort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo(
|
||||
"storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_ACTIVE_COUNT] = new StructBase.FieldInfo("activeCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_READABLE_SERVER_COUNT] = new StructBase.FieldInfo(
|
||||
"readableServerCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER] = new StructBase.FieldInfo("currentWriteServer", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_WRITABLE_SERVER_COUNT] = new StructBase.FieldInfo(
|
||||
"writableServerCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo("storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER] = new StructBase.FieldInfo(
|
||||
"currentWriteServer", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo("subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo(
|
||||
"storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID] = new StructBase.FieldInfo("currentTrunkFileId", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo(
|
||||
"subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID] = new StructBase.FieldInfo(
|
||||
"currentTrunkFileId", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsTotalSize = offset;
|
||||
}
|
||||
|
||||
protected String groupName; //name of this group
|
||||
protected long totalMB; //total disk storage in MB
|
||||
protected long totalMB; //total disk space in MB
|
||||
protected long freeMB; //free disk space in MB
|
||||
protected long reservedMB; //reserved disk space in MB
|
||||
protected long trunkFreeMB; //trunk free space in MB
|
||||
protected int storageCount; //storage server count
|
||||
protected int storagePort; //storage server port
|
||||
protected int storageHttpPort; //storage server HTTP port
|
||||
protected int activeCount; //active storage server count
|
||||
protected int readableServerCount; //readable storage server count
|
||||
protected int writableServerCount; //writable storage server count
|
||||
protected int currentWriteServer; //current storage server index to upload file
|
||||
protected int storePathCount; //store base path count of each storage server
|
||||
protected int subdirCountPerPath; //sub dir count per store path
|
||||
@@ -121,6 +141,15 @@ public class StructGroupStat extends StructBase {
|
||||
return this.freeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* get reserved disk space in MB
|
||||
*
|
||||
* @return reserved disk space in MB
|
||||
*/
|
||||
public long getReservedMB() {
|
||||
return this.reservedMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* get trunk free space in MB
|
||||
*
|
||||
@@ -139,13 +168,22 @@ public class StructGroupStat extends StructBase {
|
||||
return this.storageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* get readable storage server count
|
||||
*
|
||||
* @return readable storage server count
|
||||
*/
|
||||
public int getReadableServerCount() {
|
||||
return this.readableServerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* get active storage server count in this group
|
||||
*
|
||||
* @return active storage server count in this group
|
||||
*/
|
||||
public int getActiveCount() {
|
||||
return this.activeCount;
|
||||
public int getWritableServerCount() {
|
||||
return this.writableServerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,15 +195,6 @@ public class StructGroupStat extends StructBase {
|
||||
return this.storagePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage server HTTP port
|
||||
*
|
||||
* @return storage server HTTP port
|
||||
*/
|
||||
public int getStorageHttpPort() {
|
||||
return this.storageHttpPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current storage server index to upload file
|
||||
*
|
||||
@@ -212,11 +241,12 @@ public class StructGroupStat extends StructBase {
|
||||
this.groupName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_GROUP_NAME]);
|
||||
this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);
|
||||
this.freeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_FREE_MB]);
|
||||
this.reservedMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_RESERVED_MB]);
|
||||
this.trunkFreeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TRUNK_FREE_MB]);
|
||||
this.storageCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_COUNT]);
|
||||
this.storagePort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_PORT]);
|
||||
this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
|
||||
this.activeCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_ACTIVE_COUNT]);
|
||||
this.readableServerCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_READABLE_SERVER_COUNT]);
|
||||
this.writableServerCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_WRITABLE_SERVER_COUNT]);
|
||||
this.currentWriteServer = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER]);
|
||||
this.storePathCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORE_PATH_COUNT]);
|
||||
this.subdirCountPerPath = intValue(bs, offset, fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH]);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (C) 2025 Happy Fish / YuQing
|
||||
* <p>
|
||||
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
|
||||
* General Public License (LGPL).
|
||||
* Please visit the FastDFS Home Page https://github.com/happyfish100/fastdfs for more detail.
|
||||
*/
|
||||
|
||||
package org.csource.fastdfs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* C struct body decoder
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.36
|
||||
*/
|
||||
public class StructIPv4StorageStat extends StructStorageStat {
|
||||
protected static int fieldsTotalSize;
|
||||
protected static StructBase.FieldInfo[] fieldsArray =
|
||||
new StructBase.FieldInfo[StructStorageStat.FIELD_COUNT];
|
||||
|
||||
static {
|
||||
fieldsTotalSize = StructStorageStat.initFieldsArray(
|
||||
fieldsArray, ProtoCommon.FDFS_IPV4_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* get fields total size
|
||||
*
|
||||
* @return fields total size
|
||||
*/
|
||||
public static int getFieldsTotalSize() {
|
||||
return fieldsTotalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bs byte array
|
||||
* @param offset start offset
|
||||
*/
|
||||
public void setFields(byte[] bs, int offset) {
|
||||
super.setFields(fieldsArray, bs, offset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (C) 2025 Happy Fish / YuQing
|
||||
* <p>
|
||||
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
|
||||
* General Public License (LGPL).
|
||||
* Please visit the FastDFS Home Page https://github.com/happyfish100/fastdfs for more detail.
|
||||
*/
|
||||
|
||||
package org.csource.fastdfs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* C struct body decoder
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.36
|
||||
*/
|
||||
public class StructIPv6StorageStat extends StructStorageStat {
|
||||
protected static int fieldsTotalSize;
|
||||
protected static StructBase.FieldInfo[] fieldsArray =
|
||||
new StructBase.FieldInfo[StructStorageStat.FIELD_COUNT];
|
||||
|
||||
static {
|
||||
fieldsTotalSize = StructStorageStat.initFieldsArray(
|
||||
fieldsArray, ProtoCommon.FDFS_IPV6_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* get fields total size
|
||||
*
|
||||
* @return fields total size
|
||||
*/
|
||||
public static int getFieldsTotalSize() {
|
||||
return fieldsTotalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bs byte array
|
||||
* @param offset start offset
|
||||
*/
|
||||
public void setFields(byte[] bs, int offset) {
|
||||
super.setFields(fieldsArray, bs, offset);
|
||||
}
|
||||
}
|
||||
@@ -14,25 +14,26 @@ import java.util.Date;
|
||||
* C struct body decoder
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.25
|
||||
* @version Version 1.35
|
||||
*/
|
||||
public class StructStorageStat extends StructBase {
|
||||
protected static final int FIELD_INDEX_STATUS = 0;
|
||||
protected static final int FIELD_INDEX_ID = 1;
|
||||
protected static final int FIELD_INDEX_IP_ADDR = 2;
|
||||
protected static final int FIELD_INDEX_DOMAIN_NAME = 3;
|
||||
protected static final int FIELD_INDEX_RW_MODE = 1;
|
||||
protected static final int FIELD_INDEX_ID = 2;
|
||||
protected static final int FIELD_INDEX_IP_ADDR = 3;
|
||||
protected static final int FIELD_INDEX_SRC_ID = 4;
|
||||
protected static final int FIELD_INDEX_VERSION = 5;
|
||||
protected static final int FIELD_INDEX_JOIN_TIME = 6;
|
||||
protected static final int FIELD_INDEX_UP_TIME = 7;
|
||||
protected static final int FIELD_INDEX_TOTAL_MB = 8;
|
||||
protected static final int FIELD_INDEX_FREE_MB = 9;
|
||||
protected static final int FIELD_INDEX_UPLOAD_PRIORITY = 10;
|
||||
protected static final int FIELD_INDEX_STORE_PATH_COUNT = 11;
|
||||
protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 12;
|
||||
protected static final int FIELD_INDEX_CURRENT_WRITE_PATH = 13;
|
||||
protected static final int FIELD_INDEX_STORAGE_PORT = 14;
|
||||
protected static final int FIELD_INDEX_STORAGE_HTTP_PORT = 15;
|
||||
protected static final int FIELD_INDEX_RESERVED_MB = 10;
|
||||
|
||||
protected static final int FIELD_INDEX_UPLOAD_PRIORITY = 11;
|
||||
protected static final int FIELD_INDEX_STORE_PATH_COUNT = 12;
|
||||
protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 13;
|
||||
protected static final int FIELD_INDEX_CURRENT_WRITE_PATH = 14;
|
||||
protected static final int FIELD_INDEX_STORAGE_PORT = 15;
|
||||
|
||||
protected static final int FIELD_INDEX_CONNECTION_ALLOC_COUNT = 16;
|
||||
protected static final int FIELD_INDEX_CONNECTION_CURRENT_COUNT = 17;
|
||||
@@ -82,216 +83,277 @@ public class StructStorageStat extends StructBase {
|
||||
protected static final int FIELD_INDEX_LAST_HEART_BEAT_TIME = 60;
|
||||
protected static final int FIELD_INDEX_IF_TRUNK_FILE = 61;
|
||||
|
||||
protected static int fieldsTotalSize;
|
||||
protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[62];
|
||||
protected static final int FIELD_COUNT = 62;
|
||||
|
||||
static {
|
||||
int offset = 0;
|
||||
protected static int initFieldsArray(StructBase.FieldInfo[] fieldsArray, int ipaddr_size) {
|
||||
int offset = 0;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STATUS] = new StructBase.FieldInfo("status", offset, 1);
|
||||
offset += 1;
|
||||
fieldsArray[FIELD_INDEX_STATUS] = new StructBase.FieldInfo(
|
||||
"status", offset, 1);
|
||||
offset += 1;
|
||||
|
||||
fieldsArray[FIELD_INDEX_ID] = new StructBase.FieldInfo("id", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
|
||||
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
|
||||
fieldsArray[FIELD_INDEX_RW_MODE] = new StructBase.FieldInfo(
|
||||
"readWriteMode", offset, 1);
|
||||
offset += 1;
|
||||
|
||||
fieldsArray[FIELD_INDEX_IP_ADDR] = new StructBase.FieldInfo("ipAddr", offset, ProtoCommon.FDFS_IPADDR_SIZE);
|
||||
offset += ProtoCommon.FDFS_IPADDR_SIZE;
|
||||
fieldsArray[FIELD_INDEX_ID] = new StructBase.FieldInfo(
|
||||
"id", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
|
||||
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_DOMAIN_NAME] = new StructBase.FieldInfo("domainName", offset, ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE);
|
||||
offset += ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE;
|
||||
fieldsArray[FIELD_INDEX_IP_ADDR] = new StructBase.FieldInfo(
|
||||
"ipAddr", offset, ipaddr_size);
|
||||
offset += ipaddr_size;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SRC_ID] = new StructBase.FieldInfo("srcId", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
|
||||
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SRC_ID] = new StructBase.FieldInfo(
|
||||
"srcId", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
|
||||
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_VERSION] = new StructBase.FieldInfo("version", offset, ProtoCommon.FDFS_VERSION_SIZE);
|
||||
offset += ProtoCommon.FDFS_VERSION_SIZE;
|
||||
fieldsArray[FIELD_INDEX_VERSION] = new StructBase.FieldInfo(
|
||||
"version", offset, ProtoCommon.FDFS_VERSION_SIZE);
|
||||
offset += ProtoCommon.FDFS_VERSION_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_JOIN_TIME] = new StructBase.FieldInfo("joinTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_JOIN_TIME] = new StructBase.FieldInfo(
|
||||
"joinTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_UP_TIME] = new StructBase.FieldInfo("upTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_UP_TIME] = new StructBase.FieldInfo(
|
||||
"upTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo("totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo(
|
||||
"totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo("freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo(
|
||||
"freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_UPLOAD_PRIORITY] = new StructBase.FieldInfo("uploadPriority", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_RESERVED_MB] = new StructBase.FieldInfo(
|
||||
"reservedMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo("storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_UPLOAD_PRIORITY] = new StructBase.FieldInfo(
|
||||
"uploadPriority", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo("subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo(
|
||||
"storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH] = new StructBase.FieldInfo("currentWritePath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo(
|
||||
"subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo("storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH] = new StructBase.FieldInfo(
|
||||
"currentWritePath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT] = new StructBase.FieldInfo("storageHttpPort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo(
|
||||
"storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_ALLOC_COUNT] = new StructBase.FieldInfo("connectionAllocCount", offset, 4);
|
||||
offset += 4;
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_ALLOC_COUNT] = new StructBase.FieldInfo(
|
||||
"connectionAllocCount", offset, 4);
|
||||
offset += 4;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_CURRENT_COUNT] = new StructBase.FieldInfo("connectionCurrentCount", offset, 4);
|
||||
offset += 4;
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_CURRENT_COUNT] = new StructBase.FieldInfo(
|
||||
"connectionCurrentCount", offset, 4);
|
||||
offset += 4;
|
||||
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_MAX_COUNT] = new StructBase.FieldInfo("connectionMaxCount", offset, 4);
|
||||
offset += 4;
|
||||
fieldsArray[FIELD_INDEX_CONNECTION_MAX_COUNT] = new StructBase.FieldInfo(
|
||||
"connectionMaxCount", offset, 4);
|
||||
offset += 4;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_COUNT] = new StructBase.FieldInfo("totalUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_COUNT] = new StructBase.FieldInfo(
|
||||
"totalUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_COUNT] = new StructBase.FieldInfo("successUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_COUNT] = new StructBase.FieldInfo(
|
||||
"successUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_APPEND_COUNT] = new StructBase.FieldInfo("totalAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_APPEND_COUNT] = new StructBase.FieldInfo(
|
||||
"totalAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_APPEND_COUNT] = new StructBase.FieldInfo("successAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_APPEND_COUNT] = new StructBase.FieldInfo(
|
||||
"successAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MODIFY_COUNT] = new StructBase.FieldInfo("totalModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MODIFY_COUNT] = new StructBase.FieldInfo(
|
||||
"totalModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_COUNT] = new StructBase.FieldInfo("successModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_COUNT] = new StructBase.FieldInfo(
|
||||
"successModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_TRUNCATE_COUNT] = new StructBase.FieldInfo("totalTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_TRUNCATE_COUNT] = new StructBase.FieldInfo(
|
||||
"totalTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_TRUNCATE_COUNT] = new StructBase.FieldInfo("successTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_TRUNCATE_COUNT] = new StructBase.FieldInfo(
|
||||
"successTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SET_META_COUNT] = new StructBase.FieldInfo("totalSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SET_META_COUNT] = new StructBase.FieldInfo(
|
||||
"totalSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SET_META_COUNT] = new StructBase.FieldInfo("successSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SET_META_COUNT] = new StructBase.FieldInfo(
|
||||
"successSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DELETE_COUNT] = new StructBase.FieldInfo("totalDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DELETE_COUNT] = new StructBase.FieldInfo(
|
||||
"totalDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DELETE_COUNT] = new StructBase.FieldInfo("successDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DELETE_COUNT] = new StructBase.FieldInfo(
|
||||
"successDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_COUNT] = new StructBase.FieldInfo("totalDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_COUNT] = new StructBase.FieldInfo(
|
||||
"totalDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_COUNT] = new StructBase.FieldInfo("successDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_COUNT] = new StructBase.FieldInfo(
|
||||
"successDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_GET_META_COUNT] = new StructBase.FieldInfo("totalGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_GET_META_COUNT] = new StructBase.FieldInfo(
|
||||
"totalGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_GET_META_COUNT] = new StructBase.FieldInfo("successGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_GET_META_COUNT] = new StructBase.FieldInfo(
|
||||
"successGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_CREATE_LINK_COUNT] = new StructBase.FieldInfo("totalCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_CREATE_LINK_COUNT] = new StructBase.FieldInfo(
|
||||
"totalCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_CREATE_LINK_COUNT] = new StructBase.FieldInfo("successCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_CREATE_LINK_COUNT] = new StructBase.FieldInfo(
|
||||
"successCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DELETE_LINK_COUNT] = new StructBase.FieldInfo("totalDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DELETE_LINK_COUNT] = new StructBase.FieldInfo(
|
||||
"totalDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DELETE_LINK_COUNT] = new StructBase.FieldInfo("successDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DELETE_LINK_COUNT] = new StructBase.FieldInfo(
|
||||
"successDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_BYTES] = new StructBase.FieldInfo("totalUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_BYTES] = new StructBase.FieldInfo(
|
||||
"totalUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_BYTES] = new StructBase.FieldInfo("successUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_BYTES] = new StructBase.FieldInfo(
|
||||
"successUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_APPEND_BYTES] = new StructBase.FieldInfo("totalAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_APPEND_BYTES] = new StructBase.FieldInfo(
|
||||
"totalAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_APPEND_BYTES] = new StructBase.FieldInfo("successAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_APPEND_BYTES] = new StructBase.FieldInfo(
|
||||
"successAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MODIFY_BYTES] = new StructBase.FieldInfo("totalModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_MODIFY_BYTES] = new StructBase.FieldInfo(
|
||||
"totalModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_BYTES] = new StructBase.FieldInfo("successModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_BYTES] = new StructBase.FieldInfo(
|
||||
"successModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_BYTES] = new StructBase.FieldInfo("totalDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_BYTES] = new StructBase.FieldInfo(
|
||||
"totalDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_BYTES] = new StructBase.FieldInfo("successDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_BYTES] = new StructBase.FieldInfo(
|
||||
"successDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SYNC_IN_BYTES] = new StructBase.FieldInfo("totalSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SYNC_IN_BYTES] = new StructBase.FieldInfo(
|
||||
"totalSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SYNC_IN_BYTES] = new StructBase.FieldInfo("successSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SYNC_IN_BYTES] = new StructBase.FieldInfo(
|
||||
"successSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SYNC_OUT_BYTES] = new StructBase.FieldInfo("totalSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_SYNC_OUT_BYTES] = new StructBase.FieldInfo(
|
||||
"totalSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SYNC_OUT_BYTES] = new StructBase.FieldInfo("successSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_SYNC_OUT_BYTES] = new StructBase.FieldInfo(
|
||||
"successSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_OPEN_COUNT] = new StructBase.FieldInfo("totalFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_OPEN_COUNT] = new StructBase.FieldInfo(
|
||||
"totalFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_OPEN_COUNT] = new StructBase.FieldInfo("successFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_OPEN_COUNT] = new StructBase.FieldInfo(
|
||||
"successFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_READ_COUNT] = new StructBase.FieldInfo("totalFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_READ_COUNT] = new StructBase.FieldInfo(
|
||||
"totalFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_READ_COUNT] = new StructBase.FieldInfo("successFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_READ_COUNT] = new StructBase.FieldInfo(
|
||||
"successFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_WRITE_COUNT] = new StructBase.FieldInfo("totalFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_TOTAL_FILE_WRITE_COUNT] = new StructBase.FieldInfo(
|
||||
"totalFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_WRITE_COUNT] = new StructBase.FieldInfo("successFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_SUCCESS_FILE_WRITE_COUNT] = new StructBase.FieldInfo(
|
||||
"successFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_LAST_SOURCE_UPDATE] = new StructBase.FieldInfo("lastSourceUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_LAST_SOURCE_UPDATE] = new StructBase.FieldInfo(
|
||||
"lastSourceUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_LAST_SYNC_UPDATE] = new StructBase.FieldInfo("lastSyncUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_LAST_SYNC_UPDATE] = new StructBase.FieldInfo(
|
||||
"lastSyncUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_LAST_SYNCED_TIMESTAMP] = new StructBase.FieldInfo("lastSyncedTimestamp", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_LAST_SYNCED_TIMESTAMP] = new StructBase.FieldInfo(
|
||||
"lastSyncedTimestamp", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME] = new StructBase.FieldInfo("lastHeartBeatTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME] = new StructBase.FieldInfo(
|
||||
"lastHeartBeatTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
fieldsArray[FIELD_INDEX_IF_TRUNK_FILE] = new StructBase.FieldInfo("ifTrunkServer", offset, 1);
|
||||
offset += 1;
|
||||
fieldsArray[FIELD_INDEX_IF_TRUNK_FILE] = new StructBase.FieldInfo(
|
||||
"ifTrunkServer", offset, 1);
|
||||
offset += 1;
|
||||
|
||||
fieldsTotalSize = offset;
|
||||
return offset;
|
||||
}
|
||||
|
||||
protected byte status;
|
||||
protected byte readWriteMode;
|
||||
protected String id;
|
||||
protected String ipAddr;
|
||||
protected String srcId;
|
||||
protected String domainName; //http domain name
|
||||
protected String version;
|
||||
protected long totalMB; //total disk storage in MB
|
||||
protected long freeMB; //free disk storage in MB
|
||||
protected long totalMB; //total disk space in MB
|
||||
protected long freeMB; //free disk space in MB
|
||||
protected long reservedMB; //reserved disk space in MB
|
||||
protected int uploadPriority; //upload priority
|
||||
protected Date joinTime; //storage join timestamp (create timestamp)
|
||||
protected Date upTime; //storage service started timestamp
|
||||
protected int storePathCount; //store base path count of each storage server
|
||||
protected int subdirCountPerPath;
|
||||
protected int storagePort;
|
||||
protected int storageHttpPort; //storage http server port
|
||||
protected int currentWritePath; //current write path index
|
||||
protected int connectionAllocCount;
|
||||
protected int connectionCurrentCount;
|
||||
@@ -340,15 +402,6 @@ public class StructStorageStat extends StructBase {
|
||||
protected Date lastHeartBeatTime;
|
||||
protected boolean ifTrunkServer;
|
||||
|
||||
/**
|
||||
* get fields total size
|
||||
*
|
||||
* @return fields total size
|
||||
*/
|
||||
public static int getFieldsTotalSize() {
|
||||
return fieldsTotalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage status
|
||||
*
|
||||
@@ -358,6 +411,15 @@ public class StructStorageStat extends StructBase {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the read write mode
|
||||
*
|
||||
* @return the read write mode
|
||||
*/
|
||||
public byte getReadWriteMode() {
|
||||
return this.readWriteMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage server id
|
||||
*
|
||||
@@ -385,15 +447,6 @@ public class StructStorageStat extends StructBase {
|
||||
return this.srcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the domain name of the storage server
|
||||
*
|
||||
* @return the domain name of the storage server
|
||||
*/
|
||||
public String getDomainName() {
|
||||
return this.domainName;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage version
|
||||
*
|
||||
@@ -421,6 +474,15 @@ public class StructStorageStat extends StructBase {
|
||||
return this.freeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* get reserved disk space in MB
|
||||
*
|
||||
* @return reserved disk space in MB
|
||||
*/
|
||||
public long getReservedMB() {
|
||||
return this.reservedMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage server upload priority
|
||||
*
|
||||
@@ -475,15 +537,6 @@ public class StructStorageStat extends StructBase {
|
||||
return this.storagePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* get storage server HTTP port
|
||||
*
|
||||
* @return storage server HTTP port
|
||||
*/
|
||||
public int getStorageHttpPort() {
|
||||
return this.storageHttpPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current write path index
|
||||
*
|
||||
@@ -913,22 +966,22 @@ public class StructStorageStat extends StructBase {
|
||||
* @param bs byte array
|
||||
* @param offset start offset
|
||||
*/
|
||||
public void setFields(byte[] bs, int offset) {
|
||||
protected void setFields(StructBase.FieldInfo[] fieldsArray, byte[] bs, int offset) {
|
||||
this.status = byteValue(bs, offset, fieldsArray[FIELD_INDEX_STATUS]);
|
||||
this.readWriteMode = byteValue(bs, offset, fieldsArray[FIELD_INDEX_RW_MODE]);
|
||||
this.id = stringValue(bs, offset, fieldsArray[FIELD_INDEX_ID]);
|
||||
this.ipAddr = stringValue(bs, offset, fieldsArray[FIELD_INDEX_IP_ADDR]);
|
||||
this.srcId = stringValue(bs, offset, fieldsArray[FIELD_INDEX_SRC_ID]);
|
||||
this.domainName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_DOMAIN_NAME]);
|
||||
this.version = stringValue(bs, offset, fieldsArray[FIELD_INDEX_VERSION]);
|
||||
this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);
|
||||
this.freeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_FREE_MB]);
|
||||
this.reservedMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_RESERVED_MB]);
|
||||
this.uploadPriority = intValue(bs, offset, fieldsArray[FIELD_INDEX_UPLOAD_PRIORITY]);
|
||||
this.joinTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_JOIN_TIME]);
|
||||
this.upTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_UP_TIME]);
|
||||
this.storePathCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORE_PATH_COUNT]);
|
||||
this.subdirCountPerPath = intValue(bs, offset, fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH]);
|
||||
this.storagePort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_PORT]);
|
||||
this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
|
||||
this.currentWritePath = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH]);
|
||||
|
||||
this.connectionAllocCount = int32Value(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_ALLOC_COUNT]);
|
||||
@@ -979,4 +1032,7 @@ public class StructStorageStat extends StructBase {
|
||||
this.lastHeartBeatTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME]);
|
||||
this.ifTrunkServer = booleanValue(bs, offset, fieldsArray[FIELD_INDEX_IF_TRUNK_FILE]);
|
||||
}
|
||||
|
||||
public void setFields(byte[] bs, int offset) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ public class TrackerClient {
|
||||
connection = trackerServer.getConnection();
|
||||
} catch (IOException e) {
|
||||
if (failOver) {
|
||||
System.err.println("trackerServer get connection error, emsg:" + e.getMessage());
|
||||
System.err.println("trackerServer get connection error, " + e.getMessage());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
} catch (MyException e) {
|
||||
if (failOver) {
|
||||
System.err.println("trackerServer get connection error, emsg:" + e.getMessage());
|
||||
System.err.println("trackerServer get connection error, " + e.getMessage());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
@@ -118,19 +118,19 @@ public class TrackerClient {
|
||||
}
|
||||
return trackerServer.getConnection();
|
||||
} catch (IOException e) {
|
||||
System.err.println("fail over trackerServer get connection error, failOverCount:" + failOverCount + "," + e.getMessage());
|
||||
System.err.println("fail over trackerServer get connection error, "
|
||||
+ "failOverCount: " + failOverCount + ", " + e.getMessage());
|
||||
if (failOverCount == length - 1) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
} catch (MyException e) {
|
||||
System.err.println("fail over trackerServer get connection error, failOverCount:" + failOverCount + ", " + e.getMessage());
|
||||
System.err.println("fail over trackerServer get connection error, "
|
||||
+ "failOverCount: " + failOverCount + ", " + e.getMessage());
|
||||
if (failOverCount == length - 1) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -183,18 +183,30 @@ public class TrackerClient {
|
||||
}
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP,
|
||||
ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ip_addr = new String(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN, ProtoCommon.FDFS_IPADDR_SIZE - 1).trim();
|
||||
if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_STORE_IPV4_BODY_LEN) {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
port = (int) ProtoCommon.buff2long(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN
|
||||
+ ProtoCommon.FDFS_IPADDR_SIZE - 1);
|
||||
store_path = pkgInfo.body[ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN - 1];
|
||||
int ip_size;
|
||||
if (pkgInfo.body.length == ProtoCommon.TRACKER_QUERY_STORAGE_STORE_IPV6_BODY_LEN) {
|
||||
ip_size = ProtoCommon.FDFS_IPV6_SIZE;
|
||||
} else if (pkgInfo.body.length == ProtoCommon.TRACKER_QUERY_STORAGE_STORE_IPV4_BODY_LEN) {
|
||||
ip_size = ProtoCommon.FDFS_IPV4_SIZE;
|
||||
} else {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
ip_addr = new String(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN, ip_size - 1).trim();
|
||||
port = (int) ProtoCommon.buff2long(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ip_size - 1);
|
||||
store_path = pkgInfo.body[pkgInfo.body.length - 1];
|
||||
|
||||
return new StorageServer(ip_addr, port, store_path);
|
||||
} catch (IOException ex) {
|
||||
@@ -263,23 +275,32 @@ public class TrackerClient {
|
||||
}
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN) {
|
||||
if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_STORE_IPV4_BODY_LEN) {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
return null;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
int ipPortLen = pkgInfo.body.length - (ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
|
||||
final int recordLength = ProtoCommon.FDFS_IPADDR_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
if (ipPortLen % recordLength != 0) {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
return null;
|
||||
int recordLength = ProtoCommon.FDFS_IPV6_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
int ip_size;
|
||||
if ((pkgInfo.body.length >= ProtoCommon.TRACKER_QUERY_STORAGE_STORE_IPV6_BODY_LEN) &&
|
||||
ipPortLen % recordLength == 0)
|
||||
{
|
||||
ip_size = ProtoCommon.FDFS_IPV6_SIZE;
|
||||
} else {
|
||||
recordLength = ProtoCommon.FDFS_IPV4_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
if (ipPortLen % recordLength == 0) {
|
||||
ip_size = ProtoCommon.FDFS_IPV4_SIZE;
|
||||
} else {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
}
|
||||
|
||||
int serverCount = ipPortLen / recordLength;
|
||||
@@ -293,8 +314,8 @@ public class TrackerClient {
|
||||
int offset = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
|
||||
|
||||
for (int i = 0; i < serverCount; i++) {
|
||||
ip_addr = new String(pkgInfo.body, offset, ProtoCommon.FDFS_IPADDR_SIZE - 1).trim();
|
||||
offset += ProtoCommon.FDFS_IPADDR_SIZE - 1;
|
||||
ip_addr = new String(pkgInfo.body, offset, ip_size - 1).trim();
|
||||
offset += ip_size - 1;
|
||||
|
||||
port = (int) ProtoCommon.buff2long(pkgInfo.body, offset);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
@@ -332,7 +353,8 @@ public class TrackerClient {
|
||||
* @return storage server Socket object, return null if fail
|
||||
*/
|
||||
public StorageServer getFetchStorage(TrackerServer trackerServer,
|
||||
String groupName, String filename) throws IOException, MyException {
|
||||
String groupName, String filename) throws IOException, MyException
|
||||
{
|
||||
ServerInfo[] servers = this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE,
|
||||
groupName, filename);
|
||||
if (servers == null) {
|
||||
@@ -351,7 +373,8 @@ public class TrackerClient {
|
||||
* @return storage server Socket object, return null if fail
|
||||
*/
|
||||
public StorageServer getUpdateStorage(TrackerServer trackerServer,
|
||||
String groupName, String filename) throws IOException, MyException {
|
||||
String groupName, String filename) throws IOException, MyException
|
||||
{
|
||||
ServerInfo[] servers = this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE,
|
||||
groupName, filename);
|
||||
if (servers == null) {
|
||||
@@ -370,7 +393,8 @@ public class TrackerClient {
|
||||
* @return storage servers, return null if fail
|
||||
*/
|
||||
public ServerInfo[] getFetchStorages(TrackerServer trackerServer,
|
||||
String groupName, String filename) throws IOException, MyException {
|
||||
String groupName, String filename) throws IOException, MyException
|
||||
{
|
||||
return this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL,
|
||||
groupName, filename);
|
||||
}
|
||||
@@ -379,14 +403,17 @@ public class TrackerClient {
|
||||
* query storage server to download file
|
||||
*
|
||||
* @param trackerServer the tracker server
|
||||
* @param cmd command code, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE or
|
||||
* ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE
|
||||
* @param cmd command code, values list:
|
||||
* ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE
|
||||
* ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL
|
||||
* ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE
|
||||
* @param groupName the group name of storage server
|
||||
* @param filename filename on storage server
|
||||
* @return storage server Socket object, return null if fail
|
||||
*/
|
||||
protected ServerInfo[] getStorages(TrackerServer trackerServer,
|
||||
byte cmd, String groupName, String filename) throws IOException, MyException {
|
||||
protected ServerInfo[] getStorages(TrackerServer trackerServer, byte cmd,
|
||||
String groupName, String filename) throws IOException, MyException
|
||||
{
|
||||
byte[] header;
|
||||
byte[] bFileName;
|
||||
byte[] bGroupName;
|
||||
@@ -418,33 +445,47 @@ public class TrackerClient {
|
||||
out.write(wholePkg);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) {
|
||||
int server_count = 1;
|
||||
int ip_size;
|
||||
if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV4_BODY_LEN) {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
if ((pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) % (ProtoCommon.FDFS_IPADDR_SIZE - 1) != 0) {
|
||||
if ((pkgInfo.body.length >= ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV6_BODY_LEN) &&
|
||||
(pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV6_BODY_LEN) %
|
||||
(ProtoCommon.FDFS_IPV6_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE) == 0)
|
||||
{
|
||||
ip_size = ProtoCommon.FDFS_IPV6_SIZE;
|
||||
server_count += (pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV6_BODY_LEN) /
|
||||
(ProtoCommon.FDFS_IPV6_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
} else if ((pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV4_BODY_LEN) %
|
||||
(ProtoCommon.FDFS_IPV4_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE) == 0)
|
||||
{
|
||||
ip_size = ProtoCommon.FDFS_IPV4_SIZE;
|
||||
server_count += (pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_IPV4_BODY_LEN) /
|
||||
(ProtoCommon.FDFS_IPV4_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
|
||||
} else {
|
||||
this.errno = ProtoCommon.ERR_NO_EINVAL;
|
||||
throw new IOException("Invalid body length: " + pkgInfo.body.length);
|
||||
}
|
||||
|
||||
int server_count = 1 + (pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) / (ProtoCommon.FDFS_IPADDR_SIZE - 1);
|
||||
|
||||
ip_addr = new String(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN, ProtoCommon.FDFS_IPADDR_SIZE - 1).trim();
|
||||
int offset = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ProtoCommon.FDFS_IPADDR_SIZE - 1;
|
||||
|
||||
port = (int) ProtoCommon.buff2long(pkgInfo.body, offset);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
int offset = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
|
||||
ServerInfo[] servers = new ServerInfo[server_count];
|
||||
servers[0] = new ServerInfo(ip_addr, port);
|
||||
for (int i = 1; i < server_count; i++) {
|
||||
servers[i] = new ServerInfo(new String(pkgInfo.body, offset, ProtoCommon.FDFS_IPADDR_SIZE - 1).trim(), port);
|
||||
offset += ProtoCommon.FDFS_IPADDR_SIZE - 1;
|
||||
for (int i = 0; i < server_count; i++) {
|
||||
ip_addr = new String(pkgInfo.body, offset, ip_size - 1).trim();
|
||||
offset += ip_size - 1;
|
||||
|
||||
port = (int) ProtoCommon.buff2long(pkgInfo.body, offset);
|
||||
offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
||||
servers[i] = new ServerInfo(ip_addr, port);
|
||||
}
|
||||
|
||||
return servers;
|
||||
@@ -524,7 +565,7 @@ public class TrackerClient {
|
||||
out.write(header);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
@@ -568,6 +609,20 @@ public class TrackerClient {
|
||||
return this.listStorages(trackerServer, groupName, storageIpAddr);
|
||||
}
|
||||
|
||||
private int getIpaddrLength(String ip, byte[] bIpAddr) {
|
||||
if (bIpAddr.length < ProtoCommon.FDFS_IPV4_SIZE) {
|
||||
return bIpAddr.length;
|
||||
} else if (ip.indexOf(':') >= 0) { //IPv6 address
|
||||
if (bIpAddr.length < ProtoCommon.FDFS_IPV6_SIZE) {
|
||||
return bIpAddr.length;
|
||||
} else {
|
||||
return ProtoCommon.FDFS_IPV6_SIZE - 1;
|
||||
}
|
||||
} else { //IPv4 address
|
||||
return ProtoCommon.FDFS_IPV4_SIZE - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* query storage server stat info of the group
|
||||
*
|
||||
@@ -576,8 +631,8 @@ public class TrackerClient {
|
||||
* @param storageIpAddr the storage server ip address, can be null or empty
|
||||
* @return storage server stat array, return null if fail
|
||||
*/
|
||||
public StructStorageStat[] listStorages(TrackerServer trackerServer,
|
||||
String groupName, String storageIpAddr) throws IOException, MyException {
|
||||
public StructStorageStat[] listStorages(TrackerServer trackerServer, String groupName,
|
||||
String storageIpAddr) throws IOException, MyException {
|
||||
byte[] header;
|
||||
byte[] bGroupName;
|
||||
byte[] bs;
|
||||
@@ -601,17 +656,14 @@ public class TrackerClient {
|
||||
byte[] bIpAddr;
|
||||
if (storageIpAddr != null && storageIpAddr.length() > 0) {
|
||||
bIpAddr = storageIpAddr.getBytes(ClientGlobal.g_charset);
|
||||
if (bIpAddr.length < ProtoCommon.FDFS_IPADDR_SIZE) {
|
||||
ipAddrLen = bIpAddr.length;
|
||||
} else {
|
||||
ipAddrLen = ProtoCommon.FDFS_IPADDR_SIZE - 1;
|
||||
}
|
||||
ipAddrLen = getIpaddrLength(storageIpAddr, bIpAddr);
|
||||
} else {
|
||||
bIpAddr = null;
|
||||
ipAddrLen = 0;
|
||||
}
|
||||
|
||||
header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_STORAGE, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte) 0);
|
||||
header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_STORAGE,
|
||||
ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte) 0);
|
||||
byte[] wholePkg = new byte[header.length + bGroupName.length + ipAddrLen];
|
||||
System.arraycopy(header, 0, wholePkg, 0, header.length);
|
||||
System.arraycopy(bGroupName, 0, wholePkg, header.length, bGroupName.length);
|
||||
@@ -621,14 +673,23 @@ public class TrackerClient {
|
||||
out.write(wholePkg);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ProtoStructDecoder<StructStorageStat> decoder = new ProtoStructDecoder<StructStorageStat>();
|
||||
return decoder.decode(pkgInfo.body, StructStorageStat.class, StructStorageStat.getFieldsTotalSize());
|
||||
if (pkgInfo.body.length % StructIPv6StorageStat.getFieldsTotalSize() == 0) {
|
||||
ProtoStructDecoder<StructIPv6StorageStat> decoder =
|
||||
new ProtoStructDecoder<StructIPv6StorageStat>();
|
||||
return decoder.decode(pkgInfo.body, StructIPv6StorageStat.class,
|
||||
StructIPv6StorageStat.getFieldsTotalSize());
|
||||
} else {
|
||||
ProtoStructDecoder<StructIPv4StorageStat> decoder =
|
||||
new ProtoStructDecoder<StructIPv4StorageStat>();
|
||||
return decoder.decode(pkgInfo.body, StructIPv4StorageStat.class,
|
||||
StructIPv4StorageStat.getFieldsTotalSize());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
try {
|
||||
connection.close();
|
||||
@@ -683,14 +744,8 @@ public class TrackerClient {
|
||||
Arrays.fill(bGroupName, (byte) 0);
|
||||
System.arraycopy(bs, 0, bGroupName, 0, len);
|
||||
|
||||
int ipAddrLen;
|
||||
byte[] bIpAddr = storageIpAddr.getBytes(ClientGlobal.g_charset);
|
||||
if (bIpAddr.length < ProtoCommon.FDFS_IPADDR_SIZE) {
|
||||
ipAddrLen = bIpAddr.length;
|
||||
} else {
|
||||
ipAddrLen = ProtoCommon.FDFS_IPADDR_SIZE - 1;
|
||||
}
|
||||
|
||||
int ipAddrLen = getIpaddrLength(storageIpAddr, bIpAddr);
|
||||
header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_DELETE_STORAGE, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte) 0);
|
||||
byte[] wholePkg = new byte[header.length + bGroupName.length + ipAddrLen];
|
||||
System.arraycopy(header, 0, wholePkg, 0, header.length);
|
||||
@@ -699,7 +754,7 @@ public class TrackerClient {
|
||||
out.write(wholePkg);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, 0);
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, 0);
|
||||
this.errno = pkgInfo.errno;
|
||||
return pkgInfo.errno == 0;
|
||||
} catch (IOException e) {
|
||||
@@ -814,7 +869,7 @@ public class TrackerClient {
|
||||
* @param groupName the group name to upload file to, can be empty
|
||||
* @return storage server object, return null if fail
|
||||
*/
|
||||
public StringBuilder fetchStorageIds() throws IOException, MyException {
|
||||
public StringBuilder fetchStorageIds(boolean haveAllowEmptyField) throws IOException, MyException {
|
||||
byte[] header;
|
||||
int offset = 0;
|
||||
int length;
|
||||
@@ -823,21 +878,28 @@ public class TrackerClient {
|
||||
|
||||
Connection connection = getConnection(null);
|
||||
try {
|
||||
int reqBodyLength;
|
||||
OutputStream out = connection.getOutputStream();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_FETCH_STORAGE_IDS, 5, (byte)0);
|
||||
byte[] wholePkg = new byte[header.length + 5];
|
||||
if (haveAllowEmptyField) {
|
||||
reqBodyLength = 5;
|
||||
} else {
|
||||
reqBodyLength = 4;
|
||||
}
|
||||
header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_FETCH_STORAGE_IDS, reqBodyLength, (byte)0);
|
||||
byte[] wholePkg = new byte[header.length + reqBodyLength];
|
||||
System.arraycopy(header, 0, wholePkg, 0, header.length);
|
||||
wholePkg[wholePkg.length - 1] = 1;
|
||||
if (haveAllowEmptyField) {
|
||||
wholePkg[wholePkg.length - 1] = 1;
|
||||
}
|
||||
do {
|
||||
byte[] bs = ProtoCommon.int2buff(offset);
|
||||
System.arraycopy(bs, 0, wholePkg, header.length, bs.length);
|
||||
out.write(wholePkg);
|
||||
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(
|
||||
connection.getInputStream(),
|
||||
ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(connection.getInputStream(),
|
||||
connection.getInetSocketAddress(), ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
|
||||
this.errno = pkgInfo.errno;
|
||||
if (pkgInfo.errno != 0) {
|
||||
return null;
|
||||
|
||||
@@ -97,6 +97,7 @@ public class Connection {
|
||||
}
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
public boolean isAvaliable() {
|
||||
if (isConnected()) {
|
||||
if (sock.getPort() == 0) {
|
||||
@@ -119,6 +120,10 @@ public class Connection {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return this.sock == null;
|
||||
}
|
||||
|
||||
public boolean isNeedActiveTest() {
|
||||
return needActiveTest;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ public class ConnectionFactory {
|
||||
sock.connect(socketAddress, ClientGlobal.g_connect_timeout);
|
||||
return new Connection(sock, socketAddress);
|
||||
} catch (Exception e) {
|
||||
throw new MyException("connect to server " + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + " fail, emsg:" + e.getMessage());
|
||||
throw new MyException("connect to server " + socketAddress.getAddress().getHostAddress()
|
||||
+ ":" + socketAddress.getPort() + " fail, emsg: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,6 @@ public class ConnectionManager {
|
||||
*/
|
||||
private AtomicInteger totalCount = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* free connection count
|
||||
*/
|
||||
private AtomicInteger freeCount = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* lock
|
||||
*/
|
||||
@@ -50,10 +45,11 @@ public class ConnectionManager {
|
||||
try {
|
||||
Connection connection = null;
|
||||
while (true) {
|
||||
if (freeCount.get() > 0) {
|
||||
freeCount.decrementAndGet();
|
||||
connection = freeConnections.poll();
|
||||
if (!connection.isAvaliable() || (System.currentTimeMillis() - connection.getLastAccessTime()) > ClientGlobal.g_connection_pool_max_idle_time) {
|
||||
connection = freeConnections.poll();
|
||||
if (connection != null) {
|
||||
if (!connection.isAvaliable() || (System.currentTimeMillis() - connection.getLastAccessTime()) >
|
||||
ClientGlobal.g_connection_pool_max_idle_time)
|
||||
{
|
||||
closeConnection(connection);
|
||||
continue;
|
||||
}
|
||||
@@ -62,7 +58,8 @@ public class ConnectionManager {
|
||||
try {
|
||||
isActive = connection.activeTest();
|
||||
} catch (IOException e) {
|
||||
System.err.println("send to server[" + inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort() + "] active test error ,emsg:" + e.getMessage());
|
||||
System.err.println("send to server " + inetSocketAddress.getAddress().getHostAddress()
|
||||
+ ":" + inetSocketAddress.getPort() + " active test error, emsg: " + e.getMessage());
|
||||
isActive = false;
|
||||
}
|
||||
if (!isActive) {
|
||||
@@ -72,7 +69,9 @@ public class ConnectionManager {
|
||||
connection.setNeedActiveTest(false);
|
||||
}
|
||||
}
|
||||
} else if (ClientGlobal.g_connection_pool_max_count_per_entry == 0 || totalCount.get() < ClientGlobal.g_connection_pool_max_count_per_entry) {
|
||||
} else if (ClientGlobal.g_connection_pool_max_count_per_entry == 0 ||
|
||||
totalCount.get() < ClientGlobal.g_connection_pool_max_count_per_entry)
|
||||
{
|
||||
connection = ConnectionFactory.create(this.inetSocketAddress);
|
||||
totalCount.incrementAndGet();
|
||||
} else {
|
||||
@@ -81,10 +80,17 @@ public class ConnectionManager {
|
||||
//wait single success
|
||||
continue;
|
||||
}
|
||||
throw new MyException("connect to server " + inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort() + " fail, wait_time > " + ClientGlobal.g_connection_pool_max_wait_time_in_ms + "ms");
|
||||
|
||||
throw new MyException("connections reach max_count_per_entry: "
|
||||
+ ClientGlobal.g_connection_pool_max_count_per_entry + ", "
|
||||
+ "await connection for server " + inetSocketAddress.getAddress().getHostAddress()
|
||||
+ ":" + inetSocketAddress.getPort() + " timeout, wait_time > "
|
||||
+ ClientGlobal.g_connection_pool_max_wait_time_in_ms + " ms");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
throw new MyException("connect to server " + inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort() + " fail, emsg:" + e.getMessage());
|
||||
throw new MyException("connection full, await connection for server "
|
||||
+ inetSocketAddress.getAddress().getHostAddress()
|
||||
+ ":" + inetSocketAddress.getPort() + " fail, emsg: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
@@ -98,50 +104,51 @@ public class ConnectionManager {
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
connection.setLastAccessTime(System.currentTimeMillis());
|
||||
freeConnections.add(connection);
|
||||
freeCount.incrementAndGet();
|
||||
condition.signal();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void closeConnection(Connection connection) {
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (connection != null) {
|
||||
if (!connection.isClosed()) {
|
||||
totalCount.decrementAndGet();
|
||||
connection.closeDirectly();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("close socket[" + inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort() + "] error ,emsg:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
System.err.println("close socket[" + inetSocketAddress.getAddress().getHostAddress()
|
||||
+ ":" + inetSocketAddress.getPort() + "] error, emsg: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setActiveTestFlag() {
|
||||
if (freeCount.get() > 0) {
|
||||
lock.lock();
|
||||
try {
|
||||
for (Connection freeConnection : freeConnections) {
|
||||
freeConnection.setNeedActiveTest(true);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
lock.lock();
|
||||
try {
|
||||
for (Connection freeConnection : freeConnections) {
|
||||
freeConnection.setNeedActiveTest(true);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConnectionManager{" +
|
||||
"ip:port='" + inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort() +
|
||||
", totalCount=" + totalCount +
|
||||
", freeCount=" + freeCount +
|
||||
", freeCount=" + freeConnections.size() +
|
||||
", freeConnections =" + freeConnections +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ public class ConnectionPool {
|
||||
} else {
|
||||
connection.closeDirectly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void closeConnection(Connection connection) throws IOException {
|
||||
@@ -64,7 +63,7 @@ public class ConnectionPool {
|
||||
if (socketAddress == null) {
|
||||
return null;
|
||||
}
|
||||
return String.format("%s:%s", socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
|
||||
return String.format("%s-%s", socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,7 @@ fastdfs.http_tracker_http_port = 80
|
||||
|
||||
#tracker_server
|
||||
# IPv4:
|
||||
# for example: 192.168.2.100,122.244.141.46:22122
|
||||
# for example: 192.168.2.100:22122,122.244.141.46:22122
|
||||
#
|
||||
# IPv6:
|
||||
# for example: [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e]:22122
|
||||
@@ -37,3 +37,6 @@ fastdfs.connection_pool.max_idle_time = 3600
|
||||
|
||||
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
|
||||
fastdfs.connection_pool.max_wait_time_in_ms = 1000
|
||||
|
||||
## set to false when FastDFS server version <= V6.10
|
||||
fastdfs.fetch_storage_ids.have_allow_empty_field = true
|
||||
|
||||
@@ -27,3 +27,6 @@ connection_pool.enabled = true
|
||||
connection_pool.max_count_per_entry = 500
|
||||
connection_pool.max_idle_time = 3600
|
||||
connection_pool.max_wait_time_in_ms = 1000
|
||||
|
||||
# set to false when FastDFS server version <= V6.10
|
||||
fetch_storage_ids.have_allow_empty_field = true
|
||||
|
||||
@@ -14,12 +14,28 @@ import java.text.SimpleDateFormat;
|
||||
* load test class
|
||||
*
|
||||
* @author Happy Fish / YuQing
|
||||
* @version Version 1.20
|
||||
* @version Version 1.34
|
||||
*/
|
||||
public class Monitor {
|
||||
private Monitor() {
|
||||
}
|
||||
|
||||
public static String getReadWriteModeCaption(byte readWriteMode) {
|
||||
|
||||
switch (readWriteMode) {
|
||||
case ProtoCommon.FDFS_RW_MODE_NONE:
|
||||
return "none (disabled)";
|
||||
case ProtoCommon.FDFS_RW_MODE_READONLY:
|
||||
return "readonly";
|
||||
case ProtoCommon.FDFS_RW_MODE_WRITEONLY:
|
||||
return "writeonly";
|
||||
case ProtoCommon.FDFS_RW_MODE_BOTH:
|
||||
return "both (normal)";
|
||||
default:
|
||||
return "unkown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* entry point
|
||||
*
|
||||
@@ -64,16 +80,23 @@ public class Monitor {
|
||||
|
||||
count = 0;
|
||||
for (StructGroupStat groupStat : groupStats) {
|
||||
long available_mb;
|
||||
available_mb = groupStat.getFreeMB() - groupStat.getReservedMB();
|
||||
if (available_mb < 0) {
|
||||
available_mb = 0;
|
||||
}
|
||||
count++;
|
||||
System.out.println("Group " + count + ":");
|
||||
System.out.println("group name = " + groupStat.getGroupName());
|
||||
System.out.println("disk total space = " + groupStat.getTotalMB() + "MB");
|
||||
System.out.println("disk free space = " + groupStat.getFreeMB() + " MB");
|
||||
System.out.println("disk reserved space = " + groupStat.getReservedMB() + " MB");
|
||||
System.out.println("disk availale space = " + available_mb + " MB");
|
||||
System.out.println("trunk free space = " + groupStat.getTrunkFreeMB() + " MB");
|
||||
System.out.println("storage server count = " + groupStat.getStorageCount());
|
||||
System.out.println("active server count = " + groupStat.getActiveCount());
|
||||
System.out.println("readable server count = " + groupStat.getReadableServerCount());
|
||||
System.out.println("writable server count = " + groupStat.getWritableServerCount());
|
||||
System.out.println("storage server port = " + groupStat.getStoragePort());
|
||||
System.out.println("storage HTTP port = " + groupStat.getStorageHttpPort());
|
||||
System.out.println("store path count = " + groupStat.getStorePathCount());
|
||||
System.out.println("subdir count per path = " + groupStat.getSubdirCountPerPath());
|
||||
System.out.println("current write server index = " + groupStat.getCurrentWriteServer());
|
||||
@@ -90,21 +113,27 @@ public class Monitor {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
int stroageCount = 0;
|
||||
for (StructStorageStat storageStat : storageStats) {
|
||||
available_mb = storageStat.getFreeMB() - storageStat.getReservedMB();
|
||||
if (available_mb < 0) {
|
||||
available_mb = 0;
|
||||
}
|
||||
stroageCount++;
|
||||
System.out.println("\tStorage " + stroageCount + ":");
|
||||
System.out.println("\t\tstorage id = " + storageStat.getId());
|
||||
System.out.println("\t\tip_addr = " + storageStat.getIpAddr() + " " + ProtoCommon.getStorageStatusCaption(storageStat.getStatus()));
|
||||
System.out.println("\t\thttp domain = " + storageStat.getDomainName());
|
||||
System.out.println("\t\tip_addr = " + storageStat.getIpAddr() + " " +
|
||||
ProtoCommon.getStorageStatusCaption(storageStat.getStatus()));
|
||||
System.out.println("\t\tread write mode = " + getReadWriteModeCaption(storageStat.getReadWriteMode()));
|
||||
System.out.println("\t\tversion = " + storageStat.getVersion());
|
||||
System.out.println("\t\tjoin time = " + df.format(storageStat.getJoinTime()));
|
||||
System.out.println("\t\tup time = " + (storageStat.getUpTime().getTime() == 0 ? "" : df.format(storageStat.getUpTime())));
|
||||
System.out.println("\t\ttotal storage = " + storageStat.getTotalMB() + "MB");
|
||||
System.out.println("\t\tfree storage = " + storageStat.getFreeMB() + "MB");
|
||||
System.out.println("\t\tdisk total space = " + storageStat.getTotalMB() + "MB");
|
||||
System.out.println("\t\tdisk free space = " + storageStat.getFreeMB() + "MB");
|
||||
System.out.println("\t\tdisk reserved space = " + storageStat.getReservedMB() + " MB");
|
||||
System.out.println("\t\tdisk availale space = " + available_mb + " MB");
|
||||
System.out.println("\t\tupload priority = " + storageStat.getUploadPriority());
|
||||
System.out.println("\t\tstore_path_count = " + storageStat.getStorePathCount());
|
||||
System.out.println("\t\tsubdir_count_per_path = " + storageStat.getSubdirCountPerPath());
|
||||
System.out.println("\t\tstorage_port = " + storageStat.getStoragePort());
|
||||
System.out.println("\t\tstorage_http_port = " + storageStat.getStorageHttpPort());
|
||||
System.out.println("\t\tcurrent_write_path = " + storageStat.getCurrentWritePath());
|
||||
System.out.println("\t\tsource ip_id = " + storageStat.getSrcId());
|
||||
System.out.println("\t\tif_trunk_server = " + storageStat.isTrunkServer());
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Test1 {
|
||||
System.out.println("network_timeout=" + ClientGlobal.g_network_timeout + "ms");
|
||||
System.out.println("charset=" + ClientGlobal.g_charset);
|
||||
|
||||
TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("47.95.221.159", 22122)});
|
||||
TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("192.168.3.202", 22122)});
|
||||
TrackerClient tc = new TrackerClient(tg);
|
||||
|
||||
TrackerServer ts = tc.getTrackerServer();
|
||||
|
||||
Reference in New Issue
Block a user