@Override public RemotingCommand decode(ByteBuffer byteBuffer) throws Exception { int length = byteBuffer.limit(); int serializableId = byteBuffer.getInt(); RemotingSerializable serializable = getRemotingSerializable(serializableId); int headerLength = byteBuffer.getInt(); byte[] headerData = new byte[headerLength]; byteBuffer.get(headerData); RemotingCommand cmd = serializable.deserialize(headerData, RemotingCommand.class); int remaining = length - 4 - 4 - headerLength; if (remaining > 0) { int bodyLength = byteBuffer.getInt(); int bodyClassLength = remaining - 4 - bodyLength; if (bodyLength > 0) { byte[] bodyData = new byte[bodyLength]; byteBuffer.get(bodyData); byte[] bodyClassData = new byte[bodyClassLength]; byteBuffer.get(bodyClassData); cmd.setBody((RemotingCommandBody) serializable.deserialize(bodyData, Class.forName(new String(bodyClassData)))); } } return cmd; }
@Override public RemotingCommand decode(ByteBuffer byteBuffer) throws Exception { int length = byteBuffer.limit(); int serializableId = byteBuffer.getInt(); RemotingSerializable serializable = getRemotingSerializable(serializableId); int headerLength = byteBuffer.getInt(); byte[] headerData = new byte[headerLength]; byteBuffer.get(headerData); RemotingCommand cmd = serializable.deserialize(headerData, RemotingCommand.class); int remaining = length - 4 - 4 - headerLength; if (remaining > 0) { int bodyLength = byteBuffer.getInt(); int bodyClassLength = remaining - 4 - bodyLength; if (bodyLength > 0) { byte[] bodyData = new byte[bodyLength]; byteBuffer.get(bodyData); byte[] bodyClassData = new byte[bodyClassLength]; byteBuffer.get(bodyClassData); cmd.setBody((RemotingCommandBody) serializable.deserialize(bodyData, Class.forName(new String(bodyClassData)))); } } return cmd; }
public static RemotingCommand createRequestCommand(int code, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); cmd.setCode(code); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }
public static RemotingCommand createRequestCommand(int code, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); cmd.setCode(code); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }
public static RemotingCommand createResponseCommand(int code, String remark, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); RemotingCommandHelper.markResponseType(cmd); cmd.setCode(code); cmd.setRemark(remark); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }
public static RemotingCommand createResponseCommand(int code, String remark, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); RemotingCommandHelper.markResponseType(cmd); cmd.setCode(code); cmd.setRemark(remark); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }
@Override public RemotingCommand decode(ByteBuffer byteBuffer) throws Exception { int length = byteBuffer.limit(); int serializableId = byteBuffer.getInt(); RemotingSerializable serializable = getRemotingSerializable(serializableId); int headerLength = byteBuffer.getInt(); byte[] headerData = new byte[headerLength]; byteBuffer.get(headerData); RemotingCommand cmd = serializable.deserialize(headerData, RemotingCommand.class); int remaining = length - 4 - 4 - headerLength; if (remaining > 0) { int bodyLength = byteBuffer.getInt(); int bodyClassLength = remaining - 4 - bodyLength; if (bodyLength > 0) { byte[] bodyData = new byte[bodyLength]; byteBuffer.get(bodyData); byte[] bodyClassData = new byte[bodyClassLength]; byteBuffer.get(bodyClassData); cmd.setBody((RemotingCommandBody) serializable.deserialize(bodyData, Class.forName(new String(bodyClassData)))); } } return cmd; }
public static RemotingCommand createRequestCommand(int code, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); cmd.setCode(code); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }
public static RemotingCommand createResponseCommand(int code, String remark, RemotingCommandBody body) { RemotingCommand cmd = new RemotingCommand(); RemotingCommandHelper.markResponseType(cmd); cmd.setCode(code); cmd.setRemark(remark); cmd.setBody(body); cmd.setOpaque(requestId.getAndIncrement()); return cmd; }