/** * * @param graphManager * @param requestInputs _in_ All HTTP request logs. * @param responseInputs _in_ All HTTP response logs. * @param output _out_ All the request and response logs combined onto the output pipe as a RawDataSchema. */ public HTTPLogUnificationStage(GraphManager graphManager, Pipe<HTTPLogRequestSchema>[] requestInputs, Pipe<HTTPLogResponseSchema>[] responseInputs, Pipe<RawDataSchema> output) { super(graphManager, join(requestInputs, responseInputs), output); this.requestInputs = requestInputs; this.responseInputs = responseInputs; this.output = output; GraphManager.addNota(graphManager, GraphManager.DOT_BACKGROUND, "lemonchiffon3", this); }
hasWork = true; didWork = true; logRequestNow(requestInputs[i],output); hasWork = true; didWork = true; logResponseNow(responseInputs[j],output); checkForShutdown();
private void logRequestNow(Pipe<HTTPLogRequestSchema> p, Pipe<RawDataSchema> output) { int msgId = Pipe.takeMsgIdx(p); assert(msgId == HTTPLogRequestSchema.MSG_REQUEST_1); long timeNS = Pipe.takeLong(p); //time long chnl = Pipe.takeLong(p); //channelId int seq = Pipe.takeInt(p); //sequenceId DataInputBlobReader<HTTPLogRequestSchema> header = Pipe.openInputStream(p); //head //batch the writes.. int esitmate = 100+header.available(); batchMessages(output, esitmate); publishLogMessage(timeNS, chnl, seq, -1, BYTES_REQUEST, header, Pipe.outputStream(output)); Pipe.confirmLowLevelRead(p, Pipe.sizeOf(p, HTTPLogRequestSchema.MSG_REQUEST_1)); Pipe.releaseReadLock(p); }
private void checkForShutdown() { //don't check for shutdown on every pass it if (0==(0xFFF&iteration++)) { ///////we have no work and we are not blocked. //must check for shutdown case int i = requestInputs.length; while (--i>=0) { Pipe<HTTPLogRequestSchema> p = requestInputs[i]; if (!Pipe.peekMsg(p,-1)) { return;//this one was not shut down yet } } int j = responseInputs.length; while (--j>=0) { Pipe<HTTPLogResponseSchema> p = responseInputs[j]; if (!Pipe.peekMsg(p,-1)) { return;//this one was not shut down yet } } //all the pipes have now requested shutdown if (Pipe.hasRoomForWrite(output)) { Pipe.publishEOF(output); //tell downstream to shutdown requestShutdown(); //shutdown myself } else { return;//try again later } } }
new HTTPLogUnificationStage(graphManager, logReq, logRes, out);
private void logResponseNow(Pipe<HTTPLogResponseSchema> p, Pipe<RawDataSchema> output) { int msgId = Pipe.takeMsgIdx(p); assert(msgId == HTTPLogResponseSchema.MSG_RESPONSE_1); long timeNS = Pipe.takeLong(p); //time long chnl = Pipe.takeLong(p); //channelId int seq = Pipe.takeInt(p); //sequenceId DataInputBlobReader<HTTPLogResponseSchema> header = Pipe.openInputStream(p); //head long durationNS = Pipe.takeLong(p); //batch the writes.. int esitmate = 100+header.available(); batchMessages(output, esitmate); publishLogMessage(timeNS, chnl, seq, durationNS, BYTES_RESPONSE, header, Pipe.outputStream(output)); Pipe.confirmLowLevelRead(p, Pipe.sizeOf(p, HTTPLogResponseSchema.MSG_RESPONSE_1)); Pipe.releaseReadLock(p); }