1
0

StructGroupStat.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /**
  2. * Copyright (C) 2008 Happy Fish / YuQing
  3. * <p>
  4. * FastDFS Java Client may be copied only under the terms of the GNU Lesser
  5. * General Public License (LGPL).
  6. * Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
  7. */
  8. package com.kmall.common.fileserver.fastdfs;
  9. /**
  10. * C struct body decoder
  11. *
  12. * @author Happy Fish / YuQing
  13. * @version Version 1.18
  14. */
  15. public class StructGroupStat extends StructBase {
  16. protected static final int FIELD_INDEX_GROUP_NAME = 0;
  17. protected static final int FIELD_INDEX_TOTAL_MB = 1;
  18. protected static final int FIELD_INDEX_FREE_MB = 2;
  19. protected static final int FIELD_INDEX_TRUNK_FREE_MB = 3;
  20. protected static final int FIELD_INDEX_STORAGE_COUNT = 4;
  21. protected static final int FIELD_INDEX_STORAGE_PORT = 5;
  22. protected static final int FIELD_INDEX_STORAGE_HTTP_PORT = 6;
  23. protected static final int FIELD_INDEX_ACTIVE_COUNT = 7;
  24. protected static final int FIELD_INDEX_CURRENT_WRITE_SERVER = 8;
  25. protected static final int FIELD_INDEX_STORE_PATH_COUNT = 9;
  26. protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 10;
  27. protected static final int FIELD_INDEX_CURRENT_TRUNK_FILE_ID = 11;
  28. protected static int fieldsTotalSize;
  29. protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[12];
  30. static {
  31. int offset = 0;
  32. fieldsArray[FIELD_INDEX_GROUP_NAME] = new StructBase.FieldInfo("groupName", offset, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
  33. offset += ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1;
  34. fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo("totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  35. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  36. fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo("freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  37. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  38. fieldsArray[FIELD_INDEX_TRUNK_FREE_MB] = new StructBase.FieldInfo("trunkFreeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  39. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  40. fieldsArray[FIELD_INDEX_STORAGE_COUNT] = new StructBase.FieldInfo("storageCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  41. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  42. fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo("storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  43. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  44. fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT] = new StructBase.FieldInfo("storageHttpPort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  45. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  46. fieldsArray[FIELD_INDEX_ACTIVE_COUNT] = new StructBase.FieldInfo("activeCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  47. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  48. fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER] = new StructBase.FieldInfo("currentWriteServer", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  49. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  50. fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo("storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  51. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  52. fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo("subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  53. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  54. fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID] = new StructBase.FieldInfo("currentTrunkFileId", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
  55. offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
  56. fieldsTotalSize = offset;
  57. }
  58. protected String groupName; //name of this group
  59. protected long totalMB; //total disk storage in MB
  60. protected long freeMB; //free disk space in MB
  61. protected long trunkFreeMB; //trunk free space in MB
  62. protected int storageCount; //storage server count
  63. protected int storagePort; //storage server port
  64. protected int storageHttpPort; //storage server HTTP port
  65. protected int activeCount; //active storage server count
  66. protected int currentWriteServer; //current storage server index to upload file
  67. protected int storePathCount; //store base path count of each storage server
  68. protected int subdirCountPerPath; //sub dir count per store path
  69. protected int currentTrunkFileId; //current trunk file id
  70. /**
  71. * get fields total size
  72. *
  73. * @return fields total size
  74. */
  75. public static int getFieldsTotalSize() {
  76. return fieldsTotalSize;
  77. }
  78. /**
  79. * get group name
  80. *
  81. * @return group name
  82. */
  83. public String getGroupName() {
  84. return this.groupName;
  85. }
  86. /**
  87. * get total disk space in MB
  88. *
  89. * @return total disk space in MB
  90. */
  91. public long getTotalMB() {
  92. return this.totalMB;
  93. }
  94. /**
  95. * get free disk space in MB
  96. *
  97. * @return free disk space in MB
  98. */
  99. public long getFreeMB() {
  100. return this.freeMB;
  101. }
  102. /**
  103. * get trunk free space in MB
  104. *
  105. * @return trunk free space in MB
  106. */
  107. public long getTrunkFreeMB() {
  108. return this.trunkFreeMB;
  109. }
  110. /**
  111. * get storage server count in this group
  112. *
  113. * @return storage server count in this group
  114. */
  115. public int getStorageCount() {
  116. return this.storageCount;
  117. }
  118. /**
  119. * get active storage server count in this group
  120. *
  121. * @return active storage server count in this group
  122. */
  123. public int getActiveCount() {
  124. return this.activeCount;
  125. }
  126. /**
  127. * get storage server port
  128. *
  129. * @return storage server port
  130. */
  131. public int getStoragePort() {
  132. return this.storagePort;
  133. }
  134. /**
  135. * get storage server HTTP port
  136. *
  137. * @return storage server HTTP port
  138. */
  139. public int getStorageHttpPort() {
  140. return this.storageHttpPort;
  141. }
  142. /**
  143. * get current storage server index to upload file
  144. *
  145. * @return current storage server index to upload file
  146. */
  147. public int getCurrentWriteServer() {
  148. return this.currentWriteServer;
  149. }
  150. /**
  151. * get store base path count of each storage server
  152. *
  153. * @return store base path count of each storage server
  154. */
  155. public int getStorePathCount() {
  156. return this.storePathCount;
  157. }
  158. /**
  159. * get sub dir count per store path
  160. *
  161. * @return sub dir count per store path
  162. */
  163. public int getSubdirCountPerPath() {
  164. return this.subdirCountPerPath;
  165. }
  166. /**
  167. * get current trunk file id
  168. *
  169. * @return current trunk file id
  170. */
  171. public int getCurrentTrunkFileId() {
  172. return this.currentTrunkFileId;
  173. }
  174. /**
  175. * set fields
  176. *
  177. * @param bs byte array
  178. * @param offset start offset
  179. */
  180. public void setFields(byte[] bs, int offset) {
  181. this.groupName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_GROUP_NAME]);
  182. this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);
  183. this.freeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_FREE_MB]);
  184. this.trunkFreeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TRUNK_FREE_MB]);
  185. this.storageCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_COUNT]);
  186. this.storagePort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_PORT]);
  187. this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
  188. this.activeCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_ACTIVE_COUNT]);
  189. this.currentWriteServer = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER]);
  190. this.storePathCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORE_PATH_COUNT]);
  191. this.subdirCountPerPath = intValue(bs, offset, fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH]);
  192. this.currentTrunkFileId = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID]);
  193. }
  194. }