Class AbstractFdfsCommand<T>

java.lang.Object
com.github.tobato.fastdfs.domain.proto.AbstractFdfsCommand<T>
Type Parameters:
T -
All Implemented Interfaces:
FdfsCommand<T>
Direct Known Subclasses:
StorageAppendFileCommand, StorageDeleteFileCommand, StorageDownloadCommand, StorageGetMetadataCommand, StorageModifyCommand, StorageQueryFileInfoCommand, StorageSetMetadataCommand, StorageTruncateCommand, StorageUploadFileCommand, StorageUploadSlaveFileCommand, TrackerDeleteStorageCommand, TrackerGetFetchStorageCommand, TrackerGetStoreStorageCommand, TrackerListGroupsCommand, TrackerListStoragesCommand

public abstract class AbstractFdfsCommand<T> extends Object implements FdfsCommand<T>
交易命令抽象类
Author:
tobato
  • Field Details

    • request

      protected FdfsRequest request
      表示请求消息
    • response

      protected FdfsResponse<T> response
      解析反馈消息对象
  • Constructor Details

    • AbstractFdfsCommand

      public AbstractFdfsCommand()
  • Method Details

    • execute

      public T execute(Connection conn)
      对服务端发出请求然后接收反馈
      Specified by:
      execute in interface FdfsCommand<T>
    • send

      protected void send(OutputStream out, Charset charset) throws IOException
      将报文输出规范为模板方法

       1.输出报文头
       2.输出报文参数
       3.输出文件内容
       
      Parameters:
      out - 输入流
      charset - 字符集
      Throws:
      IOException - 异常
    • receive

      protected T receive(InputStream in, Charset charset) throws IOException
      接收这里只能确切知道报文头,报文内容(参数+文件)只能靠接收对象分析
      Parameters:
      in - 输入流
      Returns:
      数据
      Throws:
      IOException - 异常
    • sendFileContent

      protected void sendFileContent(InputStream ins, long size, OutputStream ous) throws IOException
      发送文件
      Parameters:
      ins - 输入流
      size - 文件流大小
      ous - 输入流
      Throws:
      IOException - 异常