Package java.nio.channels

Examples of java.nio.channels.Pipe.sink()


    final BasicThreadingContext threading = BasicThreadingContext.create (this, exceptions, exceptions.catcher);
    Assert.assertTrue (threading.initialize (AbacusTest.defaultPollTimeout));
    final BasicCallbackReactor reactor = BasicCallbackReactor.create (threading, exceptions);
    Assert.assertTrue (reactor.initialize (AbacusTest.defaultPollTimeout));
    final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.defaultInstance;
    final BasicChannel serverChannel = BasicChannel.create (pipe1.source (), pipe2.sink (), coder, reactor, threading, exceptions);
    final BasicChannel clientChannel = BasicChannel.create (pipe2.source (), pipe1.sink (), coder, reactor, threading, exceptions);
    final BasicComponent serverComponent = BasicComponent.create (reactor, exceptions);
    final BasicComponent clientComponent = BasicComponent.create (reactor, exceptions);
    Assert.assertTrue (serverChannel.initialize (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientChannel.initialize (AbacusTest.defaultPollTimeout));
View Full Code Here


      Assert.assertNotNull (reply.outputsOrError);
      Assert.assertEquals (request.reference, reply.reference);
      Assert.assertTrue ((operandA + operandB) == ((Number) reply.outputsOrError).doubleValue ());
    }
    pipe1.sink ().close ();
    pipe2.sink ().close ();
    Assert.assertTrue (serverComponent.await (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientComponent.await (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (serverComponent.destroy (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientComponent.destroy (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (serverChannel.destroy (AbacusTest.defaultPollTimeout));
View Full Code Here

  @Test
  public void testNewPipePartialReadSemantics() throws IOException {
    Pipe pipe = Pipe.open();
    int sz = 10;
    ByteBuffer buf = ByteBuffer.allocate(sz);
    pipe.sink().write(ByteBuffer.wrap("small".getBytes()));
    int rdSz = pipe.source().read(buf); // this operation blocks!
    assertTrue(rdSz <= sz);
  }

  /**
 
View Full Code Here

  public void testSocketIOWithTimeout() throws Exception {
   
    // first open pipe:
    Pipe pipe = Pipe.open();
    Pipe.SourceChannel source = pipe.source();
    Pipe.SinkChannel sink = pipe.sink();
   
    try {
      final InputStream in = new SocketInputStream(source, TIMEOUT);
      OutputStream out = new SocketOutputStream(sink, TIMEOUT);
     
View Full Code Here

    NioPipeConnection(final NioXnio nioXnio, final IoHandler<? super StreamChannel> leftHandler, final IoHandler<? super StreamChannel> rightHandler, final Executor executor) throws IOException {
        final Pipe leftToRight = Pipe.open();
        final Pipe rightToLeft = Pipe.open();
        final Pipe.SourceChannel leftToRightSource = leftToRight.source();
        final Pipe.SinkChannel leftToRightSink = rightToLeft.sink();
        final Pipe.SourceChannel rightToLeftSource = rightToLeft.source();
        final Pipe.SinkChannel rightToLeftSink = leftToRight.sink();
        leftToRightSource.configureBlocking(false);
        leftToRightSink.configureBlocking(false);
        rightToLeftSource.configureBlocking(false);
View Full Code Here

    private final NioPipeSinkChannelImpl sinkSide;

    NioOneWayPipeConnection(final NioXnio nioXnio, final IoHandler<? super StreamSourceChannel> sourceHandler, final IoHandler<? super StreamSinkChannel> sinkHandler, final Executor executor) throws IOException {
        final Pipe pipe = Pipe.open();
        final Pipe.SourceChannel source = pipe.source();
        final Pipe.SinkChannel sink = pipe.sink();
        source.configureBlocking(false);
        sink.configureBlocking(false);
        final MBean mbean;
        try {
            mbean = new MBean();
View Full Code Here

  @Test
  public void testNewPipePartialReadSemantics() throws IOException {
    Pipe pipe = Pipe.open();
    int sz = 10;
    ByteBuffer buf = ByteBuffer.allocate(sz);
    pipe.sink().write(ByteBuffer.wrap("small".getBytes()));
    int rdSz = pipe.source().read(buf); // this operation blocks!
    assertTrue(rdSz <= sz);
  }

  /**
 
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.