本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeWriter.tryWriteFragment方法的典型用法代码示例。如果您正苦于以下问题:Java PipeWriter.tryWriteFragment方法的具体用法?Java PipeWriter.tryWriteFragment怎么用?Java PipeWriter.tryWriteFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ociweb.pronghorn.pipe.PipeWriter
的用法示例。
在下文中一共展示了PipeWriter.tryWriteFragment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishOnPrivateTopic
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private boolean publishOnPrivateTopic(int token, Writable writable) {
//this is a private topic
Pipe<MessagePrivate> output = publishPrivateTopics.getPipe(token);
if (PipeWriter.tryWriteFragment(output, MessagePrivate.MSG_PUBLISH_1)) {
DataOutputBlobWriter<MessagePrivate> writer = PipeWriter.outputStream(output);
DataOutputBlobWriter.openField(writer);
writable.write(writer);
DataOutputBlobWriter.closeHighLevelField(writer, MessagePrivate.MSG_PUBLISH_1_FIELD_PAYLOAD_3);
PipeWriter.publishWrites(output);
return true;
} else {
return false;
}
}
示例2: copyToSubscriber
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void copyToSubscriber(Pipe<?> pipe, int pipeIdx, long[] targetMarks, int topicLOC, int payloadLOC) {
Pipe<MessageSubscription> outPipe = outgoingMessagePipes[pipeIdx];
if (PipeWriter.tryWriteFragment(outPipe, MessageSubscription.MSG_PUBLISH_103)) {
PipeReader.copyBytes(pipe, outPipe, topicLOC, MessageSubscription.MSG_PUBLISH_103_FIELD_TOPIC_1);
PipeReader.copyBytes(pipe, outPipe, payloadLOC, MessageSubscription.MSG_PUBLISH_103_FIELD_PAYLOAD_3);
//due to batching this may not become the head position upon publish but it will do so eventually.
//so to track this position we use workingHeadPosition not headPosition
targetMarks[pipeIdx] = Pipe.workingHeadPosition(outPipe);
PipeWriter.publishWrites(outPipe);
} else {
//add this one back to the list so we can send again later
pendingPublish[pendingPublishCount++] = pipeIdx;
pendingIngress = false;
}
}
示例3: create
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T create(final EventConsumer consumer, Class<T> clazz) {
//re-use old proxy if possible
if (null!=consumer.cached && clazz.isAssignableFrom(consumer.cached.getClass())) {
if (PipeWriter.tryWriteFragment(consumer.output, consumer.cachedMsgId)) {
return (T)consumer.cached;
} else {
return null;
}
}
return slowCreate(consumer, clazz);
}
示例4: publishServerConnection
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishServerConnection(Pipe<ServerConnectionSchema> output, long fieldConnectionGroup, long fieldChannelId) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_SERVERCONNECTION_100)) {
PipeWriter.writeLong(output,MSG_SERVERCONNECTION_100_FIELD_CONNECTIONGROUP_1, fieldConnectionGroup);
PipeWriter.writeLong(output,MSG_SERVERCONNECTION_100_FIELD_CHANNELID_2, fieldChannelId);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例5: publishBlockChannelUntil
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishBlockChannelUntil(Pipe<I2CCommandSchema> output, long fieldTimeMS) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_BLOCKCHANNELUNTIL_23)) {
PipeWriter.writeLong(output,MSG_BLOCKCHANNELUNTIL_23_FIELD_TIMEMS_14, fieldTimeMS);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例6: populateRingBufferWithASCII
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
private void populateRingBufferWithASCII(Pipe<RawDataSchema> pipe, int blockSize, int testSize) {
int j = testSize;
while (true) {
if (j == 0) {
return;//done
}
if (PipeWriter.tryWriteFragment(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1)) { //returns true if there is room to write this fragment
Pipe.writeTrailingCountOfBytesConsumed(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1);
int stringSize = (--j*blockSize)/testSize;
String testString = buildTestString(stringSize);
//because there is only 1 template we do not write the template id it is assumed to be zero.
//now we write the data for the message
if (0 == (j&1)) {
PipeWriter.writeASCII(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1_FIELD_BYTEARRAY_2, testString);
} else {
if (0 == (j&2)) {
char[] source = testString.toCharArray();
PipeWriter.writeASCII(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1_FIELD_BYTEARRAY_2, source);
} else {
PipeWriter.writeASCII(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1_FIELD_BYTEARRAY_2, testString.toCharArray(), 0, stringSize);
}
}
Pipe.publishWritesBatched(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();
}
}
}
示例7: publishConnect
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishConnect(Pipe<MQTTClientRequestSchema> output, int fieldKeepAliveSec, int fieldFlags, CharSequence fieldClientId, CharSequence fieldWillTopic, byte[] fieldWillPayloadBacking, int fieldWillPayloadPosition, int fieldWillPayloadLength, CharSequence fieldUser, CharSequence fieldPass) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_CONNECT_1)) {
PipeWriter.writeInt(output,MSG_CONNECT_1_FIELD_KEEPALIVESEC_28, fieldKeepAliveSec);
PipeWriter.writeInt(output,MSG_CONNECT_1_FIELD_FLAGS_29, fieldFlags);
PipeWriter.writeUTF8(output,MSG_CONNECT_1_FIELD_CLIENTID_30, fieldClientId);
PipeWriter.writeUTF8(output,MSG_CONNECT_1_FIELD_WILLTOPIC_31, fieldWillTopic);
PipeWriter.writeBytes(output,MSG_CONNECT_1_FIELD_WILLPAYLOAD_32, fieldWillPayloadBacking, fieldWillPayloadPosition, fieldWillPayloadLength);
PipeWriter.writeUTF8(output,MSG_CONNECT_1_FIELD_USER_33, fieldUser);
PipeWriter.writeUTF8(output,MSG_CONNECT_1_FIELD_PASS_34, fieldPass);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例8: publishPublish
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishPublish(Pipe<MQTTClientRequestSchema> output, int fieldQOS, int fieldRetain, CharSequence fieldTopic, byte[] fieldPayloadBacking, int fieldPayloadPosition, int fieldPayloadLength) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_PUBLISH_3)) {
PipeWriter.writeInt(output,MSG_PUBLISH_3_FIELD_QOS_21, fieldQOS);
PipeWriter.writeInt(output,MSG_PUBLISH_3_FIELD_RETAIN_22, fieldRetain);
PipeWriter.writeUTF8(output,MSG_PUBLISH_3_FIELD_TOPIC_23, fieldTopic);
PipeWriter.writeBytes(output,MSG_PUBLISH_3_FIELD_PAYLOAD_25, fieldPayloadBacking, fieldPayloadPosition, fieldPayloadLength);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例9: requestDisconnect
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
protected boolean requestDisconnect() {
// System.err.println("AAA :"+RingBuffer.bytesWriteBase(toCon));
if (PipeWriter.tryWriteFragment(toCon, ConInConst.MSG_CON_IN_DISCONNECT)) {
// System.err.println("BBB :"+RingBuffer.bytesWriteBase(toCon));
PipeWriter.publishWrites(toCon);
// System.err.println("CCCC :"+RingBuffer.bytesWriteBase(toCon));
return true;
} else {
return false;
}
}
示例10: publishPoint
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishPoint(Pipe<I2CBusSchema> output, int fieldClock, int fieldData, long fieldTime) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_POINT_100)) {
PipeWriter.writeInt(output,MSG_POINT_100_FIELD_CLOCK_101, fieldClock);
PipeWriter.writeInt(output,MSG_POINT_100_FIELD_DATA_102, fieldData);
PipeWriter.writeLong(output,MSG_POINT_100_FIELD_TIME_103, fieldTime);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例11: requestPublish
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
protected int requestPublish(byte[] topic, int topicIdx, int topicLength, int topicMask,
int qualityOfService, int retain,
byte[] payload, int payloadIdx, int payloadLength, int payloadMask) {
if (nextFreePacketId >= nextFreePacketIdLimit) {
//get next range
if (Pipe.hasContentToRead(idGenIn, sizeOfPacketIdFragment)) {
loadNextPacketIdRange();
} else {
return -1;
}
}
////
if (PipeWriter.tryWriteFragment(toCon, ConInConst.MSG_CON_IN_PUBLISH)) {
PipeWriter.writeInt(toCon, ConInConst.CON_IN_PUBLISH_FIELD_QOS, qualityOfService);
int localPacketId = (0==qualityOfService) ? -1 : nextFreePacketId++;
PipeWriter.writeInt(toCon, ConInConst.CON_IN_PUBLISH_FIELD_PACKETID, localPacketId);
final int bytePos = Pipe.bytesWorkingHeadPosition(toCon);
byte[] byteBuffer = Pipe.byteBuffer(toCon);
int byteMask = Pipe.blobMask(toCon);
int len = MQTTEncoder.buildPublishPacket(bytePos, byteBuffer, byteMask, qualityOfService, retain,
topic, topicIdx, topicLength, topicMask,
payload, payloadIdx, payloadLength, payloadMask, localPacketId);
PipeWriter.writeSpecialBytesPosAndLen(toCon, ConInConst.CON_IN_PUBLISH_FIELD_PACKETDATA, len, bytePos);
PipeWriter.publishWrites(toCon);
return localPacketId<0 ? 0 : localPacketId;//TODO: we have no id for qos 0 this is dirty.
} else {
return -1;
}
}
示例12: publishSubRelease
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishSubRelease(Pipe<BlockManagerRequestSchema> output, long fieldId, byte[] fieldRouteBacking, int fieldRoutePosition, int fieldRouteLength) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_SUBRELEASE_2)) {
PipeWriter.writeLong(output,MSG_SUBRELEASE_2_FIELD_ID_11, fieldId);
PipeWriter.writeBytes(output,MSG_SUBRELEASE_2_FIELD_ROUTE_14, fieldRouteBacking, fieldRoutePosition, fieldRouteLength);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例13: publishSubWrite
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishSubWrite(Pipe<BlockManagerRequestSchema> output, long fieldId, byte[] fieldPayloadBacking, int fieldPayloadPosition, int fieldPayloadLength) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_SUBWRITE_3)) {
PipeWriter.writeLong(output,MSG_SUBWRITE_3_FIELD_ID_11, fieldId);
PipeWriter.writeBytes(output,MSG_SUBWRITE_3_FIELD_PAYLOAD_12, fieldPayloadBacking, fieldPayloadPosition, fieldPayloadLength);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例14: publishSubRead
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishSubRead(Pipe<BlockManagerRequestSchema> output, long fieldid) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_SUBREAD_4)) {
PipeWriter.writeLong(output,MSG_SUBREAD_4_FIELD_ID_11, fieldid);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}
示例15: publishBlockChannel
import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean publishBlockChannel(Pipe<I2CCommandSchema> output, long fieldDurationNanos) {
boolean result = false;
if (PipeWriter.tryWriteFragment(output, MSG_BLOCKCHANNEL_22)) {
PipeWriter.writeLong(output,MSG_BLOCKCHANNEL_22_FIELD_DURATIONNANOS_13, fieldDurationNanos);
PipeWriter.publishWrites(output);
result = true;
}
return result;
}