org.jboss.netty.channel.ChannelHandlerContext Java Examples
The following examples show how to use
org.jboss.netty.channel.ChannelHandlerContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BgpUpdate.java From onos with Apache License 2.0 | 6 votes |
/** * Applies the appropriate actions after detecting BGP UPDATE * Attribute Flags Error: send NOTIFICATION and close the channel. * * @param bgpSession the BGP Session to use * @param ctx the Channel Handler Context * @param attrTypeCode the attribute type code * @param attrLen the attribute length (in octets) * @param attrFlags the attribute flags * @param message the message with the data */ private static void actionsBgpUpdateAttributeFlagsError( BgpSession bgpSession, ChannelHandlerContext ctx, int attrTypeCode, int attrLen, int attrFlags, ChannelBuffer message) { log.debug("BGP RX UPDATE Error from {}: Attribute Flags Error", bgpSession.remoteInfo().address()); // // ERROR: Attribute Flags Error // // Send NOTIFICATION and close the connection int errorCode = BgpConstants.Notifications.UpdateMessageError.ERROR_CODE; int errorSubcode = BgpConstants.Notifications.UpdateMessageError.ATTRIBUTE_FLAGS_ERROR; ChannelBuffer data = prepareBgpUpdateNotificationDataPayload(attrTypeCode, attrLen, attrFlags, message); ChannelBuffer txMessage = BgpNotification.prepareBgpNotification(errorCode, errorSubcode, data); ctx.getChannel().write(txMessage); bgpSession.closeSession(ctx); }
Example #2
Source File: SyslogUDPSource.java From mt-flume with Apache License 2.0 | 6 votes |
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent mEvent) { try { syslogUtils.setEventSize(maxsize); Event e = syslogUtils.extractEvent((ChannelBuffer)mEvent.getMessage()); if (e == null) { return; } getChannelProcessor().processEvent(e); counterGroup.incrementAndGet("events.success"); } catch (ChannelException ex) { counterGroup.incrementAndGet("events.dropped"); logger.error("Error writting to channel", ex); return; } }
Example #3
Source File: UdpWorker.java From parallec with Apache License 2.0 | 6 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { if (!hasCaughtException) { hasCaughtException = true; String errMsg = e.getCause().toString(); logger.debug("UDP Handler exceptionCaught: {} . ", errMsg); e.getChannel().close(); int statusCodeInt = 1; String statusCode = statusCodeInt + " FAILURE"; udpWorker.onComplete(udpWorker.responseSb.toString(), true, errMsg, errMsg, statusCode, statusCodeInt); } }
Example #4
Source File: ShuffleHandler.java From RDFS with Apache License 2.0 | 6 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel ch = e.getChannel(); Throwable cause = e.getCause(); if (cause instanceof TooLongFrameException) { sendError(ctx, BAD_REQUEST); return; } LOG.error("Shuffle error: ", cause); shuffleMetrics.failedOutput(); if (ch.isConnected()) { LOG.error("Shuffle error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #5
Source File: BgpUpdate.java From onos with Apache License 2.0 | 6 votes |
/** * Parses BGP UPDATE Attribute Type LOCAL_PREF. * * @param bgpSession the BGP Session to use * @param ctx the Channel Handler Context * @param attrTypeCode the attribute type code * @param attrLen the attribute length (in octets) * @param attrFlags the attribute flags * @param message the message to parse * @return the parsed LOCAL_PREF value * @throws BgpMessage.BgpParseException */ private static long parseAttributeTypeLocalPref( BgpSession bgpSession, ChannelHandlerContext ctx, int attrTypeCode, int attrLen, int attrFlags, ChannelBuffer message) throws BgpMessage.BgpParseException { // Check the Attribute Length if (attrLen != BgpConstants.Update.LocalPref.LENGTH) { // ERROR: Attribute Length Error actionsBgpUpdateAttributeLengthError( bgpSession, ctx, attrTypeCode, attrLen, attrFlags, message); String errorMsg = "Attribute Length Error"; throw new BgpMessage.BgpParseException(errorMsg); } long localPref = message.readUnsignedInt(); return localPref; }
Example #6
Source File: RpcProgram.java From big-c with Apache License 2.0 | 6 votes |
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { RpcInfo info = (RpcInfo) e.getMessage(); RpcCall call = (RpcCall) info.header(); SocketAddress remoteAddress = info.remoteAddress(); if (LOG.isTraceEnabled()) { LOG.trace(program + " procedure #" + call.getProcedure()); } if (this.progNumber != call.getProgram()) { LOG.warn("Invalid RPC call program " + call.getProgram()); sendAcceptedReply(call, remoteAddress, AcceptState.PROG_UNAVAIL, ctx); return; } int ver = call.getVersion(); if (ver < lowProgVersion || ver > highProgVersion) { LOG.warn("Invalid RPC call version " + ver); sendAcceptedReply(call, remoteAddress, AcceptState.PROG_MISMATCH, ctx); return; } handleInternal(ctx, info); }
Example #7
Source File: BgpUpdate.java From onos with Apache License 2.0 | 6 votes |
/** * Applies the appropriate actions after detecting BGP UPDATE * Missing Well-known Attribute Error: send NOTIFICATION and close the * channel. * * @param bgpSession the BGP Session to use * @param ctx the Channel Handler Context * @param missingAttrTypeCode the missing attribute type code */ private static void actionsBgpUpdateMissingWellKnownAttribute( BgpSession bgpSession, ChannelHandlerContext ctx, int missingAttrTypeCode) { log.debug("BGP RX UPDATE Error from {}: Missing Well-known Attribute: {}", bgpSession.remoteInfo().address(), missingAttrTypeCode); // // ERROR: Missing Well-known Attribute // // Send NOTIFICATION and close the connection int errorCode = BgpConstants.Notifications.UpdateMessageError.ERROR_CODE; int errorSubcode = BgpConstants.Notifications.UpdateMessageError.MISSING_WELL_KNOWN_ATTRIBUTE; ChannelBuffer data = ChannelBuffers.buffer(1); data.writeByte(missingAttrTypeCode); ChannelBuffer txMessage = BgpNotification.prepareBgpNotification(errorCode, errorSubcode, data); ctx.getChannel().write(txMessage); bgpSession.closeSession(ctx); }
Example #8
Source File: BgpUpdate.java From onos with Apache License 2.0 | 6 votes |
/** * Applies the appropriate actions after detecting BGP UPDATE * Attribute Length Error: send NOTIFICATION and close the channel. * * @param bgpSession the BGP Session to use * @param ctx the Channel Handler Context * @param attrTypeCode the attribute type code * @param attrLen the attribute length (in octets) * @param attrFlags the attribute flags * @param message the message with the data */ private static void actionsBgpUpdateAttributeLengthError( BgpSession bgpSession, ChannelHandlerContext ctx, int attrTypeCode, int attrLen, int attrFlags, ChannelBuffer message) { log.debug("BGP RX UPDATE Error from {}: Attribute Length Error", bgpSession.remoteInfo().address()); // // ERROR: Attribute Length Error // // Send NOTIFICATION and close the connection int errorCode = BgpConstants.Notifications.UpdateMessageError.ERROR_CODE; int errorSubcode = BgpConstants.Notifications.UpdateMessageError.ATTRIBUTE_LENGTH_ERROR; ChannelBuffer data = prepareBgpUpdateNotificationDataPayload(attrTypeCode, attrLen, attrFlags, message); ChannelBuffer txMessage = BgpNotification.prepareBgpNotification(errorCode, errorSubcode, data); ctx.getChannel().write(txMessage); bgpSession.closeSession(ctx); }
Example #9
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void channelDisconnected( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { super.channelDisconnected( ctx, e ); if ( websocket ) { logger.info( "Websocket disconnected" ); } }
Example #10
Source File: MessageDecoder.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 5 votes |
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { System.out.println(ctx.canHandleUpstream()); List<List<Byte>> objectsDecoded = new LinkedList<>(); int initialIndex = buffer.readerIndex(); int readableBytes = buffer.readableBytes(); List<Byte> bytes = new LinkedList<>(); for (int i = initialIndex; i < initialIndex + readableBytes; i++) { if (buffer.getByte(i) == 0) { buffer.readerIndex(i + 1); objectsDecoded.add(bytes); bytes = new LinkedList<>(); } else { bytes.add(buffer.getByte(i)); } } if (objectsDecoded.size()>0){ return objectsDecoded; } return null; }
Example #11
Source File: RpcUtil.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) { if (buf.readableBytes() < 4) return null; buf.markReaderIndex(); byte[] fragmentHeader = new byte[4]; buf.readBytes(fragmentHeader); int length = XDR.fragmentSize(fragmentHeader); boolean isLast = XDR.isLastFragment(fragmentHeader); if (buf.readableBytes() < length) { buf.resetReaderIndex(); return null; } ChannelBuffer newFragment = buf.readSlice(length); if (currentFrame == null) { currentFrame = newFragment; } else { currentFrame = ChannelBuffers.wrappedBuffer(currentFrame, newFragment); } if (isLast) { ChannelBuffer completeFrame = currentFrame; currentFrame = null; return completeFrame; } else { return null; } }
Example #12
Source File: BasicChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
protected ProtocolSession createSession(ChannelHandlerContext ctx) throws Exception { SSLEngine engine = null; if (secure != null) { engine = secure.getContext().createSSLEngine(); String[] enabledCipherSuites = secure.getEnabledCipherSuites(); if (enabledCipherSuites != null && enabledCipherSuites.length > 0) { engine.setEnabledCipherSuites(enabledCipherSuites); } } return protocol.newSession(new NettyProtocolTransport(ctx.getChannel(), engine)); }
Example #13
Source File: TestBgpPeerFrameDecoder.java From onos with Apache License 2.0 | 5 votes |
/** * Processes BGP OPEN message. * * @param ctx the Channel Handler Context. * @param message the message to process. */ private void processBgpOpen(ChannelHandlerContext ctx, ChannelBuffer message) { int minLength = BgpConstants.BGP_OPEN_MIN_LENGTH - BgpConstants.BGP_HEADER_LENGTH; if (message.readableBytes() < minLength) { // ERROR: Bad Message Length. Close the channel. ctx.getChannel().close(); return; } // // Parse the OPEN message // remoteInfo.setBgpVersion(message.readUnsignedByte()); remoteInfo.setAsNumber(message.readUnsignedShort()); remoteInfo.setHoldtime(message.readUnsignedShort()); remoteInfo.setBgpId(Ip4Address.valueOf((int) message.readUnsignedInt())); // Optional Parameters int optParamLen = message.readUnsignedByte(); if (message.readableBytes() < optParamLen) { // ERROR: Bad Message Length. Close the channel. ctx.getChannel().close(); return; } message.readBytes(optParamLen); // NOTE: data ignored // BGP OPEN message successfully received receivedOpenMessageLatch.countDown(); }
Example #14
Source File: SessionHandler.java From DataLink with Apache License 2.0 | 5 votes |
private void handleGroupCoordinatorRequest(ChannelHandlerContext ctx, Request request) { ResponseHeader responseHeader = new ResponseHeader(request.getHeader().correlationId()); Node activeNode = coordinator.getActiveGroupCoordinator(); if (activeNode == null) { logger.trace("Coordinator不存在"); sendResponse(ctx, new Response(responseHeader, new GroupCoordinatorResponse(Errors.GROUP_COORDINATOR_NOT_AVAILABLE.code(), Node.noNode()))); } else { logger.trace("Coordinator存在,当前Coordinator是:{}", activeNode.toString()); sendResponse(ctx, new Response(responseHeader, new GroupCoordinatorResponse(Errors.NONE.code(), activeNode))); } }
Example #15
Source File: ShuffleHandler.java From RDFS with Apache License 2.0 | 5 votes |
private void sendError(ChannelHandlerContext ctx, String message, HttpResponseStatus status) { HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status); response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); response.setContent( ChannelBuffers.copiedBuffer(message, CharsetUtil.UTF_8)); // Close the connection as soon as the error message is sent. ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE); }
Example #16
Source File: TcpWorker.java From parallec with Apache License 2.0 | 5 votes |
/** * Why not use channelClosed: if fail to establish a channel * (e.g. connection refused). will also call channelClosed. * * @param ctx the ctx * @param e the e * @throws Exception the exception */ @Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { logger.debug("channel is closed. "); int statusCodeInt = 0; String statusCode = statusCodeInt + " SUCCESSFUL"; tcpWorker.onComplete(tcpWorker.responseSb.toString(), false, null, null, statusCode, statusCodeInt); }
Example #17
Source File: RaopRtspChallengeResponseHandler.java From Android-Airplay-Server with MIT License | 5 votes |
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt) throws Exception { final HttpRequest req = (HttpRequest)evt.getMessage(); synchronized(this) { if (req.containsHeader(HeaderChallenge)) { /* The challenge is sent without padding! */ final byte[] challenge = Base64.decodeUnpadded(req.getHeader(HeaderChallenge)); /* Verify that we got 16 bytes */ if (challenge.length != 16) throw new ProtocolException("Invalid Apple-Challenge header, " + challenge.length + " instead of 16 bytes"); /* Remember challenge and local address. * Both are required to compute the response */ m_challenge = challenge; m_localAddress = ((InetSocketAddress)ctx.getChannel().getLocalAddress()).getAddress(); } else { /* Forget last challenge */ m_challenge = null; m_localAddress = null; } } super.messageReceived(ctx, evt); }
Example #18
Source File: NetworkFailureHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void channelClosed(ChannelHandlerContext context, ChannelStateEvent event) throws Exception { Channel targetChannel = sourceToTargetChannels.get(event.getChannel()); if (targetChannel == null) { return; } closeOnFlush(targetChannel); sourceToTargetChannels.remove(event.getChannel()); onClose.accept(this); }
Example #19
Source File: StormServerHandler.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { // removeFailureCounter(e.getChannel()); if (e.getChannel() != null) { LOG.info("Channel occur exception {}, cause={}", e.getChannel().getRemoteAddress(), e.getCause()); } server.closeChannel(e.getChannel()); }
Example #20
Source File: OspfMessageEncoder.java From onos with Apache License 2.0 | 5 votes |
@Override protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) { byte[] byteMsg = (byte[]) msg; log.debug("Encoding ospfMessage of length {}", byteMsg.length); ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length); channelBuffer.writeBytes(byteMsg); return channelBuffer; }
Example #21
Source File: OFControllerChannelHandler.java From FlowSpaceFirewall with Apache License 2.0 | 5 votes |
@Override @LogMessageDoc(message="Disconnected controller {switch information}", explanation="The specified controller has disconnected.") public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { }
Example #22
Source File: NettyCodecAdapter.java From dubbox with Apache License 2.0 | 5 votes |
@Override protected Object encode(ChannelHandlerContext ctx, Channel ch, Object msg) throws Exception { com.alibaba.dubbo.remoting.buffer.ChannelBuffer buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.dynamicBuffer(1024); NettyChannel channel = NettyChannel.getOrAddChannel(ch, url, handler); try { codec.encode(channel, buffer, msg); } finally { NettyChannel.removeChannelIfDisconnected(ch); } return ChannelBuffers.wrappedBuffer(buffer.toByteBuffer()); }
Example #23
Source File: OspfInterfaceImplTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests processDdMessage() method. */ @Test public void testProcessDdMessage() throws Exception { ospfInterface.setOspfArea(ospfArea); ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11")); ospfInterface.setInterfaceType(2); ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255")); ospfInterface.setHelloIntervalTime(10); ospfInterface.setRouterDeadIntervalTime(10); ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12")); channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); OspfMessage message; ddPacket = new DdPacket(); ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1")); ddPacket.setOspfVer(2); ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12")); ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2")); ddPacket.setIsOpaqueCapable(true); ddPacket.setIsMore(1); ddPacket.setIsInitialize(1); ddPacket.setIsMaster(1); ddPacket.setSequenceNo(123); message = ddPacket; ospfNbrHashMap = new HashMap(); ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"), Ip4Address.valueOf("2.2.2.2"), 2, topologyForDeviceAndLink); ospfNbr.setLastDdPacket(createDdPacket()); ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2")); ospfNbr.setState(OspfNeighborState.EXSTART); ospfNbr.setRouterPriority(0); ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13")); ospfNbr.setDdSeqNum(123); ospfInterface.addNeighbouringRouter(ospfNbr); channelHandlerContext = null; channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); ospfInterface.processDdMessage(message, channelHandlerContext); assertThat(ospfInterfaceChannelHandler, is(notNullValue())); }
Example #24
Source File: RpcProgramPortmap.java From big-c with Apache License 2.0 | 5 votes |
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { RpcInfo info = (RpcInfo) e.getMessage(); RpcCall rpcCall = (RpcCall) info.header(); final int portmapProc = rpcCall.getProcedure(); int xid = rpcCall.getXid(); XDR in = new XDR(info.data().toByteBuffer().asReadOnlyBuffer(), XDR.State.READING); XDR out = new XDR(); if (portmapProc == PMAPPROC_NULL) { out = nullOp(xid, in, out); } else if (portmapProc == PMAPPROC_SET) { out = set(xid, in, out); } else if (portmapProc == PMAPPROC_UNSET) { out = unset(xid, in, out); } else if (portmapProc == PMAPPROC_DUMP) { out = dump(xid, in, out); } else if (portmapProc == PMAPPROC_GETPORT) { out = getport(xid, in, out); } else if (portmapProc == PMAPPROC_GETVERSADDR) { out = getport(xid, in, out); } else { LOG.info("PortmapHandler unknown rpc procedure=" + portmapProc); RpcAcceptedReply reply = RpcAcceptedReply.getInstance(xid, RpcAcceptedReply.AcceptState.PROC_UNAVAIL, new VerifierNone()); reply.write(out); } ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap() .buffer()); RpcResponse rsp = new RpcResponse(buf, info.remoteAddress()); RpcUtil.sendRpcResponse(ctx, rsp); }
Example #25
Source File: NettyHandler.java From anima with GNU General Public License v3.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(conf,ctx.getChannel(), handler); try { InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); String key = address.getAddress().getHostAddress() + ":" + address.getPort(); channels.remove(key); handler.disconnected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }
Example #26
Source File: BgpChannelHandler.java From onos with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { log.error("[exceptionCaught]: " + e.toString()); if (e.getCause() instanceof ClosedChannelException) { bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString()); log.debug("Channel for bgp {} already closed", getPeerInfoString()); } else if (e.getCause() instanceof IOException) { log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage()); bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString()); if (log.isDebugEnabled()) { // still print stack trace if debug is enabled log.debug("StackTrace for previous Exception: ", e.getCause()); } stopSessionTimers(); ctx.getChannel().close(); } else if (e.getCause() instanceof BgpParseException) { byte[] data = new byte[] {}; BgpParseException errMsg = (BgpParseException) e.getCause(); byte errorCode = errMsg.getErrorCode(); byte errorSubCode = errMsg.getErrorSubCode(); bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString()); ChannelBuffer tempCb = errMsg.getData(); if (tempCb != null) { int dataLength = tempCb.readableBytes(); data = new byte[dataLength]; tempCb.readBytes(data, 0, dataLength); } sendNotification(errorCode, errorSubCode, data); } else if (e.getCause() instanceof RejectedExecutionException) { log.warn("Could not process message: queue full"); bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString()); } else { stopSessionTimers(); log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state); bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString()); ctx.getChannel().close(); } }
Example #27
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 5 votes |
protected ChannelFuture sendMapOutput(ChannelHandlerContext ctx, Channel ch, String user, String mapId, int reduce, MapOutputInfo mapOutputInfo) throws IOException { final TezIndexRecord info = mapOutputInfo.indexRecord; final ShuffleHeader header = new ShuffleHeader(mapId, info.getPartLength(), info.getRawLength(), reduce); final DataOutputBuffer dob = new DataOutputBuffer(); header.write(dob); ch.write(wrappedBuffer(dob.getData(), 0, dob.getLength())); final File spillfile = new File(mapOutputInfo.mapOutputFileName.toString()); RandomAccessFile spill; try { spill = SecureIOUtils.openForRandomRead(spillfile, "r", user, null); } catch (FileNotFoundException e) { LOG.info(spillfile + " not found"); return null; } ChannelFuture writeFuture; final DefaultFileRegion partition = new DefaultFileRegion(spill.getChannel(), info.getStartOffset(), info.getPartLength()); writeFuture = ch.write(partition); writeFuture.addListener(new ChannelFutureListener() { // TODO error handling; distinguish IO/connection failures, // attribute to appropriate spill output @Override public void operationComplete(ChannelFuture future) { partition.releaseExternalResources(); } }); return writeFuture; }
Example #28
Source File: TestBgpPeerChannelHandler.java From onos with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent channelEvent) { this.savedCtx = ctx; // Prepare and transmit BGP OPEN message ChannelBuffer message = BgpOpen.prepareBgpOpen(localInfo); ctx.getChannel().write(message); // Prepare and transmit BGP KEEPALIVE message message = BgpKeepalive.prepareBgpKeepalive(); ctx.getChannel().write(message); }
Example #29
Source File: ImapChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
@Override public void channelBound(final ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { ImapSession imapsession = new NettyImapSession(ctx.getChannel(), context, enabledCipherSuites, compress, plainAuthDisallowed, SessionId.generate()); attributes.set(ctx.getChannel(), imapsession); try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) { super.channelBound(ctx, e); } }
Example #30
Source File: TcpWorker.java From parallec with Apache License 2.0 | 5 votes |
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { //add \n to the end tcpWorker.responseSb.append(e.getMessage().toString()+"\n"); logger.debug("DONE." + ++msgRecvCount); logger.debug("MSG_RECEIVED_AT_TCP_CLIENT: {}", e.getMessage().toString()); }