use of com.ociweb.gl.impl.stage.HTTPClientRequestTrafficStage in project GreenLightning by oci-pronghorn.
the class BuilderImpl method buildHTTPClientGraph.
public void buildHTTPClientGraph(MsgRuntime<?, ?> runtime, Pipe<NetResponseSchema>[] netResponsePipes, Pipe<ClientHTTPRequestSchema>[] netRequestPipes, Pipe<TrafficReleaseSchema>[][] masterGoOut, Pipe<TrafficAckSchema>[][] masterAckIn) {
// //////
if (useNetClient(netRequestPipes)) {
int maxPartialResponses = Math.max(2, ClientHostPortInstance.getSessionCount());
int connectionsInBits = (int) Math.ceil(Math.log(maxPartialResponses) / Math.log(2));
int netResponseCount = 8;
int responseQueue = 10;
// must be adjusted together
// Multipler per session for total connections ,count of pipes to channel writer
int outputsCount = 8;
// count of channel writer stages
int clientWriters = 1;
PipeConfig<NetPayloadSchema> clientNetRequestConfig = pcm.getConfig(NetPayloadSchema.class);
// BUILD GRAPH
ccm = new ClientCoordinator(connectionsInBits, maxPartialResponses, this.client.getCertificates(), gm.recordTypeData);
Pipe<NetPayloadSchema>[] clientRequests = new Pipe[outputsCount];
int r = outputsCount;
while (--r >= 0) {
clientRequests[r] = new Pipe<NetPayloadSchema>(clientNetRequestConfig);
}
if (isAllNull(masterGoOut[IDX_NET])) {
// this one has much lower latency and should be used if possible
new HTTPClientRequestStage(gm, ccm, netRequestPipes, clientRequests);
} else {
logger.info("Warning, the slower HTTP Client Request code was called. 2ms latency may be introduced.");
// this may stay for as long as 2ms before returning due to timeout of
// traffic logic, this is undesirable in some low latency cases.
new HTTPClientRequestTrafficStage(gm, runtime, this, ccm, netRequestPipes, masterGoOut[IDX_NET], masterAckIn[IDX_NET], clientRequests);
}
int releaseCount = 1024;
// takes more memory but limits writes, each creating a little GC
int writeBufferMultiplier = 100;
int responseUnwrapCount = 2;
int clientWrapperCount = 2;
NetGraphBuilder.buildHTTPClientGraph(gm, ccm, responseQueue, clientRequests, netResponsePipes, netResponseCount, releaseCount, writeBufferMultiplier, responseUnwrapCount, clientWrapperCount, clientWriters);
}
}
Aggregations