当前位置: 首页>>代码示例>>Java>>正文


Java PipeWriter.writeASCII方法代码示例

本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeWriter.writeASCII方法的典型用法代码示例。如果您正苦于以下问题:Java PipeWriter.writeASCII方法的具体用法?Java PipeWriter.writeASCII怎么用?Java PipeWriter.writeASCII使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ociweb.pronghorn.pipe.PipeWriter的用法示例。


在下文中一共展示了PipeWriter.writeASCII方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestConnect

import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
public static boolean requestConnect(CharSequence url, int conFlags, byte[] willTopic, int willTopicIdx,
		int willTopicLength, int willTopicMask, byte[] willMessageBytes, int willMessageBytesIdx,
		int willMessageBytesLength, int willMessageBytesMask, byte[] username, byte[] passwordBytes,
		Pipe<MQTTConnectionInSchema> toBroker, byte[] clientId, int ttlSec) {
	
	 if (PipeWriter.tryWriteFragment(toBroker, MQTTConnectionInSchema.MSG_CONNECT_2)) {
		
		PipeWriter.writeASCII(toBroker, MQTTConnectionInSchema.MSG_CONNECT_2_FIELD_HOST_401, url);
					
		//this is the high level API however we are writing bytes to to the end of the unstructured buffer.
		final int bytePos = Pipe.getWorkingBlobHeadPosition(toBroker);
		byte[] byteBuffer = Pipe.blob(toBroker);
		int byteMask = Pipe.blobMask(toBroker);
					
		int len = buildConnectPacket(bytePos, byteBuffer, byteMask, ttlSec, conFlags, 
				                                 clientId, 0 , clientId.length, 0xFFFF,
				                                 willTopic, willTopicIdx , willTopicLength, willTopicMask,
				                                 willMessageBytes, willMessageBytesIdx, willMessageBytesLength, willMessageBytesMask,
				                                 username, 0, username.length, 0xFFFF, //TODO: add rest of fields
				                                 passwordBytes, 0, passwordBytes.length, 0xFFFF);//TODO: add rest of fields
		assert(len>0);
		PipeWriter.writeSpecialBytesPosAndLen(toBroker, MQTTConnectionInSchema.MSG_CONNECT_2_FIELD_PACKETDATA_300, len, bytePos);
		
		PipeWriter.publishWrites(toBroker);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:30,代码来源:MQTTEncoder.java

示例2: run

import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
	if (PipeWriter.tryWriteFragment(output, RawDataSchema.MSG_CHUNKEDSTREAM_1)) {
		PipeWriter.writeASCII(output, RawDataSchema.MSG_CHUNKEDSTREAM_1_FIELD_BYTEARRAY_2, "test");
		PipeWriter.publishWrites(output);
	}
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:8,代码来源:ExampleProducerStage.java

示例3: 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();
       	}        	
       	
       }
}
 
开发者ID:oci-pronghorn,项目名称:PronghornPipes,代码行数:36,代码来源:PipeSingleTemplateASCIITest.java

示例4: requestConnect

import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
protected boolean requestConnect(CharSequence url, int conFlags, byte[] willTopic, int willTopicIdx, int willTopicLength, int willTopicMask,  
                                  byte[] willMessageBytes, int willMessageBytesIdx, int willMessageBytesLength, int willMessageBytesMask,
                                  byte[] username, byte[] passwordBytes) {

	if (PipeWriter.tryWriteFragment(toCon, ConInConst.MSG_CON_IN_CONNECT)) {
		
		PipeWriter.writeASCII(toCon, ConInConst.CON_IN_CONNECT_FIELD_URL, url);
					
		//this is the high level API however we are writing bytes to to the end of the unstructured buffer.
		final int bytePos = Pipe.bytesWorkingHeadPosition(toCon);
		byte[] byteBuffer = Pipe.byteBuffer(toCon);
		int byteMask = Pipe.blobMask(toCon);
					
		int len = MQTTEncoder.buildConnectPacket(bytePos, byteBuffer, byteMask, ttlSec, conFlags, 
				                                 clientId, 0 , clientId.length, 0xFFFF,
				                                 willTopic, willTopicIdx , willTopicLength, willTopicMask,
				                                 willMessageBytes, willMessageBytesIdx, willMessageBytesLength, willMessageBytesMask,
				                                 username, 0, username.length, 0xFFFF, //TODO: add rest of fields
				                                 passwordBytes, 0, passwordBytes.length, 0xFFFF);//TODO: add rest of fields
		assert(len>0);
		PipeWriter.writeSpecialBytesPosAndLen(toCon, ConInConst.CON_IN_CONNECT_FIELD_PACKETDATA, len, bytePos);
		
		PipeWriter.publishWrites(toCon);
		return true;
	} else {
		return false;
	}

}
 
