当前位置: 首页>>代码示例>>Java>>正文


Java ReadStream类代码示例

本文整理汇总了Java中io.vertx.core.streams.ReadStream的典型用法代码示例。如果您正苦于以下问题:Java ReadStream类的具体用法?Java ReadStream怎么用?Java ReadStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReadStream类属于io.vertx.core.streams包,在下文中一共展示了ReadStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modify

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Override
public FdfsClient modify(ReadStream<Buffer> stream, long size, FdfsFileId fileId, long offset,
		Handler<AsyncResult<Void>> handler) {
	getTracker().setHandler(tracker -> {
		if (tracker.succeeded()) {
			tracker.result().getStoreStorage(fileId.group(), storage -> {
				if (storage.succeeded()) {
					storage.result().modify(stream, size, fileId, offset, modify -> {
						handler.handle(modify);
					});
				} else {
					handler.handle(Future.failedFuture(storage.cause()));
				}
			});
		} else {
			handler.handle(Future.failedFuture(tracker.cause()));
		}
	});

	return this;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:22,代码来源:FdfsClientImpl.java

示例2: append

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Override
public FdfsClient append(ReadStream<Buffer> stream, long size, FdfsFileId fileId,
		Handler<AsyncResult<Void>> handler) {
	getTracker().setHandler(tracker -> {
		if (tracker.succeeded()) {
			tracker.result().getStoreStorage(fileId.group(), storage -> {
				if (storage.succeeded()) {
					storage.result().append(stream, size, fileId, append -> {
						handler.handle(append);
					});
				} else {
					handler.handle(Future.failedFuture(storage.cause()));
				}
			});
		} else {
			handler.handle(Future.failedFuture(tracker.cause()));
		}
	});

	return this;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:22,代码来源:FdfsClientImpl.java

示例3: myPermissionHandle

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
/**
 * Simple test to fake a _tenantPermission interface.
 * Captures the body, and reports it in a header.
 *
 * @param ctx
 */
private void myPermissionHandle(RoutingContext ctx) {
  ReadStream<Buffer> content = ctx.request();
  final Buffer incoming = Buffer.buffer();
  content.handler(incoming::appendBuffer);
  ctx.request().endHandler(x -> {
    String body = incoming.toString();
    body = body.replaceAll("\\s+", " "); // remove newlines etc
    ctx.response().putHeader("X-Tenant-Perms-Result", body);
    if (body.length() > 80) {
      body = body.substring(0, 80) + "...";
    }
    logger.info("tenantPermissions: " + body);
    ctx.response().end();
  });
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:22,代码来源:MainVerticle.java

示例4: testClosedKeyStream

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Test
public void testClosedKeyStream() {
  Map<JsonObject, Buffer> map = genJsonToBuffer(100);
  loadData(map, (vertx, asyncMap) -> {
    List<JsonObject> keys = new ArrayList<>();
    ReadStream<JsonObject> stream = InfinispanAsyncMap.<JsonObject, Buffer>unwrap(asyncMap).keyStream();
    stream.exceptionHandler(t -> {
      fail(t);
    }).handler(jsonObject -> {
      keys.add(jsonObject);
      if (jsonObject.getInteger("key") == 38) {
        stream.handler(null);
        int emitted = keys.size();
        vertx.setTimer(500, tid -> {
          assertTrue("Items emitted after close", emitted == keys.size());
          testComplete();
        });
      }
    });
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:23,代码来源:InfinispanClusteredAsyncMapTest.java

示例5: proxyRequestResponse10

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
private void proxyRequestResponse10(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  if (bcontent != null) {
    proxyRequestResponse(it, pc, null, bcontent, mi);
  } else {
    final Buffer incoming = Buffer.buffer();
    stream.handler(data -> {
      incoming.appendBuffer(data);
      pc.trace("ProxyRequestBlock request chunk '"
        + data.toString() + "'");
    });
    stream.endHandler(v -> {
      pc.trace("ProxyRequestBlock request end");
      proxyRequestResponse(it, pc, null, incoming, mi);
    });
    stream.resume();
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:21,代码来源:ProxyService.java

示例6: proxyInternal

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
private void proxyInternal(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  pc.debug("proxyInternal " + mi.getModuleDescriptor().getId());
  if (bcontent != null) {
    proxyInternalBuffer(it, pc, bcontent, mi);
  } else { // read the whole request into a buffer
    final Buffer incoming = Buffer.buffer();
    stream.handler(data -> {
      incoming.appendBuffer(data);
      pc.trace("proxyInternal request chunk '"
        + data.toString() + "'");
    });
    stream.endHandler(v -> {
      pc.trace("proxyInternal request end");
      proxyInternalBuffer(it, pc, incoming, mi);
    });
    stream.resume();
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:22,代码来源:ProxyService.java

示例7: testSmall

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
public void testSmall(TestContext context, boolean encrypt) throws IOException {

        SfsVertx sfsVertx = new SfsVertxImpl(rule.vertx(), backgroundPool, ioPool);
        Path tmpDir = createTempDirectory(valueOf(currentTimeMillis()));

        Buffer testBuffer = buffer("test");
        Async async = context.async();
        aVoid()
                .flatMap(aVoid -> {
                    FileBackedBuffer fileBackedBuffer = new FileBackedBuffer(sfsVertx, 2, encrypt, tmpDir);
                    ReadStream<Buffer> readStream = new BufferReadStream(testBuffer);
                    return pump(readStream, fileBackedBuffer)
                            .flatMap(aVoid1 -> {
                                ReadStream<Buffer> fileBackedReadStream = fileBackedBuffer.readStream();
                                BufferWriteEndableWriteStream bufferedWriteStreamConsumer = new BufferWriteEndableWriteStream();
                                return pump(fileBackedReadStream, bufferedWriteStreamConsumer)
                                        .doOnNext(aVoid2 -> {
                                            Buffer actualBuffer = bufferedWriteStreamConsumer.toBuffer();
                                            assertArrayEquals(context, testBuffer.getBytes(), actualBuffer.getBytes());
                                            assertEquals(context, true, fileBackedBuffer.isFileOpen());
                                        });
                            })
                            .flatMap(aVoid1 -> fileBackedBuffer.close());
                })
                .subscribe(new TestSubscriber(context, async));
    }
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:27,代码来源:FileBackedBufferTest.java

示例8: testOnlyBuffer

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
public void testOnlyBuffer(TestContext context, boolean encrypt) throws IOException {

        SfsVertx sfsVertx = new SfsVertxImpl(rule.vertx(), backgroundPool, ioPool);
        Path tmpDir = createTempDirectory(valueOf(currentTimeMillis()));

        Buffer testBuffer = buffer("test");
        Async async = context.async();
        aVoid()
                .flatMap(aVoid -> {
                    FileBackedBuffer fileBackedBuffer = new FileBackedBuffer(sfsVertx, 1024, encrypt, tmpDir);
                    ReadStream<Buffer> readStream = new BufferReadStream(testBuffer);
                    return pump(readStream, fileBackedBuffer)
                            .flatMap(aVoid1 -> {
                                ReadStream<Buffer> fileBackedReadStream = fileBackedBuffer.readStream();
                                BufferWriteEndableWriteStream bufferedWriteStreamConsumer = new BufferWriteEndableWriteStream();
                                return pump(fileBackedReadStream, bufferedWriteStreamConsumer)
                                        .doOnNext(aVoid2 -> {
                                            Buffer actualBuffer = bufferedWriteStreamConsumer.toBuffer();
                                            assertArrayEquals(context, testBuffer.getBytes(), actualBuffer.getBytes());
                                            assertEquals(context, false, fileBackedBuffer.isFileOpen());
                                        });
                            })
                            .flatMap(aVoid1 -> fileBackedBuffer.close());
                })
                .subscribe(new TestSubscriber(context, async));
    }
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:27,代码来源:FileBackedBufferTest.java

示例9: search

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
/**
 * <p>Search the GeoRocket data store and return a {@link ReadStream} of
 * merged chunks matching the given criteria.</p>
 * <p>If <code>query</code> is <code>null</code> or empty all chunks from
 * the given <code>layer</code> (and all sub-layers) will be returned. If
 * <code>layer</code> is also <code>null</code> or empty the contents of the
 * whole data store will be returned.</p>
 * <p>The caller is responsible for handling exceptions through
 * {@link ReadStream#exceptionHandler(Handler)}.</p>
 * @param query a search query specifying which chunks to return (may be
 * <code>null</code>)
 * @param layer the name of the layer where to search for chunks recursively
 * (may be <code>null</code>)
 * @param handler a handler that will receive the {@link ReadStream} from
 * which the merged chunks matching the given criteria can be read
 */
public void search(String query, String layer,
    Handler<AsyncResult<ReadStream<Buffer>>> handler) {
  if ((query == null || query.isEmpty()) && (layer == null || layer.isEmpty())) {
    handler.handle(Future.failedFuture("No search query and no layer given. "
        + "Do you really wish to export/query the whole data store? If so, "
        + "set the layer to '/'."));
    return;
  }
  String queryPath = prepareQuery(query, layer);
  HttpClientRequest request = client.get(getEndpoint() + queryPath);
  request.exceptionHandler(t -> handler.handle(Future.failedFuture(t)));
  request.handler(response -> {
    if (response.statusCode() == 404) {
      fail(response, handler, message -> new NoSuchElementException(ClientAPIException.parse(message).getMessage()));
    } else if (response.statusCode() != 200) {
      fail(response, handler);
    } else {
      handler.handle(Future.succeededFuture(response));
    }
  });
  configureRequest(request).end();
}
 
开发者ID:georocket,项目名称:georocket,代码行数:39,代码来源:StoreClient.java

示例10: putBinaryBody

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
public MultipartHelper putBinaryBody(String name, ReadStream<Buffer> stream, String contentType, String fileName, Handler<AsyncResult> handler) {
    request
            .write("--")
            .write(boundary)
            .write(System.lineSeparator())
            .write(String.format("Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"", name, fileName))
            .write(System.lineSeparator())
            .write(String.format("Content-Type: %s", contentType))
            .write(System.lineSeparator())
            .write("Content-Transfer-Encoding: binary")
            .write(System.lineSeparator())
            .write(System.lineSeparator());
    Pump.pump(stream
            .endHandler(event -> {
                request.write(System.lineSeparator());
                handler.handle(createResult(true, null));
            })
            .exceptionHandler(e -> handler.handle(createResult(false, e))), request)
            .start();
    return this;
}
 
开发者ID:flicus,项目名称:vertx-telegram-bot-api,代码行数:22,代码来源:MultipartHelper.java

示例11: resume

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Override
public ReadStream<JsonObject> resume() {
  JsonObject conf;
  Handler<JsonObject> succ;
  synchronized (this) {
    if (! paused) {
      // Cannot resume a non paused stream
      return this;
    }

    paused = false;
    conf = last;
    if (last != null) {
      last = null;
    }
    succ = this.handler;
  }

  if (conf != null && succ != null) {
    vertx.runOnContext(v -> succ.handle(conf));
  }

  return this;
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:25,代码来源:ConfigRetrieverImpl.java

示例12: asyncStore

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
/**
 * Asynchronously store content from source to filePath,
 * and call onEnd when finished
 * @param source
 * @param filePath
 * @param onEnd
 */
public static void asyncStore(Vertx vertx,
                       ReadStream<Buffer> source,
                       String filePath,
                       Handler<Void> onEnd) {
    checkDir(filePath);
    source.pause();
    vertx.fileSystem().open(filePath,
            new OpenOptions().setWrite(true).setCreate(true),
            fres -> {
                AsyncFile afile = fres.result();
                Pump pump = Pump.pump(source, afile);
                source.endHandler(onEnd);
                pump.start();
                source.resume();
            });
}
 
开发者ID:ljie-PI,项目名称:tentacles,代码行数:24,代码来源:AsyncFileStore.java

示例13: upload

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Override
public FdfsClient upload(ReadStream<Buffer> stream, long size, String ext,
		Handler<AsyncResult<FdfsFileId>> handler) {

	if (Buffer.buffer(ext, options.getCharset()).length() > FdfsProtocol.FDFS_FILE_EXT_NAME_MAX_LEN) {
		handler.handle(Future
				.failedFuture("ext is too long ( greater than " + FdfsProtocol.FDFS_FILE_EXT_NAME_MAX_LEN + ")"));
		return this;
	}

	getTracker().setHandler(tracker -> {
		if (tracker.succeeded()) {
			tracker.result().getStoreStorage(storage -> {
				if (storage.succeeded()) {
					storage.result().upload(stream, size, ext, upload -> {
						handler.handle(upload);
					});
				} else {
					handler.handle(Future.failedFuture(storage.cause()));
				}
			});
		} else {
			handler.handle(Future.failedFuture(tracker.cause()));
		}
	});

	return this;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:29,代码来源:FdfsClientImpl.java

示例14: uploadAppender

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
@Override
public FdfsClient uploadAppender(ReadStream<Buffer> stream, long size, String ext,
		Handler<AsyncResult<FdfsFileId>> handler) {

	if (Buffer.buffer(ext, options.getCharset()).length() > FdfsProtocol.FDFS_FILE_EXT_NAME_MAX_LEN) {
		handler.handle(Future
				.failedFuture("ext is too long ( greater than " + FdfsProtocol.FDFS_FILE_EXT_NAME_MAX_LEN + ")"));
		return this;
	}

	getTracker().setHandler(tracker -> {
		if (tracker.succeeded()) {
			tracker.result().getStoreStorage(storage -> {
				if (storage.succeeded()) {
					storage.result().uploadAppender(stream, size, ext, uploadAppender -> {
						handler.handle(uploadAppender);
					});
				} else {
					handler.handle(Future.failedFuture(storage.cause()));
				}
			});
		} else {
			handler.handle(Future.failedFuture(tracker.cause()));
		}
	});

	return this;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:29,代码来源:FdfsClientImpl.java

示例15: proxyRedirect

import io.vertx.core.streams.ReadStream; //导入依赖的package包/类
private void proxyRedirect(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  pc.trace("ProxyNull " + mi.getModuleDescriptor().getId());
  pc.closeTimer();
  // if no more entries in it, proxyR will return 404
  proxyR(it, pc, stream, bcontent);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:10,代码来源:ProxyService.java


注:本文中的io.vertx.core.streams.ReadStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。