use of com.ociweb.gl.impl.schema.TrafficReleaseSchema in project GreenLightning by oci-pronghorn.
the class BuilderImpl method buildStages.
public void buildStages(MsgRuntime runtime) {
IntHashTable subscriptionPipeLookup2 = MsgRuntime.getSubPipeLookup(runtime);
GraphManager gm = MsgRuntime.getGraphManager(runtime);
Pipe<NetResponseSchema>[] httpClientResponsePipes = GraphManager.allPipesOfTypeWithNoProducer(gm, NetResponseSchema.instance);
Pipe<MessageSubscription>[] subscriptionPipes = GraphManager.allPipesOfTypeWithNoProducer(gm, MessageSubscription.instance);
Pipe<TrafficOrderSchema>[] orderPipes = GraphManager.allPipesOfTypeWithNoConsumer(gm, TrafficOrderSchema.instance);
Pipe<ClientHTTPRequestSchema>[] httpClientRequestPipes = GraphManager.allPipesOfTypeWithNoConsumer(gm, ClientHTTPRequestSchema.instance);
Pipe<MessagePubSub>[] messagePubSub = GraphManager.allPipesOfTypeWithNoConsumer(gm, MessagePubSub.instance);
Pipe<IngressMessages>[] ingressMessagePipes = GraphManager.allPipesOfTypeWithNoConsumer(gm, IngressMessages.instance);
// TODO: no longer right now that we have no cops..
int commandChannelCount = orderPipes.length;
int eventSchemas = 0;
IDX_MSG = (IntHashTable.isEmpty(subscriptionPipeLookup2) && subscriptionPipes.length == 0 && messagePubSub.length == 0) ? -1 : eventSchemas++;
IDX_NET = useNetClient(httpClientRequestPipes) ? eventSchemas++ : -1;
// 20 seconds
long timeout = 20_000;
int maxGoPipeId = 0;
Pipe<TrafficReleaseSchema>[][] masterGoOut = new Pipe[eventSchemas][0];
Pipe<TrafficAckSchema>[][] masterAckIn = new Pipe[eventSchemas][0];
if (IDX_MSG >= 0) {
masterGoOut[IDX_MSG] = new Pipe[messagePubSub.length];
masterAckIn[IDX_MSG] = new Pipe[messagePubSub.length];
}
if (IDX_NET >= 0) {
masterGoOut[IDX_NET] = new Pipe[httpClientResponsePipes.length];
masterAckIn[IDX_NET] = new Pipe[httpClientResponsePipes.length];
}
int copGoAck = commandChannelCount;
// logger.info("command channel count to be checked {}",copGoAck);
while (--copGoAck >= 0) {
Pipe<TrafficReleaseSchema>[] goOut = new Pipe[eventSchemas];
Pipe<TrafficAckSchema>[] ackIn = new Pipe[eventSchemas];
// only setup the go and in pipes if the cop is used.
if (null != orderPipes[copGoAck]) {
int features = getFeatures(gm, orderPipes[copGoAck]);
boolean hasConnections = false;
if ((features & Behavior.DYNAMIC_MESSAGING) != 0) {
hasConnections = true;
maxGoPipeId = populateGoAckPipes(maxGoPipeId, masterGoOut, masterAckIn, goOut, ackIn, IDX_MSG);
}
if ((features & Behavior.NET_REQUESTER) != 0) {
hasConnections = true;
maxGoPipeId = populateGoAckPipes(maxGoPipeId, masterGoOut, masterAckIn, goOut, ackIn, IDX_NET);
}
TrafficCopStage.newInstance(gm, timeout, orderPipes[copGoAck], ackIn, goOut, runtime, this);
} else {
logger.info("oops get features skipped since no cops but needed for private topics");
}
// if (true | hasConnections) {
// TrafficCopStage trafficCopStage = new TrafficCopStage(gm,
// timeout, orderPipes[t],
// ackIn, goOut,
// runtime, this);
// } else {
// //this optimization can no longer be done due to the use of shutdown on command channel.
// // revisit this later...
// //TODO: we can reintroduce this as long has we have a stage here which does shutdown on -1;
// PipeCleanerStage.newInstance(gm, orderPipes[t]);
// }
}
initChannelBlocker(maxGoPipeId);
buildHTTPClientGraph(runtime, httpClientResponsePipes, httpClientRequestPipes, masterGoOut, masterAckIn);
// TODO: only create when subscriptionPipeLookup is not empty and subscriptionPipes has zero length.
if (IDX_MSG < 0) {
logger.trace("saved some resources by not starting up the unused pub sub service.");
} else {
if (!isAllPrivateTopics) {
// logger.info("builder created pub sub");
createMessagePubSubStage(runtime, subscriptionPipeLookup2, ingressMessagePipes, messagePubSub, masterGoOut[IDX_MSG], masterAckIn[IDX_MSG], subscriptionPipes);
}
}
}
Aggregations