/** * Write the header information to the provided {@link java.io.DataOutput}. * * @param output The output to write to * @throws IOException If any problems occur writing to the output */ public void write(final DataOutput output) throws IOException { output.write(ManagementProtocol.SIGNATURE); output.writeByte(ManagementProtocol.VERSION_FIELD); output.writeInt(getVersion()); output.writeByte(ManagementProtocol.TYPE); output.writeByte(getType()); }
public void write(DataOutput output) throws IOException { super.write(output); output.write(ManagementProtocol.RESPONSE_ID); output.writeInt(responseId); output.write(ManagementProtocol.RESPONSE_TYPE); if (error != null) { output.write(ManagementProtocol.RESPONSE_ERROR); output.writeUTF(error); } else { output.write(ManagementProtocol.RESPONSE_BODY); } }
protected static void safeWriteResponse(final Channel channel, final ManagementProtocolHeader header, byte param) { if(header.getType() == ManagementProtocol.TYPE_REQUEST) { try { writeResponse(channel, (ManagementRequestHeader) header, param); } catch(IOException ioe) { HostControllerLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
public static ManagementResponseHeader create(final ManagementProtocolHeader header, int responseId) { final int workingVersion = Math.min(ManagementProtocol.VERSION, header.getVersion()); return new ManagementResponseHeader(workingVersion, responseId, null); }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw MESSAGES.invalidType("0x" + Integer.toHexString(type)); } } }
protected static void safeWriteResponse(final Channel channel, final ManagementProtocolHeader header, final Exception error) { if(header.getType() == ManagementProtocol.TYPE_REQUEST) { try { writeResponse(channel, (ManagementRequestHeader) header, error); } catch(IOException ioe) { HostControllerLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
public static ManagementResponseHeader create(final ManagementProtocolHeader header, int responseId) { final int workingVersion = Math.min(ManagementProtocol.VERSION, header.getVersion()); return new ManagementResponseHeader(workingVersion, responseId, null); }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type)); } } }
public void write(DataOutput output) throws IOException { super.write(output); output.write(ManagementProtocol.RESPONSE_ID); output.writeInt(responseId); output.write(ManagementProtocol.RESPONSE_TYPE); if (error != null) { output.write(ManagementProtocol.RESPONSE_ERROR); output.writeUTF(error); } else { output.write(ManagementProtocol.RESPONSE_BODY); } }
protected static void safeWriteResponse(final Channel channel, final ManagementProtocolHeader header, final Exception error) { if(header.getType() == ManagementProtocol.TYPE_REQUEST) { try { writeResponse(channel, (ManagementRequestHeader) header, error); } catch(IOException ioe) { HostControllerLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
/** * Write the header information to the provided {@link java.io.DataOutput}. * * @param output The output to write to * @throws IOException If any problems occur writing to the output */ public void write(final DataOutput output) throws IOException { output.write(ManagementProtocol.SIGNATURE); output.writeByte(ManagementProtocol.VERSION_FIELD); output.writeInt(getVersion()); output.writeByte(ManagementProtocol.TYPE); output.writeByte(getType()); }
public static ManagementResponseHeader create(final ManagementProtocolHeader header, int responseId) { final int workingVersion = Math.min(ManagementProtocol.VERSION, header.getVersion()); return new ManagementResponseHeader(workingVersion, responseId, null); }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type)); } } }
public void write(DataOutput output) throws IOException { super.write(output); output.write(ManagementProtocol.RESPONSE_ID); output.writeInt(responseId); output.write(ManagementProtocol.RESPONSE_TYPE); if (error != null) { output.write(ManagementProtocol.RESPONSE_ERROR); output.writeUTF(error); } else { output.write(ManagementProtocol.RESPONSE_BODY); } }
protected static void safeWriteResponse(final Channel channel, final ManagementProtocolHeader header, byte param) { if(header.getType() == ManagementProtocol.TYPE_REQUEST) { try { writeResponse(channel, (ManagementRequestHeader) header, param); } catch(IOException ioe) { HostControllerLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
/** * Write the header information to the provided {@link java.io.DataOutput}. * * @param output The output to write to * @throws IOException If any problems occur writing to the output */ public void write(final DataOutput output) throws IOException { output.write(ManagementProtocol.SIGNATURE); output.writeByte(ManagementProtocol.VERSION_FIELD); output.writeInt(getVersion()); output.writeByte(ManagementProtocol.TYPE); output.writeByte(getType()); }
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<Void> context) throws IOException { byte param = input.readByte(); // If it failed if(param != DomainControllerProtocol.PARAM_OK) { final byte errorCode = input.readByte(); final String message = input.readUTF(); resultHandler.failed(new SlaveRegistrationException(SlaveRegistrationException.ErrorCode.parseCode(errorCode), message)); return; } final ModelNode extensions = new ModelNode(); extensions.readExternal(input); // Enable the send subject if (context.getRequestHeader().getVersion() != 1) { channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IDENTITY, Boolean.TRUE); } context.executeAsync(new ManagementRequestContext.AsyncTask<Void>() { @Override public void execute(ManagementRequestContext<Void> voidManagementRequestContext) throws Exception { // final ModelNode subsystems = resolveSubsystemVersions(extensions); channelHandler.executeRequest(context.getOperationId(), new RegisterSubsystemsRequest(subsystems)); } }); } }