开发者ID:oci-pronghorn,项目名称:PronghornGateway,代码行数:30,代码来源:APIStage.java

示例5: 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();
       		
       	}     
       }
}
 
开发者ID:oci-pronghorn,项目名称:PronghornPipes,代码行数:61,代码来源:StreamingConsumerTest.java

示例6: run

import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
		
	 int i = MAX_MESSAGES;//only write this many before allowing the scheduler to again have control 
	 while (--i>=0 &&  PipeWriter.tryWriteFragment(outputRing, MQTTFROM.MSG_MQTT_LOC)) {
		 				 
		 PipeWriter.writeASCII(outputRing, MQTTFROM.FIELD_SERVER_URI_LOC, server, 0, server.length());		
		 
		 int clientId = (int)messageCount&clientMask; //SAME HASH MUST ALSO HAVE THE SAME SERVER!
		 byte[] clientIdBytes = clientIdLookup[(int)clientId];
		 PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_CLIENT_ID_LOC, clientIdBytes, 0, clientIdBytes.length, Integer.MAX_VALUE);		
		 PipeWriter.writeInt(outputRing, MQTTFROM.FIELD_CLIENT_INDEX_LOC, externalIdValue(clientId));
		 				 		 
		 
		 PipeWriter.writeInt(outputRing, MQTTFROM.FIELD_QOS_LOC, qos);			 
		 PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_TOPIC_LOC, topic, 0, topic.length, Integer.MAX_VALUE);		
		 PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_PAYLOAD_LOC, payload, 0, payload.length, Integer.MAX_VALUE);					
		 
		 			 
		 PipeWriter.publishWrites(outputRing);
		 
		 messageCount++;
	 } 

}
 
开发者ID:nathantippy,项目名称:PublishLoadGenerator-For-MQTT,代码行数:26,代码来源:MessageGenStage.java

示例7: run

import com.ociweb.pronghorn.pipe.PipeWriter; //导入方法依赖的package包/类
@Override
public void run() {
			
	while (Pipe.hasContentToRead(inputRing, msgSize)){	
					
		 if (PipeWriter.tryWriteFragment(outputRing, MQTTFROM.MSG_MQTT_LOC)) {
			 Pipe.confirmLowLevelRead(inputRing, msgSize);
			 
			 int msgId = Pipe.takeMsgIdx(inputRing);
		 				 
			 PipeWriter.writeASCII(outputRing, MQTTFROM.FIELD_SERVER_URI_LOC, server, 0, server.length());		
			 
			 int clientId = (int)messageCount&clientMask; //SAME HASH MUST ALSO HAVE THE SAME SERVER!
			 byte[] clientIdBytes = clientIdLookup[(int)clientId];
			 PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_CLIENT_ID_LOC, clientIdBytes, 0, clientIdBytes.length, Integer.MAX_VALUE);		
			 PipeWriter.writeInt(outputRing, MQTTFROM.FIELD_CLIENT_INDEX_LOC, externalIdValue(clientId));
			 				 			 
			 	 
	        int meta = takeRingByteMetaData(inputRing);
	        int len = takeRingByteLen(inputRing);

	        //converting this to the position will cause the byte posistion to increment.
	        int pos = bytePosition(meta, inputRing, len);//has side effect of moving the byte pointer!!
	        										
			byte[] data = byteBackingArray(meta, inputRing);
			int mask = blobMask(inputRing);
				
			if (data[mask&(pos+1)]!=',') {
				throw new RuntimeException("The first char must be 0, 1, or 2 followed by a comma and no spaces, in the CSV");
			}
			
			int qos = (int)(data[mask&pos]-'0');
			PipeWriter.writeInt(outputRing, MQTTFROM.FIELD_QOS_LOC, qos);			 

	        //NOTE: we assume there is no white space around the comma	
			int j = 2;
			while (j<data.length && data[mask&(pos+j)]!=',') {
				j++;
			}

			PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_TOPIC_LOC, data, 2+pos, j-2, mask);		
			PipeWriter.writeBytes(outputRing, MQTTFROM.FIELD_PAYLOAD_LOC, data, j+1+pos, len-(j+1), mask);					
			
			PipeWriter.publishWrites(outputRing);
			Pipe.releaseReads(inputRing); 
			 
			messageCount++;
		 } else {
			 return;
		 }
	}

}
 
开发者ID:nathantippy,项目名称:PublishLoadGenerator-For-MQTT,代码行数:54,代码来源:MessageCSVStage.java


注:本文中的com.ociweb.pronghorn.pipe.PipeWriter.writeASCII方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。