@Override public void handleError(final Channel channel, final IOException error) { ROOT_LOGGER.tracef(error, "%s error handling incoming data", this); try { channel.close(); } catch (IOException e) { ROOT_LOGGER.errorClosingChannel(e.getMessage()); } }
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) { ProtocolLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
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) { ProtocolLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
/** * Safe write error response. * * @param channel the channel * @param header the request header * @param error the exception */ protected static void safeWriteErrorResponse(final Channel channel, final ManagementProtocolHeader header, final Exception error) { if(header.getType() == ManagementProtocol.TYPE_REQUEST) { try { writeErrorResponse(channel, (ManagementRequestHeader) header, error); } catch(IOException ioe) { ProtocolLogger.ROOT_LOGGER.tracef(ioe, "failed to write error response for %s on channel: %s", header, channel); } } }
@Override public void handleMessage(final Channel channel, final MessageInputStream message) { try { ROOT_LOGGER.tracef("%s handling incoming data", this); lastMessageTime = System.currentTimeMillis(); final DataInput input = new DataInputStream(message); if(type == ManagementProtocol.TYPE_PING) { ROOT_LOGGER.tracef("Received ping on %s", this); handlePing(channel, header); } else if (type == ManagementProtocol.TYPE_PONG) { ROOT_LOGGER.tracef("Received on on %s", this); } else if (type == ManagementProtocol.TYPE_BYE_BYE) { ROOT_LOGGER.tracef("Received bye bye on %s, closing", this); handleChannelReset(channel); } else { } finally { StreamUtils.safeClose(message); ROOT_LOGGER.tracef("%s done handling incoming data", this);