io.vertx.core.streams.impl.InboundBuffer Java Examples

The following examples show how to use io.vertx.core.streams.impl.InboundBuffer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDBCSQLRowStream.java    From vertx-jdbc-client with Apache License 2.0 6 votes vote down vote up
JDBCSQLRowStream(ContextInternal ctx, Statement st, ResultSet rs, int fetchSize) throws SQLException {
  this.ctx = ctx;
  this.st = st;
  this.fetchSize = fetchSize;
  this.rs = rs;
  this.pending = new InboundBuffer<JsonArray>(ctx, fetchSize)
    .drainHandler(v -> readBatch())
    .emptyHandler(v -> checkEndHandler());

  metaData = rs.getMetaData();
  cols = metaData.getColumnCount();
  stClosed.set(false);
  rsClosed.set(false);
  // the first rs is populated in the constructor
  more.set(true);
}
 
Example #2
Source File: MultipartFormUpload.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
private void handleChunk(Object item) {
  Handler handler;
  synchronized (MultipartFormUpload.this) {
    if (item instanceof Buffer) {
      handler = dataHandler;
    } else if (item instanceof Throwable) {
      handler = exceptionHandler;
    } else if (item == InboundBuffer.END_SENTINEL) {
      handler = endHandler;
      item = null;
    } else {
      return;
    }
  }
  handler.handle(item);
}
 
Example #3
Source File: SockJSSession.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
SockJSSession(Vertx vertx, LocalMap<String, SockJSSession> sessions, RoutingContext rc, String id, long timeout, long heartbeatInterval,
              Handler<SockJSSocket> sockHandler) {
  super(vertx, rc.session(), rc.user());
  this.sessions = sessions;
  this.id = id;
  this.timeout = timeout;
  this.sockHandler = sockHandler;
  context = vertx.getOrCreateContext();
  pendingReads = new InboundBuffer<>(context);

  // Start a heartbeat

  heartbeatID = vertx.setPeriodic(heartbeatInterval, tid -> {
    if (listener != null) {
      listener.sendFrame("h", null);
    }
  });
}
 
Example #4
Source File: CassandraRowStreamImpl.java    From vertx-cassandra-client with Apache License 2.0 5 votes vote down vote up
public CassandraRowStreamImpl(Context context, ResultSet resultSet) {
  this.context = context;
  this.resultSet = resultSet;
  internalQueue = new InboundBuffer<Row>(context)
    .exceptionHandler(this::handleException)
    .drainHandler(v -> fetchRow());
  state = State.IDLE;
}
 
Example #5
Source File: PublisherAdapter.java    From vertx-mongo-client with Apache License 2.0 5 votes vote down vote up
public PublisherAdapter(ContextInternal context, Publisher<T> publisher, int batchSize) {
  Objects.requireNonNull(context, "context is null");
  Objects.requireNonNull(publisher, "publisher is null");
  this.context = context;
  this.publisher = publisher;
  this.batchSize = batchSize > 0 ? batchSize : 256;
  internalQueue = new InboundBuffer<T>(context);
  state = State.IDLE;
}
 
Example #6
Source File: MultipartFormUpload.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public MultipartFormUpload(Context context,
                           MultipartForm parts,
                           boolean multipart,
                           HttpPostRequestEncoder.EncoderMode encoderMode) throws Exception {
  this.context = context;
  this.pending = new InboundBuffer<>(context)
    .handler(this::handleChunk)
    .drainHandler(v -> run()).pause();
  this.request = new DefaultFullHttpRequest(
    HttpVersion.HTTP_1_1,
    io.netty.handler.codec.http.HttpMethod.POST,
    "/");
  this.encoder = new HttpPostRequestEncoder(
    new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
    request,
    multipart,
    HttpConstants.DEFAULT_CHARSET,
    encoderMode);
  for (FormDataPart formDataPart : parts) {
    if (formDataPart.isAttribute()) {
      encoder.addBodyAttribute(formDataPart.name(), formDataPart.value());
    } else {
      encoder.addBodyFileUpload(formDataPart.name(),
        formDataPart.filename(), new File(formDataPart.pathname()),
        formDataPart.mediaType(), formDataPart.isText());
    }
  }
  encoder.finalizeRequest();
}
 
Example #7
Source File: MailWithDKIMSignTest.java    From vertx-mail-client with Apache License 2.0 4 votes vote down vote up
private FakeReadStream(Context context) {
  this.pending = new InboundBuffer<Buffer>(context).emptyHandler(v -> checkEnd()).pause();
  context.runOnContext(h -> this.pending.write(fakeStreamData()));
}
 
Example #8
Source File: RabbitMQConsumerImpl.java    From vertx-rabbitmq-client with Apache License 2.0 4 votes vote down vote up
RabbitMQConsumerImpl(Context context, QueueConsumerHandler consumerHandler, QueueOptions options) {
  this.consumerHandler = consumerHandler;
  this.keepMostRecent = options.isKeepMostRecent();
  this.maxQueueSize = options.maxInternalQueueSize();
  this.pending = new InboundBuffer<RabbitMQMessage>(context, maxQueueSize).pause();
}