/** * Writes a byte array to the specified pipe * @param source byte array to write * @param pipe pipe to write to * @param <S> MessageSchema to extend */ public static <S extends MessageSchema<S>> void addByteArray(byte[] source, Pipe<S> pipe) { addByteArray(source,0,source.length,pipe); }
/** * Writes a byte array to the specified pipe * @param source byte array to write * @param pipe pipe to write to * @param <S> MessageSchema to extend */ public static <S extends MessageSchema<S>> void addByteArray(byte[] source, Pipe<S> pipe) { addByteArray(source,0,source.length,pipe); }
/** * Writes a byte array to the specified pipe * @param source byte array to write * @param pipe pipe to write to * @param <S> MessageSchema to extend */ public static <S extends MessageSchema<S>> void addByteArray(byte[] source, Pipe<S> pipe) { addByteArray(source,0,source.length,pipe); }
private void publish(Path parent, String fileNameText, Pipe<FolderWatchSchema> target, int size) { if (null==parent) { Pipe.addByteArray(rootPathTextBytes, 0, rootPathTextBytes.length, target); } else { Pipe.addUTF8(parent.toAbsolutePath().toString(), target); } Pipe.addUTF8(fileNameText, target); Pipe.confirmLowLevelWrite(target, size); Pipe.publishWrites(target); }
int size = Pipe.addMsgIdx(outPipe, MessageSubscription.MSG_PUBLISH_103); Pipe.addByteArray(topicBacking, topicPos, topicLength, topicMask, outPipe); Pipe.addByteArray(payloadBacking, payloadPos, payloadLength, payloadMask, outPipe); } else { Pipe.addNullByteArray(outPipe);
public static void writeASCII(byte[] data, int offset, int length, Pipe output) { //before write make sure the tail is moved ahead so we have room to write long lastCheckedValue = Pipe.tailPosition(output); while (null==Pipe.slab(output) || lastCheckedValue < Pipe.workingHeadPosition(output)-(output.sizeOfSlabRing-Pipe.from(output).fragDataSize[MetaMessageDefs.MSG_ASCII_LOC])) { Pipe.spinWork(output); lastCheckedValue = Pipe.tailPosition(output); } Pipe.addMsgIdx(output,MetaMessageDefs.MSG_ASCII_LOC); Pipe.addByteArray(data, offset, length, output); }
public static <S extends MessageSchema<S>> void writeLV(Pipe<S> pipe, int msgIdx, long field1, byte[] field2Backing, int field2Position, int field2Length) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addByteArray(field2Backing, field2Position, field2Length, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> void writeLV(Pipe<S> pipe, int msgIdx, long field1, byte[] field2Backing, int field2Position, int field2Length) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addByteArray(field2Backing, field2Position, field2Length, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static void writeBytes(byte[] data, int offset, int length, Pipe output) { //before write make sure the tail is moved ahead so we have room to write long lastCheckedValue = Pipe.tailPosition(output); while (null==Pipe.slab(output) || lastCheckedValue < Pipe.workingHeadPosition(output)-(output.sizeOfSlabRing-Pipe.from(output).fragDataSize[MetaMessageDefs.MSG_BYTEARRAY_LOC])) { Pipe.spinWork(output); lastCheckedValue = Pipe.tailPosition(output); } Pipe.addMsgIdx(output, MetaMessageDefs.MSG_BYTEARRAY_LOC); Pipe.addByteArray(data, offset, length, output); }
public static <S extends MessageSchema<S>> void writeLV(Pipe<S> pipe, int msgIdx, long field1, byte[] field2Backing, int field2Position, int field2Length) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addByteArray(field2Backing, field2Position, field2Length, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
Pipe.addByteArray(data, position, fragmentLength, output); Pipe.confirmLowLevelWrite(output, RawDataSchema.FROM.fragDataSize[0]); Pipe.publishWrites(output);
Pipe.addByteArray(data, position, fragmentLength, output); Pipe.confirmLowLevelWrite(output, RawDataSchema.FROM.fragDataSize[0]); Pipe.publishWrites(output);
Pipe.addByteArray(data, position, fragmentLength, output); Pipe.confirmLowLevelWrite(output, RawDataSchema.FROM.fragDataSize[0]); Pipe.publishWrites(output);
private static void logTraffic(HTTP1xRouterStage that, Pipe<NetPayloadSchema> selectedInput, final long channel, long arrivalTime, int seqForLogging, int posForLogging, int totalConsumed) { //this logs every input at this point Pipe<HTTPLogRequestSchema> logOut = that.log; Pipe.presumeRoomForWrite(logOut);//checked above int size = Pipe.addMsgIdx(logOut, HTTPLogRequestSchema.MSG_REQUEST_1); Pipe.addLongValue(arrivalTime, logOut); Pipe.addLongValue(channel, logOut); Pipe.addIntValue(seqForLogging, logOut); Pipe.addByteArray(Pipe.blob(selectedInput), posForLogging, totalConsumed, that.trieReader.sourceMask, logOut); Pipe.confirmLowLevelWrite(logOut, size); Pipe.publishWrites(logOut); }
private boolean sendSingleMessage(Pipe<NetPayloadSchema> pipe, long connectionId, int testSeed, int testSize) { Random r = new Random(testSeed); //System.out.println("sending "+connectionId+" "+testSize); if (Pipe.hasRoomForWrite(pipe)) { int size = Pipe.addMsgIdx(pipe, NetPayloadSchema.MSG_PLAIN_210); Pipe.addLongValue(connectionId, pipe); Pipe.addLongValue(System.currentTimeMillis(), pipe); Pipe.addLongValue(0, pipe); byte[] payload = new byte[testSize]; r.nextBytes(payload); Pipe.addByteArray(payload, 0, testSize, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); return true; } else { return false; } }
private void writeTestRecord(int length, int offset) { final int size = Pipe.addMsgIdx(output, NetPayloadSchema.MSG_PLAIN_210); Pipe.addLongValue(0, output); //channel Pipe.addLongValue(System.currentTimeMillis(), output); Pipe.addLongValue(Pipe.getWorkingTailPosition(output), output); Pipe.addByteArray(rawData, offset, length, output); Pipe.confirmLowLevelWrite(output, size); Pipe.publishWrites(output); }
Pipe.addByteArray(rawData, pos, length, output); Pipe.confirmLowLevelWrite(output, size); Pipe.publishWrites(output);
@Override public void run() { while (Pipe.hasRoomForWrite((Pipe<?>) outputRing, msgSize)) { if (--messageCount>=0) { Pipe.confirmLowLevelWrite(outputRing, msgSize); //write the record Pipe.addMsgIdx(outputRing, 0); addByteArray(testArray, 0, testArray.length, outputRing); publishWrites(outputRing); } else { requestShutdown(); return; } } } }
public static void writeByteArrayMessage(Pipe ring, boolean isNullable, String columnName, Object value) { writeNullableMessage(ring, (columnName == null) ? MetaMessageDefs.MSG_NULLABLEBYTEARRAY_LOC : MetaMessageDefs.MSG_NAMEDNULLABLEBYTEARRAY_LOC, isNullable, columnName, value); if (value != null) { int msg = (columnName == null) ? MetaMessageDefs.MSG_BYTEARRAY_LOC : MetaMessageDefs.MSG_NAMEDBYTEARRAY_LOC; //before write make sure the tail is moved ahead so we have room to write while (!Pipe.hasRoomForWrite(ring, Pipe.from(ring).fragDataSize[msg])) { Pipe.spinWork(ring); } Pipe.addMsgIdx(ring, msg); if (columnName != null) { Pipe.validateVarLength(ring, columnName.length()); int sourceLen = columnName.length(); final int p = Pipe.copyASCIIToBytes(columnName, 0, sourceLen, ring); Pipe.addBytePosAndLen(ring, p, sourceLen); } byte[] source = (byte[]) value; Pipe.addByteArray(source, 0, source.length, ring); Pipe.publishWrites(ring); } }
Pipe.addByteArray("ABCDEFGHIJKLMNOP1234567890".getBytes(), testDataPipe); Pipe.confirmLowLevelWrite(testDataPipe); Pipe.publishWrites(testDataPipe);