* @param connection The connection
* @throws IOException If any errors occur
*/
protected void sendRequest(final int protocolVersion, final Connection connection) throws IOException {
OutputStream outputStream = null;
ByteDataOutput output = null;
try {
outputStream = connection.writeMessage();
output = new SimpleByteDataOutput(outputStream);
output.writeByte(ManagementProtocol.REQUEST_OPERATION);
output.writeByte(getRequestCode());
output.writeByte(ManagementProtocol.REQUEST_START);
output.close();
outputStream.close();
} finally {
safeClose(output);
safeClose(outputStream);
}
try {
outputStream = connection.writeMessage();
outputStream.write(ManagementProtocol.REQUEST_BODY);
sendRequest(protocolVersion, outputStream);
outputStream.close();
} finally {
safeClose(outputStream);
}
try {
outputStream = connection.writeMessage();
output = new SimpleByteDataOutput(outputStream);
output.writeByte(ManagementProtocol.REQUEST_END);
output.close();
outputStream.close();
} finally {
safeClose(output);
safeClose(outputStream);
}