public StructStorageStat[] listStorages(TrackerServer trackerServer,String groupName,String storageIpAddr) throws IOException {
  byte[] header;
  byte[] bGroupName;
  byte[] bs;
  int len;
  boolean bNewConnection;
  Socket trackerSocket;
  if (trackerServer == null) {
    trackerServer=getConnection();
    if (trackerServer == null) {
      return null;
    }
    bNewConnection=true;
  }
 else {
    bNewConnection=false;
  }
  trackerSocket=trackerServer.getSocket();
  OutputStream out=trackerSocket.getOutputStream();
  try {
    bs=groupName.getBytes(ClientGlobal.g_charset);
    bGroupName=new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
    if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN) {
      len=bs.length;
    }
 else {
      len=ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
    }
    Arrays.fill(bGroupName,(byte)0);
    System.arraycopy(bs,0,bGroupName,0,len);
    int ipAddrLen;
    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;
      }
    }
 else {
      bIpAddr=null;
      ipAddrLen=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);
    if (ipAddrLen > 0) {
      System.arraycopy(bIpAddr,0,wholePkg,header.length + bGroupName.length,ipAddrLen);
    }
    out.write(wholePkg);
    ProtoCommon.RecvPackageInfo pkgInfo=ProtoCommon.recvPackage(trackerSocket.getInputStream(),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());
  }
 catch (  IOException ex) {
    if (!bNewConnection) {
      try {
        trackerServer.close();
      }
 catch (      IOException ex1) {
        ex1.printStackTrace();
      }
    }
    throw ex;
  }
catch (  Exception ex) {
    ex.printStackTrace();
    this.errno=ProtoCommon.ERR_NO_EINVAL;
    return null;
  }
 finally {
    if (bNewConnection) {
      try {
        trackerServer.close();
      }
 catch (      IOException ex1) {
        ex1.printStackTrace();
      }
    }
  }
}

public StructStorageStat [ ] listStorages ( TrackerServer trackerServer , String groupName , String storageIpAddr ) throws IOException { byte [ ] header ; byte [ ] bGroupName ; byte [ ] bs ; int len ; boolean bNewConnection ; Socket trackerSocket ; if ( trackerServer == null ) { trackerServer = getConnection ( ) ; if ( trackerServer == null ) { return null ; } bNewConnection = true ; } else { bNewConnection = false ; } trackerSocket = trackerServer . getSocket ( ) ; OutputStream out = trackerSocket . getOutputStream ( ) ; try { bs = groupName . getBytes ( ClientGlobal . g_charset ) ; bGroupName = new byte [ ProtoCommon . FDFS_GROUP_NAME_MAX_LEN ] ; if ( bs . length <= ProtoCommon . FDFS_GROUP_NAME_MAX_LEN ) { len = bs . length ; } else { len = ProtoCommon . FDFS_GROUP_NAME_MAX_LEN ; } Arrays . fill ( bGroupName , ( byte ) 0 ) ; System . arraycopy ( bs , 0 , bGroupName , 0 , len ) ; int ipAddrLen ; 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 ; } } else { bIpAddr = null ; ipAddrLen = 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 ) ; if ( ipAddrLen > 0 ) { System . arraycopy ( bIpAddr , 0 , wholePkg , header . length + bGroupName . length , ipAddrLen ) ; } out . write ( wholePkg ) ; ProtoCommon . RecvPackageInfo pkgInfo = ProtoCommon . recvPackage ( trackerSocket . getInputStream ( ) , 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 ( ) ) ; } catch ( IOException ex ) { if ( ! bNewConnection ) { try { trackerServer . close ( ) ; } catch ( IOException ex1 ) { ex1 . printStackTrace ( ) ; } } throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; this . errno = ProtoCommon . ERR_NO_EINVAL ; return null ; } finally { if ( bNewConnection ) { try { trackerServer . close ( ) ; } catch ( IOException ex1 ) { ex1 . printStackTrace ( ) ; } } } }
query storage server stat info of the group
