本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeWriter.publishEOF方法的典型用法代码示例。如果您正苦于以下问题:Java PipeWriter.publishEOF方法的具体用法?Java PipeWriter.publishEOF怎么用?Java PipeWriter.publishEOF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ociweb.pronghorn.pipe.PipeWriter
的用法示例。
在下文中一共展示了PipeWriter.publishEOF方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
int msgIdx = PipeReader.getMsgIdx(input);
//System.out.format("\nMessage Idx %d %d %d\n", msgIdx, Pipe.tailPosition(input), input.sizeOfSlabRing);
if (msgIdx >= 0) {
MessageProcessor msg = messages[msgIdx];
if (msg != null) {
msg.readAndWrite(input, output);
}
//else {
//System.out.format("Not Found %d", msgIdx);
//}
PipeReader.releaseReadLock(input);
}
else {
PipeReader.releaseReadLock(input);
PipeWriter.publishEOF(output);
requestShutdown();
//System.out.format("End of the line");
return;
}
}
}
示例2: run
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
if (0 == shutdownCountdown) {
int j = output.length;
while (--j>=0) {
if (!PipeWriter.hasRoomForWrite(output[j])) {
return;
}
}
PipeWriter.publishEOF(output);
requestShutdown();
return;
}
int i = input.length;
while (--i >= 0) {
if (PipeWriter.hasRoomForWrite(output[i])) {
processRequest(input[i], output[i]);
}
}
}
示例3: run
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
while (messageCount>0) {
if (PipeWriter.tryWriteFragment(outputRing, MESSAGE_LOC)) {
PipeWriter.writeBytes(outputRing, FIELD_LOC, testArray, 0, testArray.length, Integer.MAX_VALUE);
PipeWriter.publishWrites(outputRing);
messageCount--;
} else {
return;
}
}
PipeWriter.publishEOF(outputRing);
requestShutdown();
return;//do not come back
}
示例4: writeWithAckImpl
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void writeWithAckImpl(boolean encryption, boolean telemetry) {
Pipe<PersistedBlobStoreSchema> perStore = PersistedBlobStoreSchema.instance.newPipe(10, 1000);
perStore.initBuffers();
long fieldBlockId = 10;
byte[] fieldByteArrayBacking = "hello".getBytes();
int fieldByteArrayPosition = 0;
int fieldByteArrayLength = fieldByteArrayBacking.length;
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_BLOCK_1);
PipeWriter.writeLong(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BLOCKID_3, fieldBlockId);
PipeWriter.writeBytes(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BYTEARRAY_2, fieldByteArrayBacking, fieldByteArrayPosition, fieldByteArrayLength);
PipeWriter.publishWrites(perStore);
PipeWriter.publishEOF(perStore);
String result = runGraph(perStore, encryption, telemetry);
assertTrue(result, result.indexOf("AckWrite")>0);
assertTrue(result, result.indexOf("{\"BlockId\":10}")>0);
}
示例5: writeAndReadImpl
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void writeAndReadImpl(boolean encryption, boolean telemetry) {
Pipe<PersistedBlobStoreSchema> perStore = PersistedBlobStoreSchema.instance.newPipe(10, 1000);
perStore.initBuffers();
byte[] fieldByteArrayBacking = "hello".getBytes();
int fieldByteArrayLength = fieldByteArrayBacking.length;
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_BLOCK_1);
PipeWriter.writeLong(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BLOCKID_3, (long) 10);
PipeWriter.writeBytes(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BYTEARRAY_2, fieldByteArrayBacking, 0, fieldByteArrayLength);
PipeWriter.publishWrites(perStore);
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_REQUESTREPLAY_6);
PipeWriter.publishWrites(perStore);
PipeWriter.publishEOF(perStore); //ensure that the parts do not shut down before we are done
String result = runGraph(perStore, encryption, telemetry);
assertTrue(result, result.indexOf("AckWrite")>0);
assertTrue(result, result.indexOf("{\"BlockId\":10}")>0);
assertTrue(result, result.indexOf("0x68,0x65,0x6c,0x6c,0x6f")>0);
assertTrue(result, result.indexOf("FinishReplay")>0);
}
示例6: sentEOF
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
protected boolean sentEOF(Pipe<?> pipe) {
if (null!=pipe) {
PipeWriter.publishEOF(pipe);
return true;
} else {
return false;
}
}
示例7: writeReleaseAndReadImpl
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void writeReleaseAndReadImpl(boolean encryption, boolean telemetry) {
Pipe<PersistedBlobStoreSchema> perStore = PersistedBlobStoreSchema.instance.newPipe(10, 1000);
perStore.initBuffers();
byte[] fieldByteArrayBacking = "hello".getBytes();
int fieldByteArrayLength = fieldByteArrayBacking.length;
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_BLOCK_1);
PipeWriter.writeLong(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BLOCKID_3, (long) 10);
PipeWriter.writeBytes(perStore,PersistedBlobStoreSchema.MSG_BLOCK_1_FIELD_BYTEARRAY_2, fieldByteArrayBacking, 0, fieldByteArrayLength);
PipeWriter.publishWrites(perStore);
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_RELEASE_7);
PipeWriter.writeLong(perStore,PersistedBlobStoreSchema.MSG_RELEASE_7_FIELD_BLOCKID_3, (long) 10);
PipeWriter.publishWrites(perStore);
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_REQUESTREPLAY_6);
PipeWriter.publishWrites(perStore);
PipeWriter.publishEOF(perStore);
String result = runGraph(perStore, encryption, telemetry);
assertTrue(result, result.indexOf("AckWrite")>0);
assertTrue(result, result.indexOf("{\"BlockId\":10}")>0);
assertFalse(result, result.indexOf("0x68,0x65,0x6c,0x6c,0x6f")>0);
assertTrue(result, result.indexOf("BeginReplay")>0);
assertTrue(result, result.indexOf("FinishReplay")>0);
}
示例8: populateRingBufferWithSequence
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void populateRingBufferWithSequence(Pipe<MessageSchemaDynamic> pipe, int testSize) {
int j = testSize;
while (true) {
if (j==0) {
PipeWriter.publishEOF(pipe);
return;//done
}
if (PipeWriter.tryWriteFragment(pipe, MSG_TRUCKS_LOC)) { //AUTO writes template id as needed
PipeWriter.writeASCII(pipe, SQUAD_NAME, "TheBobSquad");
//WRITE THE FIRST MEMBER OF THE SEQ
//block to ensure we have room for the next fragment, and ensure that bytes consumed gets recorded
PipeWriter.blockWriteFragment(pipe, MSG_TRUCK_SEQ_LOC);//could use tryWrite here but it would make this example more complex
PipeWriter.writeLong(pipe, SQUAD_TRUCK_ID, 10);
PipeWriter.writeDecimal(pipe, TRUCK_CAPACITY, 2, 2000);
PipeWriter.writeInt(pipe, THING_NO_LOC, 1);
PipeWriter.blockWriteFragment(pipe, MSG_TRUCK_THING_SEQ_LOC);
PipeWriter.writeInt(pipe, THING_ID_LOC, 7);
//
//WRITE THE SECOND MEMBER OF THE SEQ
//block to ensure we have room for the next fragment, and ensure that bytes consumed gets recorded
PipeWriter.blockWriteFragment(pipe, MSG_TRUCK_SEQ_LOC);
PipeWriter.writeLong(pipe, SQUAD_TRUCK_ID, 11);
PipeWriter.writeDouble(pipe, TRUCK_CAPACITY, 30d, 2); //alternate way of writing a decimal
PipeWriter.writeInt(pipe, THING_NO_LOC, 1);
PipeWriter.blockWriteFragment(pipe, MSG_TRUCK_THING_SEQ_LOC);
PipeWriter.writeInt(pipe, THING_ID_LOC, 7);
//NOTE: because we are waiting until the end of the sequence to write its length we have two rules
// 1. Publish can not be called between these fragments because it will publish a zero for the count
// 2. The RingBuffer must be large enough to hold all the fragments in the sequence.
// Neither one of these apply when the length can be set first.
PipeWriter.writeInt(pipe, SQUAD_NO_MEMBERS, 2); //NOTE: we are writing this field very late because we now know how many we wrote.
PipeWriter.blockWriteFragment(pipe, FRAG_JOMQ_LOC);
PipeWriter.writeInt(pipe, JOMQ_LOC, 42);
PipeWriter.publishWrites(pipe);
j--;
} else {
//Unable to write because there is no room so do something else while we are waiting.
Thread.yield();
}
}
}
示例9: emptyReplayImpl
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void emptyReplayImpl(boolean encryption, boolean telemetry) {
Pipe<PersistedBlobStoreSchema> perStore = PersistedBlobStoreSchema.instance.newPipe(10, 1000);
perStore.initBuffers();
PipeWriter.presumeWriteFragment(perStore, PersistedBlobStoreSchema.MSG_REQUESTREPLAY_6);
PipeWriter.publishWrites(perStore);
PipeWriter.publishEOF(perStore);
String result = runGraph(perStore, encryption, telemetry);
assertTrue(result, result.indexOf("BeginReplay")>0);
assertTrue(result, result.indexOf("FinishReplay")>0);
}
示例10: writeTestValue
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void writeTestValue(Pipe pipe, int blockSize, int testSize) {
int FIELD_LOC = FieldReferenceOffsetManager.lookupFieldLocator(SINGLE_MESSAGE_NAMES[0], FRAG_LOC, FROM);
assertTrue(0==Pipe.contentRemaining(pipe));
int j = testSize;
while (true) {
if (j == 0) {
PipeWriter.publishEOF(pipe);
return;//done
}
if (PipeWriter.tryWriteFragment(pipe, FRAG_LOC)) { //returns true if there is room to write this fragment
int value = (--j*blockSize)/testSize;
PipeWriter.writeFloatAsIntBits(pipe, FIELD_LOC, 1f/(float)value);
PipeWriter.publishWrites(pipe); //must always publish the writes if message or fragment
} else {
//Unable to write because there is no room so do something else while we are waiting.
Thread.yield();
}
}
}
示例11: writeTestValue
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void writeTestValue(Pipe pipe, int blockSize, int testSize) {
int j = testSize;
while (true) {
if (j == 0) {
PipeWriter.publishEOF(pipe);
return;//done
}
if (PipeWriter.tryWriteFragment(pipe, FRAG_LOC)) { //returns true if there is room to write this fragment
int value = (--j*blockSize)/testSize;
PipeWriter.writeDecimal(pipe, FRAG_FIELD, 2, (long) value );
PipeWriter.publishWrites(pipe); //must always publish the writes if message or fragment
} else {
//Unable to write because there is no room so do something else while we are waiting.
Thread.yield();
}
}
}
示例12: testReadWriteStage
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Test
public void testReadWriteStage() {
File file = null;
try {
file = File.createTempFile("testReadWriteStageTest", "dat");
} catch (IOException e) {
e.printStackTrace();
}
String[] paths = new String[] {file.getAbsolutePath()};
GraphManager gm = new GraphManager();
Pipe<SequentialCtlSchema>[] control = new Pipe[]{SequentialCtlSchema.instance.newPipe(10, 1000)};
Pipe<RawDataSchema>[] input = new Pipe[]{RawDataSchema.instance.newPipe(10, 1000)};
Pipe<RawDataSchema>[] output = new Pipe[]{RawDataSchema.instance.newPipe(10, 1000)};
Pipe<SequentialRespSchema>[] response = new Pipe[]{SequentialRespSchema.instance.newPipe(10, 1000)};
control[0].initBuffers();
input[0].initBuffers();
//data to be written
Pipe.addMsgIdx(input[0], 0);
Pipe.addByteArray("hello".getBytes(), input[0]);
Pipe.confirmLowLevelWrite(input[0]);
Pipe.publishWrites(input[0]);
SequentialCtlSchema.publishIdToSave(control[0], 123);
//this replay command is expected to only happen after the data is written since pipe has data.
SequentialCtlSchema.publishReplay(control[0]);
SequentialCtlSchema.publishMetaRequest(control[0]);
PipeWriter.publishEOF(control[0]);
SequentialFileReadWriteStage readWriteStage = new SequentialFileReadWriteStage(gm, control, response, input, output, paths);
StringBuilder outputData = new StringBuilder();
StringBuilder responseData = new StringBuilder();
ConsoleJSONDumpStage watch = ConsoleJSONDumpStage.newInstance(gm, output[0],outputData);
ConsoleJSONDumpStage.newInstance(gm, response[0], responseData);
NonThreadScheduler scheduler= new NonThreadScheduler(gm);
scheduler.startup();
while ( (!GraphManager.isStageTerminated(gm, watch.stageId)) ) {
scheduler.run();
}
scheduler.shutdown();
String responseString = responseData.toString();
assertTrue(responseString, responseString.indexOf("WriteAck")>=0);
assertTrue(responseString, responseString.indexOf("{\"Size\":5}")>=0);
String outputString = outputData.toString();
assertTrue(outputString, outputString.indexOf("0x68,0x65,0x6c,0x6c,0x6f")>=0);
}