public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
public int closeHighLevelField(int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(); PipeWriter.writeSpecialBytesPosAndLen(p, targetFieldLoc, len, startPosition); p.closeBlobFieldWrite(); return len; }
public int closeHighLevelField(int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(); PipeWriter.writeSpecialBytesPosAndLen(p, targetFieldLoc, len, startPosition); p.closeBlobFieldWrite(); return len; }
public int closeHighLevelField(int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(); PipeWriter.writeSpecialBytesPosAndLen(p, targetFieldLoc, len, startPosition); p.closeBlobFieldWrite(); return len; }
public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
@Override public void stringEnd() { if (activeFieldLoc>0) { if (!mapper.isNumeric(activeFieldLoc)) { DataOutputBlobWriter<M> out = PipeWriter.outputStream(pipe); //this data looks correct. //byte[] byteArray = out.toByteArray(); //System.err.println(activeFieldLoc+" CAPTURED TEXT:"+new String(byteArray)); int len = DataOutputBlobWriter.closeHighLevelField(out, activeFieldLoc); } else { pipe.closeBlobFieldWrite(); // System.err.println("UNABLE TO PARSE NUMERIC:"+new String(out.toByteArray())); } activeFieldLoc = 0; } }
@Override public void stringEnd() { if (activeFieldLoc>0) { if (!mapper.isNumeric(activeFieldLoc)) { DataOutputBlobWriter<M> out = PipeWriter.outputStream(pipe); //this data looks correct. //byte[] byteArray = out.toByteArray(); //System.err.println(activeFieldLoc+" CAPTURED TEXT:"+new String(byteArray)); int len = DataOutputBlobWriter.closeHighLevelField(out, activeFieldLoc); } else { pipe.closeBlobFieldWrite(); // System.err.println("UNABLE TO PARSE NUMERIC:"+new String(out.toByteArray())); } activeFieldLoc = 0; } }
@Override public void stringEnd() { if (activeFieldLoc>0) { if (!mapper.isNumeric(activeFieldLoc)) { DataOutputBlobWriter<M> out = PipeWriter.outputStream(pipe); //this data looks correct. //byte[] byteArray = out.toByteArray(); //System.err.println(activeFieldLoc+" CAPTURED TEXT:"+new String(byteArray)); int len = DataOutputBlobWriter.closeHighLevelField(out, activeFieldLoc); } else { pipe.closeBlobFieldWrite(); // System.err.println("UNABLE TO PARSE NUMERIC:"+new String(out.toByteArray())); } activeFieldLoc = 0; } }
public static void closePayloadAndPublish( HTTPUtilResponse that, byte[] eTag, HTTPContentType contentTypeEnum, Pipe<ServerResponseSchema> output, long activeChannelId, int activeSequenceNo, int activeFieldRequestContext, ChannelWriter outputStream, HeaderWritable additionalHeaderWriter, int status) { storeChnlAndSeqInHeaderFragment(that, output, activeChannelId, activeSequenceNo); byte[] contentType = null!=contentTypeEnum ? contentTypeEnum.getBytes() : null; int totalLengthWritten = outputStream.length(); //this is a key pronghorn pattern in use here output.closeBlobFieldWrite(); //closed because we will add each part below... HTTPUtil.prependBodyWithHeader(output, eTag, totalLengthWritten, that, activeFieldRequestContext, activeChannelId, activeSequenceNo, contentType, additionalHeaderWriter, status);//context }
public static void finalizeLengthOfFirstBlock(HTTPUtilResponse that, DataOutputBlobWriter<?> outputStream) { int propperLength = DataOutputBlobWriter.length(outputStream); Pipe.validateVarLength(outputStream.getPipe(), propperLength); Pipe.setIntValue(propperLength, outputStream.getPipe(), that.block1PositionOfLen); //go back and set the right length. outputStream.getPipe().closeBlobFieldWrite(); }
public static <T extends MessageSchema<T>> int closeLowLeveLField(DataOutputBlobWriter<T> writer, int len) { assert(len<=writer.backingPipe.sizeOfBlobRing): "bad length "+len+" larger than pipe"; if (writer.structuredWithIndexData) { //write this field as length len but move head to the end of maxvarlen writer.activePosition = writer.lastPosition; Pipe.setBlobWorkingHead(writer.backingPipe, writer.activePosition & Pipe.BYTES_WRAP_MASK); } else { //do not keep index just move forward by length size Pipe.addAndGetBlobWorkingHeadPosition(writer.backingPipe, len); } assert(writer.startPosition>=0) : "Error bad position of "+writer.startPosition+" length was "+len; Pipe.addBytePosAndLenSpecial(writer.backingPipe, writer.startPosition, len); Pipe.validateVarLength(writer.backingPipe, len); writer.backingPipe.closeBlobFieldWrite(); if (writer.structuredWithIndexData) { //set the flag marking this as structed. Pipe.slab(writer.backingPipe)[writer.backingPipe.slabMask & (int)(Pipe.workingHeadPosition(writer.backingPipe)-2)] |= Pipe.STRUCTURED_POS_MASK; } return len; }
public static <T extends MessageSchema<T>> int closeLowLeveLField(DataOutputBlobWriter<T> writer, int len) { if (writer.structuredWithIndexData) { //write this field as length len but move head to the end of maxvarlen writer.activePosition = writer.lastPosition; Pipe.setBlobWorkingHead(writer.backingPipe, writer.activePosition & Pipe.BYTES_WRAP_MASK); } else { //do not keep index just move forward by length size Pipe.addAndGetBlobWorkingHeadPosition(writer.backingPipe, len); } assert(writer.startPosition>=0) : "Error bad position of "+writer.startPosition+" length was "+len; Pipe.addBytePosAndLenSpecial(writer.backingPipe, writer.startPosition, len); Pipe.validateVarLength(writer.backingPipe, len); writer.backingPipe.closeBlobFieldWrite(); if (writer.structuredWithIndexData) { //set the flag marking this as structed. Pipe.slab(writer.backingPipe)[writer.backingPipe.slabMask & (int)(Pipe.workingHeadPosition(writer.backingPipe)-2)] |= Pipe.STRUCTURED_POS_MASK; } return len; }
public static <T extends MessageSchema<T>> int closeLowLeveLField(DataOutputBlobWriter<T> writer, int len) { assert(len<=writer.backingPipe.sizeOfBlobRing): "bad length "+len+" larger than pipe"; if (writer.structuredWithIndexData) { //write this field as length len but move head to the end of maxvarlen writer.activePosition = writer.lastPosition; Pipe.setBlobWorkingHead(writer.backingPipe, writer.activePosition & Pipe.BYTES_WRAP_MASK); } else { //do not keep index just move forward by length size Pipe.addAndGetBlobWorkingHeadPosition(writer.backingPipe, len); } assert(writer.startPosition>=0) : "Error bad position of "+writer.startPosition+" length was "+len; Pipe.addBytePosAndLenSpecial(writer.backingPipe, writer.startPosition, len); Pipe.validateVarLength(writer.backingPipe, len); writer.backingPipe.closeBlobFieldWrite(); if (writer.structuredWithIndexData) { //set the flag marking this as structed. Pipe.slab(writer.backingPipe)[writer.backingPipe.slabMask & (int)(Pipe.workingHeadPosition(writer.backingPipe)-2)] |= Pipe.STRUCTURED_POS_MASK; } return len; }
private void writeChunkPrefix(NetResponseWriter outputStream, int headerBlobPosition, long positionOfLen, int len) { //logger.trace("writing chunk at position {} ", headerBlobPosition); DataOutputBlobWriter.openFieldAtPosition(outputStream, headerBlobPosition); //since block has return on the end we must subtract 2 from what we wrote final int adj = 2+(5*(1&(context>>ServerCoordinator.END_RESPONSE_SHIFT))); Appendables.appendHexDigitsRaw(outputStream, len-adj); outputStream.write(RETURN_NEWLINE); int propperLength = DataOutputBlobWriter.length(outputStream); Pipe.validateVarLength(outputStream.getPipe(), propperLength); Pipe.setIntValue(propperLength, outputStream.getPipe(), positionOfLen); //go back and set the right length. outputStream.getPipe().closeBlobFieldWrite(); }
FailableWrite publishFailableOnPrivateTopic(int token, FailableWritable writable) { //this is a private topic Pipe<MessagePrivate> output = publishPrivateTopics.getPipe(token); if (Pipe.hasRoomForWrite(output)) { DataOutputBlobWriter<MessagePrivate> writer = Pipe.openOutputStream(output); FailableWrite result = writable.write(writer); if (result == FailableWrite.Cancel) { output.closeBlobFieldWrite(); } else { int size = Pipe.addMsgIdx(output, MessagePrivate.MSG_PUBLISH_1); DataOutputBlobWriter.closeLowLevelField(writer); Pipe.confirmLowLevelWrite(output, size); Pipe.publishWrites(output); } return result; } else { return FailableWrite.Retry; } }
private static void writeHeader(NetResponseWriter outputStream, final int headerBlobPosition, final long positionOfLen, int statusCode, final int context, HTTPContentType contentType, int length, boolean chunked) { //logger.info("writing head at position {} ", headerBlobPosition); DataOutputBlobWriter.openFieldAtPosition(outputStream, headerBlobPosition); byte[] revisionBytes = HTTPRevisionDefaults.HTTP_1_1.getBytes(); byte[] etagBytes = null;//TODO: nice feature to add later int connectionIsClosed = 1&(context>>ServerCoordinator.CLOSE_CONNECTION_SHIFT); byte[] typeBytes = null!=contentType?contentType.getBytes():null; HTTPUtil.writeHeader(revisionBytes, statusCode, 0, etagBytes, typeBytes, length, chunked, true, outputStream, connectionIsClosed, w -> w.write(HTTPHeaderDefaults.DATE, outputStream.headerDate) ); int propperLength = DataOutputBlobWriter.length(outputStream); Pipe.validateVarLength(outputStream.getPipe(), propperLength); Pipe.setIntValue(propperLength, outputStream.getPipe(), positionOfLen); //go back and set the right length. outputStream.getPipe().closeBlobFieldWrite(); }