public PipeConfig<T> grow2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(1+slabBits), (byte)(0==blobBits ? 0 : 1+blobBits), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> shrink2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits-1), (byte)(0==blobBits ? 0 : blobBits-1), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> debug(int debugFlags){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits), (byte)(blobBits), byteConst, schema); result.showLabels = this.showLabels; result.debugFlags = debugFlags; return result; }
public PipeConfig<T> grow2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(1+slabBits), (byte)(0==blobBits ? 0 : 1+blobBits), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> shrink2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits-1), (byte)(0==blobBits ? 0 : blobBits-1), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> blobGrow2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits), (byte)(1+blobBits), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> debug(int debugFlags){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits), (byte)(blobBits), byteConst, schema); result.showLabels = this.showLabels; result.debugFlags = debugFlags; return result; }
public PipeConfig<T> grow2x(){ PipeConfig<T> result = new PipeConfig<T>((byte)(1+slabBits), (byte)(0==blobBits ? 0 : 1+blobBits), byteConst, schema); result.showLabels = showLabels; return result; }
public PipeConfig<T> debug(int debugFlags){ PipeConfig<T> result = new PipeConfig<T>((byte)(slabBits), (byte)(blobBits), byteConst, schema); result.showLabels = this.showLabels; result.debugFlags = debugFlags; return result; }
public PipeConfig<T> newPipeConfig(int minimumFragmentsOnRing) { return new PipeConfig<T>((T)this, minimumFragmentsOnRing, 0); };
public PipeConfig<T> newPipeConfig(int minimumFragmentsOnRing) { return new PipeConfig<T>((T)this, minimumFragmentsOnRing, 0); };
public PipeConfig<T> newPipeConfig(int minimumFragmentsOnRing, int maximumLenghOfVariableLengthFields) { return new PipeConfig<T>((T)this, minimumFragmentsOnRing, maximumLenghOfVariableLengthFields); };
@Override public void definePrivateTopic(int queueLength, int maxMessageSize, String topic, String source, String ... targets) { PipeConfig<MessagePrivate> config = new PipeConfig<MessagePrivate>(MessagePrivate.instance, queueLength, maxMessageSize); defPrivateTopics(config, topic, source, targets); }
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 PrivateTopic(String topic, int messageCount, int messageSize, boolean hideLabels, BuilderImpl builder) { this.topic = topic; this.config = new PipeConfig<MessagePrivate>(MessagePrivate.instance, messageCount, messageSize); if (hideLabels) { this.config.hideLabels(); //private topics can clutter if they show all the details. } this.builder = builder; assert(null!=config); }
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. }
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 memoryUsage() { PipeConfig<NetPayloadSchema> netPayloadConfig = new PipeConfig<NetPayloadSchema>( NetPayloadSchema.instance, 10,1<<12); int blob = 1<<netPayloadConfig.blobBits; int slab = 1<<netPayloadConfig.slabBits; int expectedBlob = 10 * (1<<12); //System.err.println(slab+" "+blob+" expected blob "+expectedBlob); assertTrue (blob < expectedBlob*2);//real blob should be no more than 2x larger than expected } }
@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); }