Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.englishtown.vertx.solr.streams.impl;
  
A Solr implementation of the vertx Pump using JsonObjects instead of Buffers
 
 public class SolrPump {
 
     private ReadStream<JsonObjectreadJsonStream;
     private int pumped;

    
Pumps data from a io.vertx.core.streams.ReadStream to a io.vertx.core.streams.WriteStream and performs flow control where necessary to prevent the write stream buffer from getting overfull.

Instances of this class read bytes from a io.vertx.core.streams.ReadStream and write them to a io.vertx.core.streams.WriteStream. This class can be used to pump from any io.vertx.core.streams.ReadStream to any io.vertx.core.streams.WriteStream, e.g. from an OffsetJsonReadStream to a io.vertx.core.json.JsonObject io.vertx.core.streams.WriteStream,

Instances of this class are not thread-safe.

private final WriteStream<JsonObject> writeStream; private final ReadStream<JsonObject> readJsonStream; private int pumped;

/** Create a new SolrDataPump with the given ReadJsonStream and WriteJsonStream

Parameters:
rs ReadStream
ws WriteStream
Returns:
Returns this
 
     public static SolrPump createPump(ReadStream<JsonObjectrsWriteStream<JsonObjectws) {
         return new SolrPump(rsws);
     }

    
Create a new SolrDataPump with the given ReadJsonStream and WriteJsonStream and writeQueueMaxSize

Parameters:
rs ReadStream
ws WriteStream
writeQueueMaxSize Maximum allowed size of the write queue
Returns:
Returns this
 
     public static SolrPump createPump(ReadStream<JsonObjectrsWriteStream<JsonObjectwsint writeQueueMaxSize) {
         return new SolrPump(rswswriteQueueMaxSize);
     }

    
Set the write queue max size to writeQueueMaxSize

Parameters:
maxSize Maximum size to set for the write queue
Returns:
Returns this
 
     public SolrPump setWriteQueueMaxSize(int maxSize) {
         this..setWriteQueueMaxSize(maxSize);
         return this;
     }

    
Start the Pump. The Pump can be started and stopped multiple times.

Returns:
Returns this
 
     public SolrPump start() {
         return this;
     }

    
Stop the SolrDataPump. The SolrDataPump can be started and stopped multiple times.

Returns:
Returns this
 
     public SolrPump stop() {
         .drainHandler(null);
         .handler(null);
         return this;
     }

    
Return the total number of Json objects pumped by this pump.

Returns:
Returns this
 
     public int objectsPumped() {
         return ;
     }
 
     private final Handler<VoiddrainHandler = new Handler<Void>() {
         public void handle(Void v) {
            .resume();
        }
    };
    // defining our data handler, which is a functional object (a parameter that has a method attached to it)
    // passed into the start() method for the Pump
    private final Handler<JsonObjectdataHandler = (JsonObject jsonObject) -> {
            .write(jsonObject);
            ++;
            if (.writeQueueFull()) {
                .pause();
                .drainHandler();
            }
    };

    
Create a new Pump with the given WriteJsonStream. Set the write queue max size of the write stream to maxWriteQueueSize
    private SolrPump(ReadStream<JsonObjectrsWriteStream<JsonObjectwsint maxWriteQueueSize) {
        this(rsws);
        this..setWriteQueueMaxSize(maxWriteQueueSize);
    }
    private SolrPump(ReadStream<JsonObjectrsWriteStream<JsonObjectws) {
        this. = rs;
        this. = ws;
    }
New to GrepCode? Check out our FAQ X