/** * append file to storage server (by file buff) * * @param group_name the group name of appender file * @param appender_filename the appender filename * @param file_buff file content/buff * @return 0 for success, != 0 for error (error no) */ public int append_file(String group_name, String appender_filename, byte[] file_buff) throws IOException, MyException { return this.do_append_file(group_name, appender_filename, file_buff.length, new UploadBuff(file_buff, 0, file_buff.length)); }
/** * modify appender file to storage server (by file buff) * * @param group_name the group name of appender file * @param appender_filename the appender filename * @param file_offset the offset of appender file * @param file_buff file content/buff * @return 0 for success, != 0 for error (error no) */ public int modify_file(String group_name, String appender_filename, long file_offset, byte[] file_buff) throws IOException, MyException { return this.do_modify_file(group_name, appender_filename, file_offset, file_buff.length, new UploadBuff(file_buff, 0, file_buff.length)); }
/** * get a connection to tracker server * * @return tracker server Socket object, return null if fail */ public TrackerServer getConnection() throws IOException { return this.tracker_group.getConnection(); }
/** * query storage server to download file * * @param trackerServer the tracker server * @param file_id the file id(including group name and filename) * @return storage server Socket object, return null if fail */ public StorageServer getFetchStorage1(TrackerServer trackerServer, String file_id) throws IOException { String[] parts = new String[2]; this.errno = StorageClient1.split_file_id(file_id, parts); if (this.errno != 0) { return null; } return this.getFetchStorage(trackerServer, parts[0], parts[1]); }
/** * get storage servers to download file * * @param trackerServer the tracker server * @param file_id the file id(including group name and filename) * @return storage servers, return null if fail */ public ServerInfo[] getFetchStorages1(TrackerServer trackerServer, String file_id) throws IOException { String[] parts = new String[2]; this.errno = StorageClient1.split_file_id(file_id, parts); if (this.errno != 0) { return null; } return this.getFetchStorages(trackerServer, parts[0], parts[1]); }
/** * download file from storage server * * @param file_id the file id(including group name and filename) * @return file content/buffer, return null if fail */ public byte[] download_file1(String file_id) throws IOException, MyException { final long file_offset = 0; final long download_bytes = 0; return this.download_file1(file_id, file_offset, download_bytes); }
/** * download file from storage server * * @param group_name the group name of storage server * @param remote_filename filename on storage server * @return file content/buff, return null if fail */ public byte[] download_file(String group_name, String remote_filename) throws IOException, MyException { final long file_offset = 0; final long download_bytes = 0; return this.download_file(group_name, remote_filename, file_offset, download_bytes); }
protected void finalize() throws Throwable { this.close(); } }
/** * query storage server stat info of the group * * @param trackerServer the tracker server * @param groupName the group name of storage server * @return storage server stat array, return null if fail */ public StructStorageStat[] listStorages(TrackerServer trackerServer, String groupName) throws IOException { final String storageIpAddr = null; return this.listStorages(trackerServer, groupName, storageIpAddr); }
/** * truncate appender file to size 0 from storage server * * @param group_name the group name of storage server * @param appender_filename the appender filename * @return 0 for success, none zero for fail (error code) */ public int truncate_file(String group_name, String appender_filename) throws IOException, MyException { final long truncated_file_size = 0; return this.truncate_file(group_name, appender_filename, truncated_file_size); }
/** * split metadata to name value pair array * * @param meta_buff metadata * @return name value pair array */ public static NameValuePair[] split_metadata(String meta_buff) { return split_metadata(meta_buff, FDFS_RECORD_SEPERATOR, FDFS_FIELD_SEPERATOR); }
/** * delete a storage server from the global FastDFS cluster * * @param groupName the group name of storage server * @param storageIpAddr the storage server ip address * @return true for success, false for fail */ public boolean deleteStorage(String groupName, String storageIpAddr) throws IOException { return this.deleteStorage(ClientGlobal.g_tracker_group, groupName, storageIpAddr); }
/** * get the connected socket * * @return the socket */ public Socket getSocket() throws IOException { if (this.sock == null) { this.sock = ClientGlobal.getSocket(this.inetSockAddr); } return this.sock; }
public void close() throws IOException { if (this.sock != null) { try { ProtoCommon.closeSocket(this.sock); } finally { this.sock = null; } } }
/** * query storage server to upload file * * @param trackerServer the tracker server * @return storage server Socket object, return null if fail */ public StorageServer getStoreStorage(TrackerServer trackerServer) throws IOException { final String groupName = null; return this.getStoreStorage(trackerServer, groupName); }
/** * get storage servers to download file * * @param trackerServer the tracker server * @param groupName the group name of storage server * @param filename filename on storage server * @return storage servers, return null if fail */ public ServerInfo[] getFetchStorages(TrackerServer trackerServer, String groupName, String filename) throws IOException { return this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL, groupName, filename); }
/** * append file to storage server (by callback) * * @param group_name the group name to append file to * @param appender_filename the appender filename * @param file_size the file size * @param callback the write data callback object * @return 0 for success, != 0 for error (error no) */ public int append_file(String group_name, String appender_filename, long file_size, UploadCallback callback) throws IOException, MyException { return this.do_append_file(group_name, appender_filename, file_size, callback); }
/** * append file to storage server (by file buff) * * @param group_name the group name of appender file * @param appender_filename the appender filename * @param file_buff file content/buff * @param offset start offset of the buff * @param length the length of buff to append * @return 0 for success, != 0 for error (error no) */ public int append_file(String group_name, String appender_filename, byte[] file_buff, int offset, int length) throws IOException, MyException { return this.do_append_file(group_name, appender_filename, length, new UploadBuff(file_buff, offset, length)); }
/** * download file from storage server * * @param file_id the file id(including group name and filename) * @param local_filename the filename on local * @return 0 success, return none zero errno if fail */ public int download_file1(String file_id, String local_filename) throws IOException, MyException { final long file_offset = 0; final long download_bytes = 0; return this.download_file1(file_id, file_offset, download_bytes, local_filename); }
/** * download file from storage server * * @param file_id the file id(including group name and filename) * @param callback the callback object, will call callback.recv() when data arrive * @return 0 success, return none zero errno if fail */ public int download_file1(String file_id, DownloadCallback callback) throws IOException, MyException { final long file_offset = 0; final long download_bytes = 0; return this.download_file1(file_id, file_offset, download_bytes, callback); }