本文整理汇总了Java中io.vertx.core.streams.ReadStream.resume方法的典型用法代码示例。如果您正苦于以下问题:Java ReadStream.resume方法的具体用法?Java ReadStream.resume怎么用?Java ReadStream.resume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.streams.ReadStream
的用法示例。
在下文中一共展示了ReadStream.resume方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: proxyRequestOnly
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestOnly(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
if (bcontent != null) {
proxyRequestHttpClient(it, pc, bcontent, mi);
} else {
final Buffer incoming = Buffer.buffer();
stream.handler(data -> {
incoming.appendBuffer(data);
pc.trace("ProxyRequestOnly request chunk '"
+ data.toString() + "'");
});
stream.endHandler(v -> {
pc.trace("ProxyRequestOnly request end");
proxyRequestHttpClient(it, pc, incoming, mi);
});
stream.resume();
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: proxy
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
public void proxy(RoutingContext ctx) {
ctx.request().pause();
ReadStream<Buffer> stream = ctx.request();
// Pause the request data stream before doing any slow ops, otherwise
// it will get read into a buffer somewhere.
ProxyContext pc = new ProxyContext(ctx);
String tenantId = tenantHeader(pc);
if (tenantId == null) {
stream.resume();
return; // Error code already set in ctx
}
tenantManager.get(tenantId, gres -> {
if (gres.failed()) {
stream.resume();
pc.responseText(400, "No such Tenant " + tenantId);
return;
}
Tenant tenant = gres.result();
moduleManager.getEnabledModules(tenant, mres -> {
if (mres.failed()) {
stream.resume();
pc.responseError(mres.getType(), mres.cause());
return;
}
List<ModuleDescriptor> enabledModules = mres.result();
String metricKey = "proxy." + tenantId + "."
+ ctx.request().method() + "." + ctx.normalisedPath();
DropwizardHelper.markEvent(metricKey);
String authToken = ctx.request().getHeader(XOkapiHeaders.TOKEN);
List<ModuleInstance> l = getModulesForRequest(pc, enabledModules);
if (l == null) {
stream.resume();
return; // ctx already set up
}
pc.setModList(l);
pc.logRequest(ctx, tenantId);
ctx.request().headers().add(XOkapiHeaders.URL, okapiUrl);
ctx.request().headers().remove(XOkapiHeaders.MODULE_ID);
authHeaders(l, ctx.request().headers(), authToken, pc);
resolveUrls(l.iterator(), res -> {
if (res.failed()) {
stream.resume();
pc.responseError(res.getType(), res.cause());
} else {
proxyR(l.iterator(), pc, stream, null);
}
});
});
});
}
示例5: proxyRequestResponse
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestResponse(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
ModuleInstance mi) {
RoutingContext ctx = pc.getCtx();
HttpClientRequest cReq = httpClient.requestAbs(ctx.request().method(),
makeUrl(mi, ctx), res -> {
if (res.statusCode() >= 200 && res.statusCode() < 300
&& res.getHeader(XOkapiHeaders.STOP) == null
&& it.hasNext()) {
makeTraceHeader(mi, res.statusCode(), pc);
relayToRequest(res, pc);
res.pause();
proxyR(it, pc, res, null);
} else {
relayToResponse(ctx.response(), res);
makeTraceHeader(mi, res.statusCode(), pc);
res.handler(data -> {
ctx.response().write(data);
pc.trace("ProxyRequestResponse response chunk '"
+ data.toString() + "'");
});
res.endHandler(v -> {
pc.closeTimer();
ctx.response().end();
pc.trace("ProxyRequestResponse response end");
});
res.exceptionHandler(e
-> pc.warn("proxyRequestResponse: res exception ", e));
}
});
cReq.exceptionHandler(e -> {
pc.warn("proxyRequestResponse failure: ", e);
pc.responseText(500, "proxyRequestResponse failure: "
+ mi.getModuleDescriptor().getId() + " " + mi.getUrl() + ": "
+ e + " " + e.getMessage());
});
cReq.headers().setAll(ctx.request().headers());
cReq.headers().remove("Content-Length");
if (bcontent != null) {
pc.trace("proxyRequestResponse request buf '" + bcontent + "'");
cReq.end(bcontent);
} else {
cReq.setChunked(true);
stream.handler(data -> {
pc.trace("proxyRequestResponse request chunk '"
+ data.toString() + "'");
cReq.write(data);
});
stream.endHandler(v -> {
pc.trace("proxyRequestResponse request complete");
cReq.end();
});
stream.exceptionHandler(e
-> pc.warn("proxyRequestResponse: content exception ", e));
stream.resume();
}
log(pc, cReq);
}
示例6: proxyR
import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyR(Iterator<ModuleInstance> it,
ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent) {
RoutingContext ctx = pc.getCtx();
if (!it.hasNext()) {
stream.resume();
pc.debug("proxyR: Not found");
pc.responseText(404, ""); // Should have been caught earlier
} else {
ModuleInstance mi = it.next();
String tenantId = ctx.request().getHeader(XOkapiHeaders.TENANT);
if (tenantId == null || tenantId.isEmpty()) {
tenantId = "???"; // Should not happen, we have validated earlier
}
String metricKey = "proxy." + tenantId
+ ".module." + mi.getModuleDescriptor().getId();
pc.startTimer(metricKey);
// Pass the right token
ctx.request().headers().remove(XOkapiHeaders.TOKEN);
String token = mi.getAuthToken();
if (token != null && !token.isEmpty()) {
ctx.request().headers().add(XOkapiHeaders.TOKEN, token);
}
// Pass the X-Okapi-Filter header for filters (only)
ctx.request().headers().remove(XOkapiHeaders.FILTER);
if (mi.getRoutingEntry().getPhase() != null) {
String pth = mi.getRoutingEntry().getPathPattern();
if (pth == null) {
pth = mi.getRoutingEntry().getPath();
}
String filt = mi.getRoutingEntry().getPhase() + " " + pth;
pc.debug("Adding " + XOkapiHeaders.FILTER + ": " + filt);
ctx.request().headers().add(XOkapiHeaders.FILTER, filt);
}
ProxyType pType = mi.getRoutingEntry().getProxyType();
if (pType != ProxyType.REDIRECT) {
pc.debug("Invoking module " + mi.getModuleDescriptor().getId()
+ " type " + pType
+ " level " + mi.getRoutingEntry().getPhaseLevel()
+ " path " + mi.getUri()
+ " url " + mi.getUrl());
}
switch (pType) {
case REQUEST_ONLY:
proxyRequestOnly(it, pc, stream, bcontent, mi);
break;
case REQUEST_RESPONSE:
proxyRequestResponse(it, pc, stream, bcontent, mi);
break;
case HEADERS:
proxyHeaders(it, pc, stream, bcontent, mi);
break;
case REDIRECT:
proxyRedirect(it, pc, stream, bcontent, mi);
break;
case INTERNAL:
proxyInternal(it, pc, stream, bcontent, mi);
break;
case REQUEST_RESPONSE_1_0:
proxyRequestResponse10(it, pc, stream, bcontent, mi);
break;
default:
// Should not happen
pc.responseText(500, "Bad proxy type '" + pType
+ "' in module " + mi.getModuleDescriptor().getId());
break;
}
}
}