Examples of ChannelRejectedException


Examples of com.starlight.intrepid.exception.ChannelRejectedException

    @Override
    public void newChannel( ByteChannel channel, VMID source_vmid,
      Serializable attachment ) throws ChannelRejectedException {

      if ( reject_reason != null ) {
        throw new ChannelRejectedException( reject_reason );
      }

      queue.add( Triple.create( channel, source_vmid, attachment ) );
    }
View Full Code Here

Examples of com.starlight.intrepid.exception.ChannelRejectedException

    ChannelAcceptor acceptor3 = EasyMock.createMock( ChannelAcceptor.class );

    // Scenario 1:
    //  1) Add acceptor 1, deny connection
    acceptor1.newChannel( null, null, "A" );
    EasyMock.expectLastCall().andThrow( new ChannelRejectedException() );
    EasyMock.replay( acceptor1, acceptor2, acceptor3 );

    main_acceptor.addDelegate( acceptor1 );

    try {
      main_acceptor.newChannel( null, null, "A" );
      fail( "Shouldn't have worked" );
    }
    catch( ChannelRejectedException ex ) {
      // Expected
    }

    EasyMock.verify( acceptor1, acceptor2, acceptor3 );

    // Scenario 2:
    //  1) Add acceptor 2 (to end)
    //  2) Acceptor 1 will deny connection
    //  2) Acceptor 2 will approve connection
    EasyMock.reset( acceptor1, acceptor2, acceptor3 );

    acceptor1.newChannel( null, null, "B" );
    EasyMock.expectLastCall().andThrow( new ChannelRejectedException() );
    acceptor2.newChannel( null, null, "B" );
    EasyMock.replay( acceptor1, acceptor2, acceptor3 );

    main_acceptor.addDelegate( acceptor2 );
View Full Code Here

Examples of com.starlight.intrepid.exception.ChannelRejectedException

      catch( ChannelRejectedException ex ) {
        // ignore, keep trying
      }
    }

    throw new ChannelRejectedException( Resources.ERROR_NO_SUITABLE_ACCEPTOR_FOUND );
  }
View Full Code Here

Examples of com.starlight.intrepid.exception.ChannelRejectedException

  public void newChannel( ByteChannel channel, VMID source_vmid,
    Serializable attachment ) throws ChannelRejectedException {

    // Verify the expected type
    if ( !( attachment instanceof ID ) ) {
      throw new ChannelRejectedException( Resources.ERROR_ATTACHMENT_NOT_ID );
    }

    ObjectSlot<Object> slot;
    object_map_lock.lock();
    try {
      //noinspection SuspiciousMethodCalls
      slot = object_map.get( attachment );
    }
    finally {
      object_map_lock.unlock();
    }

    // Make sure we're expecting the object
    if ( slot == null ) {
      throw new ChannelRejectedException(
        new FormattedTextResourceKey( Resources.ERROR_UNKNOWN_ID, attachment ) );
    }
    // Make sure the object hasn't already been read
    else if ( slot.get() != null ) {
      throw new ChannelRejectedException(
        new FormattedTextResourceKey( Resources.ERROR_SLOT_FULL, attachment ) );
    }

    new ChannelReader( channel, slot ).start();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.