public void handleError(org.jboss.remoting3.Channel channel, IOException e) { log.error("Error on channel", e); future.setException(e); }
public void handleEnd(org.jboss.remoting3.Channel channel) { log.error("Channel ended."); future.setException(new IOException("Channel ended")); }
/** * Verify the header received, confirm to the server the version selected, create the client * channel receiver and assign it to the channel. */ public void handleMessage( org.jboss.remoting3.Channel channel, MessageInputStream messageInputStream) { DataInputStream dis = new DataInputStream(messageInputStream); try { log.tracef("Bytes Available %d", dis.available()); byte[] firstThree = new byte[3]; dis.read(firstThree); log.tracef("First Three %s", new String(firstThree)); if (Arrays.equals(firstThree, JMX_BYTES) == false) { throw new IOException("Invalid leading bytes in header."); } log.tracef("Bytes Available %d", dis.available()); int versionCount = dis.readInt(); log.tracef("Expecting %d versions", versionCount); byte[] versions = new byte[versionCount]; dis.read(versions); if (log.isDebugEnabled()) { StringBuffer sbVersions = new StringBuffer("Versions "); for (byte current : versions) { sbVersions.append(" 0x0").append(current); } log.debugf("Available version (%s)", sbVersions); } byte stability = dis.readByte(); switch (stability) { case STABLE: log.debug("Calling a stable server"); break; case SNAPSHOT: log.warn("Calling a snapshot server"); break; default: throw new IOException("Unrecognised stability value."); } String serverVersion = null; if (expectServerVersion) { int length = dis.readInt(); byte[] versionBytes = new byte[length]; dis.read(versionBytes); serverVersion = new String(versionBytes, "UTF-8"); log.debugf("Server version %s", serverVersion); } for (byte current : versions) { if (current == 0x00) { sendVersionZeroHeader(channel); expectServerVersion = true; channel.receiveMessage(this); return; } } InitialHeader ih = new InitialHeader(); ih.versions = versions; ih.stability = stability; ih.serverVersion = serverVersion; future.setResult(ih); } catch (IOException e) { log.error("Unable to negotiate connection.", e); future.setException(e); } finally { IoUtils.safeClose(dis); } }