Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelEvent


      Date newDate = new Date(newTime);
      slog("Hey Guys !  I got a date ! [" + date + "] and I modified it to [" + newDate + "]");
      // Send back the reponse
      Channel channel = e.getChannel();
      ChannelFuture channelFuture = Channels.future(e.getChannel());
      ChannelEvent responseEvent = new DownstreamMessageEvent(channel, channelFuture, newDate, channel.getRemoteAddress());
      ctx.sendDownstream(responseEvent);
      // But still send it upstream because there might be another handler
      super.messageReceived(ctx, e);
    }   
View Full Code Here


     *         if failed to receive a new message
     * @throws InterruptedException
     *         if the operation has been interrupted
     */
    public E read() throws IOException, InterruptedException {
        ChannelEvent e = readEvent();
        if (e == null) {
            return null;
        }

        if (e instanceof MessageEvent) {
View Full Code Here

     *         if failed to receive a new message
     * @throws InterruptedException
     *         if the operation has been interrupted
     */
    public E read(long timeout, TimeUnit unit) throws IOException, InterruptedException {
        ChannelEvent e = readEvent(timeout, unit);
        if (e == null) {
            return null;
        }

        if (e instanceof MessageEvent) {
View Full Code Here

            if (getQueue().isEmpty()) {
                return null;
            }
        }

        ChannelEvent e = getQueue().take();
        if (e instanceof ChannelStateEvent) {
            // channelClosed has been triggered.
            assert closed;
            return null;
        } else {
View Full Code Here

            if (getQueue().isEmpty()) {
                return null;
            }
        }

        ChannelEvent e = getQueue().poll(timeout, unit);
        if (e == null) {
            throw new BlockingReadTimeoutException();
        } else if (e instanceof ChannelStateEvent) {
            // channelClosed has been triggered.
            assert closed;
View Full Code Here

     * make sure important tasks are not counted.
     */
    protected boolean shouldCount(Runnable task) {
        if (task instanceof ChannelEventRunnable) {
            ChannelEventRunnable r = (ChannelEventRunnable) task;
            ChannelEvent e = r.getEvent();
            if (e instanceof WriteCompletionEvent) {
                return false;
            } else if (e instanceof ChannelStateEvent) {
                if (((ChannelStateEvent) e).getState() == ChannelState.INTEREST_OPS) {
                    return false;
View Full Code Here

    @Test
    public void testReleaseExternalResourceViaUpstreamEvent() throws Exception {
       
        Channel channel = createMock(Channel.class);
        expect(channel.isOpen()).andReturn(true).anyTimes();
        ChannelEvent event = createMock(ChannelEvent.class);
        expect(event.getChannel()).andReturn(channel).anyTimes();
        expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel,false)).anyTimes();
        replay(channel, event);
       
        final CountDownLatch latch = new CountDownLatch(1);
       
        OrderedMemoryAwareThreadPoolExecutor executor = new OrderedMemoryAwareThreadPoolExecutor(10, 0L, 0L);
View Full Code Here

   
    @Test
    public void testReleaseExternalResourceViaDownstreamEvent() throws Exception {
        Channel channel = createMock(Channel.class);
        expect(channel.getCloseFuture()).andReturn(new DefaultChannelFuture(channel, false));
        ChannelEvent event = createMock(ChannelEvent.class);
        expect(event.getChannel()).andReturn(channel).anyTimes();
        expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel,false)).anyTimes();
       

        replay(channel, event);

        final CountDownLatch latch = new CountDownLatch(1);
View Full Code Here

        for (Runnable task: tasks) {
            if (task instanceof ChannelEventRunnable) {
                if (cause == null) {
                    cause = new IOException("Unable to process queued event");
                }
                ChannelEvent event = ((ChannelEventRunnable) task).getEvent();
                event.getFuture().setFailure(cause);

                if (channels == null) {
                    channels = new HashSet<Channel>();
                }

                // store the Channel of the event for later notification of the exceptionCaught event
                channels.add(event.getChannel());
            }
        }

        // loop over all channels and fire an exceptionCaught event
        if (channels != null) {
View Full Code Here

     * make sure important tasks are not counted.
     */
    protected boolean shouldCount(Runnable task) {
        if (task instanceof ChannelUpstreamEventRunnable) {
            ChannelUpstreamEventRunnable r = (ChannelUpstreamEventRunnable) task;
            ChannelEvent e = r.getEvent();
            if (e instanceof WriteCompletionEvent) {
                return false;
            } else if (e instanceof ChannelStateEvent) {
                if (((ChannelStateEvent) e).getState() == ChannelState.INTEREST_OPS) {
                    return false;
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.ChannelEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.