private static Pipe<MQTTClientRequestSchema> newClientRequestPipe(PipeConfig<MQTTClientRequestSchema> config) { return new Pipe<MQTTClientRequestSchema>(config) { @SuppressWarnings("unchecked") @Override protected DataOutputBlobWriter<MQTTClientRequestSchema> createNewBlobWriter() { return new MQTTWriter(this); } }; }
private static <B extends BuilderImpl> Pipe<ClientHTTPRequestSchema> newNetRequestPipe(PipeConfig<ClientHTTPRequestSchema> config, B builder) { return new Pipe<ClientHTTPRequestSchema>(config) { @Override protected DataOutputBlobWriter<ClientHTTPRequestSchema> createNewBlobWriter() { return new PayloadWriter<ClientHTTPRequestSchema>(this); } }; }
/** * Build an array of Pipe instances from a set of PipeConfig. * @param configs array of PipeConfig values * @return array of new pipes */ public static Pipe[] buildPipes(PipeConfig[] configs) { int i = configs.length; Pipe[] result = new Pipe[i]; while (--i>=0) { result[i] = new Pipe(configs[i]); } return result; }
/** * Build an array of Pipe instances from a set of PipeConfig. * @param configs array of PipeConfig values * @return array of new pipes */ public static Pipe[] buildPipes(PipeConfig[] configs) { int i = configs.length; Pipe[] result = new Pipe[i]; while (--i>=0) { result[i] = new Pipe(configs[i]); } return result; }
/** * Build and array of Pipe instances from a single PipeConfig * @param count of new Pipe instances created * @param commonConfig PipeConfig used for all the new pipes * @return array of new pipes */ public static <S extends MessageSchema<S>> Pipe<S>[] buildPipes(int count, PipeConfig<S> commonConfig) { Pipe[] result = new Pipe[count]; int i = count; while (--i>=0) { result[i] = new Pipe<S>(commonConfig); } return (Pipe<S>[])result; }
public static <S extends MessageSchema<S>> Pipe<S> pipe(PipeConfig<S> config) { return new Pipe<S>(config); }
/** * Build an array of Pipe instances from a set of PipeConfig found in array of pipes. * @param Pipe array of pipes * @param <S> schema * @return array of new pipes */ public static <S extends MessageSchema<S>> Pipe<S>[] buildPipes(Pipe<S>[] pipes) { int i = pipes.length; Pipe[] result = new Pipe[i]; while (--i>=0) { result[i] = new Pipe(pipes[i].config); } return result; }
/** * Build an array of Pipe instances from a set of PipeConfig. * @param configs array of PipeConfig values * @return array of new pipes */ public static Pipe[] buildPipes(PipeConfig[] configs) { int i = configs.length; Pipe[] result = new Pipe[i]; while (--i>=0) { result[i] = new Pipe(configs[i]); } return result; }
public static <S extends MessageSchema<S>> Pipe<S> pipe(PipeConfig<S> config) { return new Pipe<S>(config); }
private Pipe<TrafficOrderSchema> newGoPipe(PipeConfig<TrafficOrderSchema> goPipeConfig) { return new Pipe<TrafficOrderSchema>(goPipeConfig); }
private final Pipe<MessagePubSub> getTempPipeOfStartupSubscriptions() { if (null==tempPipeOfStartupSubscriptions) { final PipeConfig<MessagePubSub> messagePubSubConfig = new PipeConfig<MessagePubSub>(MessagePubSub.instance, maxStartupSubs, maxTopicLengh); tempPipeOfStartupSubscriptions = new Pipe<MessagePubSub>(messagePubSubConfig); } return tempPipeOfStartupSubscriptions; }
public <S extends MessageSchema<S>> Pipe<S> newPipe(Class<S> clazz) { return new Pipe<S>(getConfig(clazz)); }
public <S extends MessageSchema<S>> Pipe<S> newPipe(Class<S> clazz) { return new Pipe<S>(getConfig(clazz)); }
public Pipe<T> newPipe(int minimumFragmentsOnRing, int maximumLenghOfVariableLengthFields) { return new Pipe<T>((PipeConfig<T>) newPipeConfig(minimumFragmentsOnRing, maximumLenghOfVariableLengthFields)); }
public Pipe<T> newPipe(int minimumFragmentsOnRing, int maximumLenghOfVariableLengthFields) { return new Pipe<T>((PipeConfig<T>) newPipeConfig(minimumFragmentsOnRing, maximumLenghOfVariableLengthFields)); }
protected int populateGoAckPipes(int maxGoPipeId, Pipe<TrafficReleaseSchema>[][] masterGoOut, Pipe<TrafficAckSchema>[][] masterAckIn, Pipe<TrafficReleaseSchema>[] goOut, Pipe<TrafficAckSchema>[] ackIn, int p) { if (p>=0) { addToLastNonNull(masterGoOut[p], goOut[p] = new Pipe<TrafficReleaseSchema>(this.pcm.getConfig(TrafficReleaseSchema.class))); maxGoPipeId = Math.max(maxGoPipeId, goOut[p].id); addToLastNonNull(masterAckIn[p], ackIn[p] = new Pipe<TrafficAckSchema>(this.pcm.getConfig(TrafficAckSchema.class))); } return maxGoPipeId; }
public static <T extends MessageSchema<T>> Pipe<T> attach(boolean debug, GraphManager gm, Pipe<T> source, Appendable console) { if (debug) { Pipe<T> out1 = new Pipe<T>(source.config().grow2x()); Pipe<T> out2 = new Pipe<T>(source.config().grow2x()); ReplicatorStage.newInstance(gm, source, out1, out2); ConsoleJSONDumpStage.newInstance(gm, out1, console); return out2; } else { return source; } }
public StreamRegulator(long bitPerSecond, int maxWrittenChunksInFlight, int maxWrittenChunkSizeInBytes) { PipeConfig<RawDataSchema> pipeConfig = new PipeConfig<RawDataSchema>(RawDataSchema.instance, maxWrittenChunksInFlight, maxWrittenChunkSizeInBytes); this.pipe = new Pipe<RawDataSchema>(pipeConfig); this.pipe.initBuffers(); Pipe.setPublishBatchSize(pipe, 0); Pipe.setReleaseBatchSize(pipe, maxWrittenChunksInFlight/3); if (this.pipe.blobMask<=0) { throw new UnsupportedOperationException("Pipe must have room to send blob data. Found size:"+ this.pipe.sizeOfBlobRing+" config: "+pipeConfig); } this.inputStreamFlyweight = new DataInputBlobReader<RawDataSchema>(pipe); this.outputStreamFlyweight = new DataOutputBlobWriter<RawDataSchema>(pipe); this.bitPerSecond = bitPerSecond; //TODO: may want to add latency per chunk, per startup, or per N bytes. }
@Test public void copyIntTest() throws IOException{ //create blob for test Pipe<RawDataSchema> encodedValuesToValidate = new Pipe<RawDataSchema>(new PipeConfig<RawDataSchema>(RawDataSchema.instance, 100, 4000)); encodedValuesToValidate.initBuffers(); DataOutputBlobWriter<RawDataSchema> writer = new DataOutputBlobWriter<RawDataSchema>(encodedValuesToValidate); //create int dictionary int[] intDictionary = new int[5]; Arrays.fill(intDictionary, 0); intDictionary[2] = 5; //make it increment 2 values 0 and 5 PhastEncoder.copyInt(intDictionary, writer, 0, 0, 2, 0, false); writer.close(); }
@Test public void decodeStringTest() throws IOException{ Pipe<RawDataSchema> pipe = new Pipe<RawDataSchema>(new PipeConfig<RawDataSchema>(RawDataSchema.instance, 100, 4000)); pipe.initBuffers(); DataOutputBlobWriter<RawDataSchema> writer = new DataOutputBlobWriter<RawDataSchema>(pipe); DataOutputBlobWriter.writePackedInt(writer, -63); writer.writeUTF("This is a test"); writer.close(); DataInputBlobReader<RawDataSchema> reader = new DataInputBlobReader<RawDataSchema>(pipe); String stest = PhastDecoder.decodeString(reader, false); reader.close(); assertTrue(stest.compareTo("This is a test") == 0); }