/** * send ACTIVE_TEST command to server, test if network is ok and the server is alive * * @param sock the Socket object */ public static boolean activeTest(Socket sock) throws IOException { byte[] header; header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte) 0); sock.getOutputStream().write(header); RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0); return headerInfo.errno == 0 ? true : false; }
/** * receive whole pack * * @param in input stream * @param expect_cmd expect response command * @param expect_body_len expect response package body length * @return RecvPackageInfo: errno and reponse body(byte buff) */ public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException { RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len); if (header.errno != 0) { return new RecvPackageInfo(header.errno, null); } byte[] body = new byte[(int) header.body_len]; int totalBytes = 0; int remainBytes = (int) header.body_len; int bytes; while (totalBytes < header.body_len) { if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) { break; } totalBytes += bytes; remainBytes -= bytes; } if (totalBytes != header.body_len) { throw new IOException("recv package size " + totalBytes + " != " + header.body_len); } return new RecvPackageInfo((byte) 0, body); }
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
/** * send ACTIVE_TEST command to server, test if network is ok and the server is alive * * @param sock the Socket object */ public static boolean activeTest(Socket sock) throws IOException { byte[] header; header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte) 0); sock.getOutputStream().write(header); RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0); return headerInfo.errno == 0 ? true : false; }
/** * send ACTIVE_TEST command to server, test if network is ok and the server is alive * * @param sock the Socket object */ public static boolean activeTest(Socket sock) throws IOException { byte[] header; header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte) 0); sock.getOutputStream().write(header); RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0); return headerInfo.errno == 0 ? true : false; }
/** * send ACTIVE_TEST command to server, test if network is ok and the server is alive * @param sock the Socket object */ public static boolean activeTest(Socket sock) throws IOException { byte[] header; header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte) 0); sock.getOutputStream().write(header); RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0); return headerInfo.errno == 0 ? true : false; }
/** * send ACTIVE_TEST command to server, test if network is ok and the server is alive * @param sock the Socket object */ public static boolean activeTest(Socket sock) throws IOException { byte[] header; header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte)0); sock.getOutputStream().write(header); RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0); return headerInfo.errno == 0 ? true : false; }
/** * receive whole pack * @param in input stream * @param expect_cmd expect response command * @param expect_body_len expect response package body length * @return RecvPackageInfo: errno and reponse body(byte buff) */ public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException { RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len); if (header.errno != 0) { return new RecvPackageInfo(header.errno, null); } byte[] body = new byte[(int) header.body_len]; int totalBytes = 0; int remainBytes = (int) header.body_len; int bytes; while (totalBytes < header.body_len) { if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) { break; } totalBytes += bytes; remainBytes -= bytes; } if (totalBytes != header.body_len) { throw new IOException("recv package size " + totalBytes + " != " + header.body_len); } return new RecvPackageInfo((byte) 0, body); }
/** * receive whole pack * * @param in input stream * @param expect_cmd expect response command * @param expect_body_len expect response package body length * @return RecvPackageInfo: errno and reponse body(byte buff) */ public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException { RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len); if (header.errno != 0) { return new RecvPackageInfo(header.errno, null); } byte[] body = new byte[(int) header.body_len]; int totalBytes = 0; int remainBytes = (int) header.body_len; int bytes; while (totalBytes < header.body_len) { if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) { break; } totalBytes += bytes; remainBytes -= bytes; } if (totalBytes != header.body_len) { throw new IOException("recv package size " + totalBytes + " != " + header.body_len); } return new RecvPackageInfo((byte) 0, body); }
/** * receive whole pack * * @param in input stream * @param expect_cmd expect response command * @param expect_body_len expect response package body length * @return RecvPackageInfo: errno and reponse body(byte buff) */ public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException { RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len); if (header.errno != 0) { return new RecvPackageInfo(header.errno, null); } byte[] body = new byte[(int) header.body_len]; int totalBytes = 0; int remainBytes = (int) header.body_len; int bytes; while (totalBytes < header.body_len) { if ((bytes = in.read(body, totalBytes, remainBytes)) < 0) { break; } totalBytes += bytes; remainBytes -= bytes; } if (totalBytes != header.body_len) { throw new IOException("recv package size " + totalBytes + " != " + header.body_len); } return new RecvPackageInfo((byte) 0, body); }
RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len); if (header.errno != 0)
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0)
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0) {
header = ProtoCommon.recvHeader(in, ProtoCommon.STORAGE_PROTO_CMD_RESP, -1); this.errno = header.errno; if (header.errno != 0)