Skip to content

Commit 1ce334d

Browse files
author
Yu Qing
committed
support connection stats since FastDFS Server v5.04
1 parent 2b7b8a6 commit 1ce334d

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
FastDFS java client SDK
3+

src/org/csource/fastdfs/StructBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ protected int intValue(byte[] bs, int offset, FieldInfo filedInfo)
6262
return (int)ProtoCommon.buff2long(bs, offset + filedInfo.offset);
6363
}
6464

65+
protected int int32Value(byte[] bs, int offset, FieldInfo filedInfo)
66+
{
67+
return ProtoCommon.buff2int(bs, offset + filedInfo.offset);
68+
}
69+
6570
protected byte byteValue(byte[] bs, int offset, FieldInfo filedInfo)
6671
{
6772
return bs[offset + filedInfo.offset];

src/org/csource/fastdfs/StructStorageStat.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,33 @@ public boolean isTrunkServer()
872872
return this.ifTrunkServer;
873873
}
874874

875+
/**
876+
* get connection alloc count
877+
* @return connection alloc count
878+
*/
879+
public int getConnectionAllocCount()
880+
{
881+
return this.connectionAllocCount;
882+
}
883+
884+
/**
885+
* get connection current count
886+
* @return connection current count
887+
*/
888+
public int getConnectionCurrentCount()
889+
{
890+
return this.connectionCurrentCount;
891+
}
892+
893+
/**
894+
* get connection max count
895+
* @return connection max count
896+
*/
897+
public int getConnectionMaxCount()
898+
{
899+
return this.connectionMaxCount;
900+
}
901+
875902
/**
876903
* set fields
877904
* @param bs byte array
@@ -896,9 +923,9 @@ public void setFields(byte[] bs, int offset)
896923
this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
897924
this.currentWritePath = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH]);
898925

899-
this.connectionAllocCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_ALLOC_COUNT]);
900-
this.connectionCurrentCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_CURRENT_COUNT]);
901-
this.connectionMaxCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_MAX_COUNT]);
926+
this.connectionAllocCount = int32Value(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_ALLOC_COUNT]);
927+
this.connectionCurrentCount = int32Value(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_CURRENT_COUNT]);
928+
this.connectionMaxCount = int32Value(bs, offset, fieldsArray[FIELD_INDEX_CONNECTION_MAX_COUNT]);
902929

903930
this.totalUploadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_COUNT]);
904931
this.successUploadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_COUNT]);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public static void main(String args[])
118118
System.out.println("\t\tcurrent_write_path = " + storageStat.getCurrentWritePath());
119119
System.out.println("\t\tsource ip_addr = " + storageStat.getSrcIpAddr());
120120
System.out.println("\t\tif_trunk_server = " + storageStat.isTrunkServer());
121+
System.out.println("\t\tconntion.alloc_count = " + storageStat.getConnectionAllocCount());
122+
System.out.println("\t\tconntion.current_count = " + storageStat.getConnectionCurrentCount());
123+
System.out.println("\t\tconntion.max_count = " + storageStat.getConnectionMaxCount());
121124
System.out.println("\t\ttotal_upload_count = " + storageStat.getTotalUploadCount());
122125
System.out.println("\t\tsuccess_upload_count = " + storageStat.getSuccessUploadCount());
123126
System.out.println("\t\ttotal_append_count = " + storageStat.getTotalAppendCount());

0 commit comments

Comments
 (0)