Skip to content

Commit 697bf97

Browse files
Fixed: 修复Tracker Server返回的TrackerStorageStat数据src_id字段解析问题
1、在FastDFS中, Tracker Server返回的TrackerStorageStat数据中src_id字段为src storage id。在数据解析的时候变成了srcIpAddr,这与原始含义有出入,特将srcIpAddr改回srcId。 2、修改srcId的数据长度引用,从FDFS_IPADDR_SIZE修改为FDFS_STORAGE_ID_MAX_SIZE,既与FastDFS中的保持一致,又为后续IPv6兼容做准备。
1 parent 45d9a89 commit 697bf97

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/java/org/csource/fastdfs/StructStorageStat.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class StructStorageStat extends StructBase {
2121
protected static final int FIELD_INDEX_ID = 1;
2222
protected static final int FIELD_INDEX_IP_ADDR = 2;
2323
protected static final int FIELD_INDEX_DOMAIN_NAME = 3;
24-
protected static final int FIELD_INDEX_SRC_IP_ADDR = 4;
24+
protected static final int FIELD_INDEX_SRC_ID = 4;
2525
protected static final int FIELD_INDEX_VERSION = 5;
2626
protected static final int FIELD_INDEX_JOIN_TIME = 6;
2727
protected static final int FIELD_INDEX_UP_TIME = 7;
@@ -100,8 +100,8 @@ public class StructStorageStat extends StructBase {
100100
fieldsArray[FIELD_INDEX_DOMAIN_NAME] = new StructBase.FieldInfo("domainName", offset, ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE);
101101
offset += ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE;
102102

103-
fieldsArray[FIELD_INDEX_SRC_IP_ADDR] = new StructBase.FieldInfo("srcIpAddr", offset, ProtoCommon.FDFS_IPADDR_SIZE);
104-
offset += ProtoCommon.FDFS_IPADDR_SIZE;
103+
fieldsArray[FIELD_INDEX_SRC_ID] = new StructBase.FieldInfo("srcId", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
104+
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
105105

106106
fieldsArray[FIELD_INDEX_VERSION] = new StructBase.FieldInfo("version", offset, ProtoCommon.FDFS_VERSION_SIZE);
107107
offset += ProtoCommon.FDFS_VERSION_SIZE;
@@ -280,7 +280,7 @@ public class StructStorageStat extends StructBase {
280280
protected byte status;
281281
protected String id;
282282
protected String ipAddr;
283-
protected String srcIpAddr;
283+
protected String srcId;
284284
protected String domainName; //http domain name
285285
protected String version;
286286
protected long totalMB; //total disk storage in MB
@@ -377,12 +377,12 @@ public String getIpAddr() {
377377
}
378378

379379
/**
380-
* get source storage ip address
380+
* get source storage id
381381
*
382-
* @return source storage ip address
382+
* @return source storage id
383383
*/
384-
public String getSrcIpAddr() {
385-
return this.srcIpAddr;
384+
public String getSrcId() {
385+
return this.srcId;
386386
}
387387

388388
/**
@@ -917,7 +917,7 @@ public void setFields(byte[] bs, int offset) {
917917
this.status = byteValue(bs, offset, fieldsArray[FIELD_INDEX_STATUS]);
918918
this.id = stringValue(bs, offset, fieldsArray[FIELD_INDEX_ID]);
919919
this.ipAddr = stringValue(bs, offset, fieldsArray[FIELD_INDEX_IP_ADDR]);
920-
this.srcIpAddr = stringValue(bs, offset, fieldsArray[FIELD_INDEX_SRC_IP_ADDR]);
920+
this.srcId = stringValue(bs, offset, fieldsArray[FIELD_INDEX_SRC_ID]);
921921
this.domainName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_DOMAIN_NAME]);
922922
this.version = stringValue(bs, offset, fieldsArray[FIELD_INDEX_VERSION]);
923923
this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);

src/test/java/org/csource/fastdfs/Monitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static void main(String args[]) {
106106
System.out.println("\t\tstorage_port = " + storageStat.getStoragePort());
107107
System.out.println("\t\tstorage_http_port = " + storageStat.getStorageHttpPort());
108108
System.out.println("\t\tcurrent_write_path = " + storageStat.getCurrentWritePath());
109-
System.out.println("\t\tsource ip_addr = " + storageStat.getSrcIpAddr());
109+
System.out.println("\t\tsource ip_id = " + storageStat.getSrcId());
110110
System.out.println("\t\tif_trunk_server = " + storageStat.isTrunkServer());
111111
System.out.println("\t\tconntion.alloc_count = " + storageStat.getConnectionAllocCount());
112112
System.out.println("\t\tconntion.current_count = " + storageStat.getConnectionCurrentCount());

0 commit comments

Comments
 (0)