/** * Allocates all internal arrays and buffers before the Pipe can be used * @return Pipe initialized */ public Pipe<T> initBuffers() { assert(!isInit(this)) : "RingBuffer was already initialized"; if (!isInit(this)) { buildBuffers(); } else { log.warn("Init was already called once already on this ring buffer"); } return this; }
/** * Set the regulator value for the consumer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setConsumerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorConsumer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorConsumer = new PipeRegulator(msgPerMs, msgSize); }
public static void initInputPipesAsNeeded(GraphManager m, int stageId) { int pipeIdIn; int idx = m.stageIdToInputsBeginIdx[stageId]; while (-1 != (pipeIdIn=m.multInputIds[idx++])) { if (!Pipe.isInit(m.pipeIdToPipe[pipeIdIn])) { m.pipeIdToPipe[pipeIdIn].initBuffers(); } } }
/** * Set the regulator value for the producer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setProducerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorProducer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorProducer = new PipeRegulator(msgPerMs, msgSize); }
@Override public void shutdown() { int i = outgoingPipes.length; while (--i>=0) { if (null!=outgoingPipes[i] && Pipe.isInit(outgoingPipes[i])) { Pipe.publishEOF(outgoingPipes[i]); } } }
/** * Set the regulator value for the consumer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setConsumerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorConsumer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorConsumer = new PipeRegulator(msgPerMs, msgSize); }
/** * Set the regulator value for the producer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setProducerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorProducer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorProducer = new PipeRegulator(msgPerMs, msgSize); }
/** * This sends a poison pill. Any pipe that receives this pill shuts down and sends the pill to any pipes downstream of them * @param pipe to send pill */ public static void publishEOF(Pipe[] pipe) { int i = pipe.length; while (--i>=0) { if (null!=pipe[i] && Pipe.isInit(pipe[i])) { publishEOF(pipe[i]); } } }
/** * Set the regulator value for the consumer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setConsumerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorConsumer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorConsumer = new PipeRegulator(msgPerMs, msgSize); }
/** * This sends a poison pill. Any pipe that receives this pill shuts down and sends the pill to any pipes downstream of them * @param pipe to send pill */ public static void publishEOF(Pipe[] pipe) { int i = pipe.length; while (--i>=0) { if (null!=pipe[i] && Pipe.isInit(pipe[i])) { publishEOF(pipe[i]); } } }
/** * Set the regulator value for the producer of the pipe. * @param pipe to be regulated * @param msgPerMs messages per ms * @param msgSize size of messages regulated */ public static <S extends MessageSchema<S>> void setProducerRegulation(Pipe<S> pipe, int msgPerMs, int msgSize) { assert(null==pipe.regulatorProducer) : "regulator must only be set once"; assert(!isInit(pipe)) : "regular may only be set before scheduler has initialized the pipe"; pipe.regulatorProducer = new PipeRegulator(msgPerMs, msgSize); }
public DataOutputBlobWriter(Pipe<S> p) { this.backingPipe = p; assert(null!=p) : "requires non null pipe"; assert(Pipe.isInit(p)): "The pipe must be init before use."; this.byteBuffer = Pipe.blob(p); this.byteMask = Pipe.blobMask(p); assert(this.byteMask!=0): "mask is "+p.blobMask+" size of blob is "+p.sizeOfBlobRing; this.structuredWriter = new StructuredWriter(this); }
public DataOutputBlobWriter(Pipe<S> p) { this.backingPipe = p; assert(null!=p) : "requires non null pipe"; assert(Pipe.isInit(p)): "The pipe must be init before use."; this.byteBuffer = Pipe.blob(p); this.byteMask = Pipe.blobMask(p); assert(this.byteMask!=0): "mask is "+p.blobMask+" size of blob is "+p.sizeOfBlobRing; this.structuredWriter = new StructuredWriter(this); }
public DataOutputBlobWriter(Pipe<S> p) { this.backingPipe = p; assert(null!=p) : "requires non null pipe"; assert(Pipe.isInit(p)): "The pipe must be init before use."; this.byteBuffer = Pipe.blob(p); this.byteMask = Pipe.blobMask(p); assert(this.byteMask!=0): "mask is "+p.blobMask+" size of blob is "+p.sizeOfBlobRing; this.structuredWriter = new StructuredWriter(this); }
public boolean goHasRoomFor(int messageCount) { assert(null==goPipe || Pipe.isInit(goPipe)) : "not init yet"; return (null==goPipe || Pipe.hasRoomForWrite(goPipe, FieldReferenceOffsetManager.maxFragmentSize(Pipe.from(goPipe))*messageCount)); }
/** * Check to see if specified pipe has room to write * @param pipe to be checked * @return <code>true</code> if pipe has room else <code>false</code> */ public static boolean hasRoomForWrite(Pipe pipe) { assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(pipe!=null); assert(Pipe.isInit(pipe)); assert(pipe.usingHighLevelAPI); return StackStateWalker.hasRoomForFragmentOfSizeX(pipe, pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - FieldReferenceOffsetManager.maxFragmentSize( Pipe.from(pipe)))); }
/** * Check to see if specified pipe has room to write * @param pipe to be checked * @return <code>true</code> if pipe has room else <code>false</code> */ public static boolean hasRoomForWrite(Pipe pipe) { assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(pipe!=null); assert(Pipe.isInit(pipe)); assert(pipe.usingHighLevelAPI); return StackStateWalker.hasRoomForFragmentOfSizeX(pipe, pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - FieldReferenceOffsetManager.maxFragmentSize( Pipe.from(pipe)))); }
/** * Return true if there is room for the desired fragment in the output buffer. * Places working head in place for the first field to be written (eg after the template Id, which is written by this method) * */ public static boolean tryWriteFragment(Pipe pipe, final int fragmentId) { assert(null!=pipe); assert(fragmentId<Pipe.from(pipe).fragDataSize.length) : "Is this pipe for the schema holding this message?"; assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(Pipe.isInit(pipe)) : "Pipe must be initialized before use: "+pipe+" call the method initBuffers"; return StackStateWalker.tryWriteFragment0(pipe, fragmentId, Pipe.from(pipe).fragDataSize[fragmentId], pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - Pipe.from(pipe).fragDataSize[fragmentId])); }
/** * Return true if there is room for the desired fragment in the output buffer. * Places working head in place for the first field to be written (eg after the template Id, which is written by this method) * */ public static boolean tryWriteFragment(Pipe pipe, final int fragmentId) { assert(null!=pipe); assert(fragmentId<Pipe.from(pipe).fragDataSize.length) : "Is this pipe for the schema holding this message?"; assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(Pipe.isInit(pipe)) : "Pipe must be initialized before use: "+pipe+" call the method initBuffers"; return StackStateWalker.tryWriteFragment0(pipe, fragmentId, Pipe.from(pipe).fragDataSize[fragmentId], pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - Pipe.from(pipe).fragDataSize[fragmentId])); }
/** * Return true if there is room for the desired fragment in the output buffer. * Places working head in place for the first field to be written (eg after the template Id, which is written by this method) * */ public static boolean tryWriteFragment(Pipe pipe, final int fragmentId) { assert(fragmentId<Pipe.from(pipe).fragDataSize.length) : "Is this pipe for the schema holding this message?"; assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(null!=pipe); assert(Pipe.isInit(pipe)) : "Pipe must be initialized before use: "+pipe+" call the method initBuffers"; return StackStateWalker.tryWriteFragment0(pipe, fragmentId, Pipe.from(pipe).fragDataSize[fragmentId], pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - Pipe.from(pipe).fragDataSize[fragmentId])); }