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


Java WriteStream类代码示例

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


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

示例1: sendFrame

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
public static void sendFrame(String type, String address, String replyAddress, String headers, Boolean send, String body, WriteStream<Buffer> handler) {
  final JsonObject payload = new JsonObject().put("type", type);

  if (address != null) {
    payload.put("address", address);
  }

  if (replyAddress != null) {
    payload.put("replyAddress", replyAddress);
  }

  if (headers != null) {
    payload.put("headers", headers);
  }

  if (body != null) {
    payload.put("body", body);
  }

  if (send != null) {
    payload.put("send", send);
  }

  writeFrame(payload, handler);
}
 
开发者ID:zzqfsy,项目名称:spring-vertx-tcp,代码行数:26,代码来源:FrameHelper.java

示例2: download

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
@Override
public FdfsClient download(FdfsFileId fileId, WriteStream<Buffer> stream, long offset, long bytes,
		Handler<AsyncResult<Void>> handler) {
	getTracker().setHandler(tracker -> {
		if (tracker.succeeded()) {
			tracker.result().getFetchStorage(fileId, storage -> {
				if (storage.succeeded()) {
					storage.result().download(fileId, stream, offset, bytes, download -> {
						handler.handle(download);
					});
				} 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: append

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
public static Observable<Void> append(Buffer buffer, final WriteStream<Buffer> ws) {
    return Observable.defer(() -> {

        ObservableFuture<Void> drainHandler = RxHelper.observableFuture();
        ws.exceptionHandler(drainHandler::fail);
        if (ws.writeQueueFull()) {
            ws.drainHandler(drainHandler::complete);
        } else {
            drainHandler.complete(null);
        }

        return drainHandler.flatMap(aVoid -> {
            ObservableFuture<Void> writeHandler = RxHelper.observableFuture();
            ws.exceptionHandler(writeHandler::fail);
            ws.write(buffer);
            if (ws.writeQueueFull()) {
                ws.drainHandler(writeHandler::complete);
            } else {
                writeHandler.complete(null);
            }
            return writeHandler;
        });
    });
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:25,代码来源:AsyncIO.java

示例4: merge

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
@Override
public Observable<Void> merge(ChunkReadStream chunk, XMLChunkMeta meta,
    WriteStream<Buffer> out) {
  return canMerge(meta)
    .flatMap(b -> {
      if (!b) {
        return Observable.error(new IllegalArgumentException(
            "Chunk cannot be merged with this strategy"));
      }
      if (!headerWritten) {
        writeHeader(out);
        headerWritten = true;
      }
      return writeChunk(chunk, meta, out);
    });
}
 
开发者ID:georocket,项目名称:georocket,代码行数:17,代码来源:AbstractMergeStrategy.java

示例5: simpleImport

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test a simple import
 * @param context the test context
 */
@Test
public void simpleImport(TestContext context) {
  String url = "/store";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));
  
  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport(
      context.asyncAssertSuccess(v -> {
    verifyPosted(url, XML, context);
    async.complete();
  }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:20,代码来源:StoreClientImportTest.java

示例6: importLayer

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing to a layer
 * @param context the test context
 */
@Test
public void importLayer(TestContext context) {
  String url = "/store/hello/world/";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));
  
  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport("hello/world",
      context.asyncAssertSuccess(v -> {
    verifyPosted(url, XML, context);
    async.complete();
  }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:20,代码来源:StoreClientImportTest.java

示例7: importLayerWithSpecialChars

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing to a layer with special characters
 * @param context the test context
 */
@Test
public void importLayerWithSpecialChars(TestContext context) {
  String url = "/store/he%2Bllo/world/";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));

  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport("he+llo/world",
      context.asyncAssertSuccess(v -> {
    verifyPosted(url, XML, context);
    async.complete();
  }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:20,代码来源:StoreClientImportTest.java

示例8: importTags

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing with tags
 * @param context the test context
 * @throws Exception if something goes wrong
 */
@Test
public void importTags(TestContext context) throws Exception {
  String url = "/store?tags=hello%2Cworld";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));
  
  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport(null,
      Arrays.asList("hello", "world"), context.asyncAssertSuccess(v -> {
    verifyPosted(url, XML, context);
    async.complete();
  }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:21,代码来源:StoreClientImportTest.java

示例9: importProperties

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing properties
 * @param context the test context
 * @throws Exception if something goes wrong
 */
@Test
public void importProperties(TestContext context) throws Exception {
  String url = "/store?props=hello%3Aworld%2Ckey%3Avalue";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));

  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport(null, null,
      Arrays.asList("hello:world", "key:value"), context.asyncAssertSuccess(v -> {
    verifyPosted(url, XML, context);
    async.complete();
  }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:21,代码来源:StoreClientImportTest.java

示例10: importTagsAndProperties

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing tags and properties
 * @param context the test context
 * @throws Exception if something goes wrong
 */
@Test
public void importTagsAndProperties(TestContext context) throws Exception {
  String url = "/store?tags=testTag%2CtestTag2&props=hello%3Awo%5C%3Arld%2Challo2%3Aworld2";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));

  Async async = context.async();
  WriteStream<Buffer> w = client.getStore().startImport(null,
    Arrays.asList("testTag", "testTag2"), Arrays.asList("hello:wo\\:rld", "hallo2:world2"),
    context.asyncAssertSuccess(v -> {
      verifyPosted(url, XML, context);
      async.complete();
    }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:22,代码来源:StoreClientImportTest.java

示例11: importCRS

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing tags and properties
 * @param context the test context
 * @throws Exception if something goes wrong
 */
@Test
public void importCRS(TestContext context) throws Exception {
  String url = "/store?fallbackCRS=test";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));

  Async async = context.async();
  WriteStream<Buffer> w = client.getStore()
    .startImport(null, null, null, Optional.empty(), "test",
      context.asyncAssertSuccess(v -> {
        verifyPosted(url, XML, context);
        async.complete();
      }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:22,代码来源:StoreClientImportTest.java

示例12: importTagsAndCRS

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
/**
 * Test importing tags and properties
 * @param context the test context
 * @throws Exception if something goes wrong
 */
@Test
public void importTagsAndCRS(TestContext context) throws Exception {
  String url = "/store?tags=testTag%2CtestTag2&props=" +
    "hello%3Awo%5C%3Arld%2Challo2%3Aworld2&fallbackCRS=test";
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(202)));

  Async async = context.async();
  WriteStream<Buffer> w = client.getStore()
    .startImport(null, Arrays.asList("testTag", "testTag2"),
      Arrays.asList("hello:wo\\:rld", "hallo2:world2"), Optional.empty(),
      "test", context.asyncAssertSuccess(v -> {
        verifyPosted(url, XML, context);
        async.complete();
      }));
  w.end(Buffer.buffer(XML));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:24,代码来源:StoreClientImportTest.java

示例13: sendFrame

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
public static void sendFrame(String type, String address, String replyAddress, JsonObject headers, Boolean send, JsonObject body, WriteStream<Buffer> handler) {
  final JsonObject payload = new JsonObject().put("type", type);

  if (address != null) {
    payload.put("address", address);
  }

  if (replyAddress != null) {
    payload.put("replyAddress", replyAddress);
  }

  if (headers != null) {
    payload.put("headers", headers);
  }

  if (body != null) {
    payload.put("body", body);
  }

  if (send != null) {
    payload.put("send", send);
  }

  writeFrame(payload, handler);
}
 
开发者ID:vert-x3,项目名称:vertx-tcp-eventbus-bridge,代码行数:26,代码来源:FrameHelper.java

示例14: testMethodWithTypeVarParamByGenericType

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
@Test
public void testMethodWithTypeVarParamByGenericType() throws Exception {
  Runnable test = () -> {
    try {
      ClassModel model = new Generator().generateClass(MethodWithTypeVarParamByGenericType.class);
      MethodInfo meth = model.getMethods().get(0);
      ParamInfo param = meth.getParam(0);
      ParameterizedTypeInfo handler = (ParameterizedTypeInfo) param.getType();
      assertEquals(Handler.class.getName(), handler.getRaw().getName());
      ParameterizedTypeInfo genericInt2 = (ParameterizedTypeInfo) handler.getArg(0);
      assertEquals(GenericInterface2.class.getName(), genericInt2.getRaw().getName());
      TypeVariableInfo k = (TypeVariableInfo) genericInt2.getArg(0);
      assertEquals("K", k.getName());
      TypeVariableInfo v = (TypeVariableInfo) genericInt2.getArg(1);
      assertEquals("V", v.getName());
    } catch (Exception e) {
      throw new AssertionError(e);
    }
  };
  blacklist(test, Stream.of(WriteStream.class));
  test.run();
}
 
开发者ID:vert-x3,项目名称:vertx-codegen,代码行数:23,代码来源:ClassTest.java

示例15: write

import io.vertx.core.streams.WriteStream; //导入依赖的package包/类
@Override
public WriteStream<PipelinePack> write(PipelinePack data) {
    return write(data, asyncResult -> {
        if (asyncResult.failed()) {
            if (exceptionHandler != null) exceptionHandler.handle(asyncResult.cause());
            return;
        }

        if (writeCompleteHandler != null) {
            final WriteCompleteFuture<Void> future = WriteCompleteFuture.future(asyncResult.result());
            future.setHandler(commitDone -> {
                if (commitDone.failed()) {
                    logger.warn("StreamMux - Error during commit. Really nothing we can do here. The producer should retry " +
                            "if it is 'reliable'. Invoking the mux exceptionHandler.");
                    if (exceptionHandler != null) exceptionHandler.handle(asyncResult.cause());
                }
                logger.debug("StreamMux - The exchange is complete now.");
            });
            writeCompleteHandler.handle(future);
        }
    });
}
 
开发者ID:wired-mind,项目名称:usher,代码行数:23,代码来源:StreamMuxImpl.java


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