Examples of sink()


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

    public Channel[] pipe() {
        clear();
        try {
            Pipe pipe = Pipe.open();
            Channel source = pipe.source(), sink = pipe.sink();

            if (posix.isNative()) {
                // set cloexec if possible
                int read = FilenoUtil.filenoFrom(source);
                int write = FilenoUtil.filenoFrom(sink);
View Full Code Here

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

    final Pipe pipeFromDisco = Pipe.open();
    final DiscoIOChannel ioChannel = new DiscoIOChannel(pipeFromDisco.source(), new NullByteChannel(),
            new DiscoWorkerDecoder().setListener(listener));

    final String okStr = "OK 4 \"ok\"\n";
    pipeFromDisco.sink().write(ByteBuffer.wrap(okStr.getBytes()));
    ioChannel.write(new WorkerAnnounceEncoder().set("1.0", 555));

    inOrder.verify(listener).ok();
  }
View Full Code Here

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

  @Test
  public void testInputFlow() throws IOException {
    final Pipe pipeFromDisco = Pipe.open();

    final DiscoWorker discoWorker = new DiscoWorker(pipeFromDisco.source(), new NullByteChannel());
    final SinkChannel disco = pipeFromDisco.sink();

    // Put messages in the input pipeline (from the disco master)
    final String okStr = "OK 4 \"ok\"\n";
    disco.write(ByteBuffer.wrap(okStr.getBytes()));
    final String taskStr = "TASK 327 {\"taskid\":0,\"master\":\"http://lhoersten-66113:8989\",\"disco_port\":8989,\"put_port\":8990,\"ddfs_data\":\"/srv/disco/ddfs\",\"disco_data\":\"/srv/disco/data\",\"mode\":\"map\",\"jobfile\":\"/srv/disco/data/localhost/5a/lhoersten-FunshineSimulator@524:7310e:1cb44/jobfile\",\"jobname\":\"lhoersten-FunshineSimulator@524:7310e:1cb44\",\"host\":\"localhost\"}\n";
View Full Code Here

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

  @Test
  public void testChannelToString() throws IOException {
    final Pipe pipe = Pipe.open();

    final SinkChannel sink = pipe.sink();
    final String expected = "12345678\n";
    sink.write(ByteBuffer.wrap(expected.getBytes()));

    final String actual = DiscoUtils.channelLineToString(pipe.source());
View Full Code Here

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

        super();
        this.logger = logger;
        try
        {
            Pipe p = Pipe.open();
            SinkChannel sink = p.sink();
            SourceChannel source = p.source();
            writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
            reader = Channels.newReader( source, Charset.defaultCharset().name() );
            parser.setInput( reader );
View Full Code Here

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

  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

Examples of org.apache.axis2.transport.nhttp.util.PipeImpl.sink()

     */
    private void processResponse(final NHttpClientConnection conn, HttpContext context, HttpResponse response) {

        try {
            PipeImpl responsePipe = new PipeImpl();
            context.setAttribute(RESPONSE_SINK_CHANNEL, responsePipe.sink());

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
View Full Code Here

Examples of org.apache.axis2.transport.nhttp.util.PipeImpl.sink()

            // hand off processing of the request to a thread off the pool
            workerPool.execute(
                new ServerWorker(cfgCtx, conn, isHttps, this,
                    request, Channels.newInputStream(requestPipe.source()),
                    response, Channels.newOutputStream(responsePipe.sink())));

        } catch (IOException e) {
            handleException("Error processing request received for : " +
                request.getRequestLine().getUri(), e, conn);
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.axis2.transport.nhttp.util.PipeImpl.sink()

     */
    private void processResponse(final NHttpClientConnection conn, HttpContext context, HttpResponse response) {

        try {
            PipeImpl responsePipe = new PipeImpl();
            context.setAttribute(RESPONSE_SINK_CHANNEL, responsePipe.sink());

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getHttpVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
View Full Code Here

Examples of org.apache.axis2.transport.nhttp.util.PipeImpl.sink()

            // hand off processing of the request to a thread off the pool
            workerPool.execute(
                new ServerWorker(cfgCtx, conn, isHttps, this,
                    request, Channels.newInputStream(requestPipe.source()),
                    response, Channels.newOutputStream(responsePipe.sink())));

        } catch (IOException e) {
            handleException("Error processing request received for : " +
                request.getRequestLine().getUri(), e, conn);
        } catch (Exception e) {
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.