當前位置: 首頁>>代碼示例>>Java>>正文


Java ChannelBufferOutputStream.writeInt方法代碼示例

本文整理匯總了Java中org.jboss.netty.buffer.ChannelBufferOutputStream.writeInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelBufferOutputStream.writeInt方法的具體用法?Java ChannelBufferOutputStream.writeInt怎麽用?Java ChannelBufferOutputStream.writeInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.buffer.ChannelBufferOutputStream的用法示例。


在下文中一共展示了ChannelBufferOutputStream.writeInt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTaskMessage

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
/**
 * write a TaskMessage into a stream
 * 
 * Each TaskMessage is encoded as: task ... short(2) len ... int(4) payload
 * ... byte[] *
 */
private void writeTaskMessage(ChannelBufferOutputStream bout,
		TaskMessage message) throws Exception {
	int payload_len = 0;
	if (message.message() != null)
		payload_len = message.message().length;

	int task_id = message.task();
	if (task_id > Short.MAX_VALUE)
		throw new RuntimeException("Task ID should not exceed "
				+ Short.MAX_VALUE);

	bout.writeShort((short) task_id);
	bout.writeInt(payload_len);
	if (payload_len > 0)
		bout.write(message.message());

	// @@@ TESTING CODE
	// LOG.info("Write one message taskid:{}, len:{}, data:{}", task_id
	// , payload_len, JStormUtils.toPrintableString(message.message()) );
}
 
開發者ID:zhangjunfang,項目名稱:jstorm-0.9.6.3-,代碼行數:27,代碼來源:MessageBatch.java

示例2: writeTaskMessage

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
/**
 * write a TaskMessage into a stream
 * 
 * Each TaskMessage is encoded as: task ... short(2) len ... int(4) payload ... byte[] *
 */
private void writeTaskMessage(ChannelBufferOutputStream bout, TaskMessage message) throws Exception {
    int payload_len = 0;
    if (message.message() != null)
        payload_len = message.message().length;

    int task_id = message.task();
    if (task_id > Short.MAX_VALUE)
        throw new RuntimeException("Task ID should not exceed " + Short.MAX_VALUE);

    bout.writeShort((short) task_id);
    bout.writeInt(payload_len);
    if (payload_len > 0)
        bout.write(message.message());

    // @@@ TESTING CODE
    // LOG.info("Write one message taskid:{}, len:{}, data:{}", task_id
    // , payload_len, JStormUtils.toPrintableString(message.message()) );
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:24,代碼來源:MessageBatch.java

示例3: writeTaskMessage

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
/**
 * write a TaskMessage into a stream
 *
 * Each TaskMessage is encoded as: task ... short(2) len ... int(4) payload ... byte[] *
 */
private void writeTaskMessage(ChannelBufferOutputStream bout, TaskMessage message) throws Exception {
    int payload_len = 0;
    if (message.message() != null)
        payload_len = message.message().length;

    short type = message.get_type();
    bout.writeShort(type);

    int task_id = message.task();
    if (task_id > Short.MAX_VALUE)
        throw new RuntimeException("Task ID should not exceed " + Short.MAX_VALUE);

    bout.writeShort((short) task_id);
    bout.writeInt(payload_len);
    if (payload_len > 0)
        bout.write(message.message());

    // LOG.info("Write one message taskid:{}, len:{}, data:{}", taskId
    // , payload_len, JStormUtils.toPrintableString(message.message()) );
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:26,代碼來源:MessageBatch.java

示例4: buffer

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
/**
 * create a buffer containing the encoding of this batch
 */
@Override
public ChannelBuffer buffer() throws Exception {
    int payloadLen = 0;
    if (_message != null)
        payloadLen = _message.length;

    int totalLen = 8 + payloadLen;
    ChannelBufferOutputStream bout = new ChannelBufferOutputStream(ChannelBuffers.directBuffer(totalLen));
    bout.writeShort(_type);

    if (_task > Short.MAX_VALUE)
        throw new RuntimeException("Task ID should not exceed " + Short.MAX_VALUE);

    bout.writeShort((short) _task);
    bout.writeInt(payloadLen);
    if (payloadLen > 0)
        bout.write(_message);

    bout.close();
    return bout.buffer();
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:25,代碼來源:TaskMessage.java

示例5: doEncode

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
private Object doEncode(Request request, ChannelHandlerContext ctx, Channel channel) throws Exception {
    //version from request header;
    byte ver = request.getHeader().getSerializeVersion();
    //overwrite if request header == 0 and version != 0, use version
    if ( ver == 0 && version != 0)
        ver = version;
    int pLen = request.getPayload() == null ? 0 : request.getPayload().length;
    byte[] header = request.getHeader().toByte();
    // encoding length , and check the max value of integer, should be 2GB
    int len = TOTAL + header.length + pLen + R_SIZE;
    if ( len > Integer.MAX_VALUE ) {
        channel.close();
        throw new Exception( len+" exceeding Integer.MAX_VALUE");
    }
    ChannelBufferOutputStream bout =   new ChannelBufferOutputStream(dynamicBuffer(
                len, ctx.getChannel().getConfig().getBufferFactory()));
    bout.write(SIGNATURE);
    bout.write(ver);
    bout.writeInt(len);
    bout.writeShort((short) header.length);
    bout.write(header);
    // request type
    bout.write((byte) request.getType().ordinal());
    bout.write( request.getPayload());
    bout.flush();
    bout.close();
    ChannelBuffer encoded = bout.buffer();
    return encoded;
}
 
開發者ID:viant,項目名稱:CacheStore,代碼行數:30,代碼來源:Encoder.java

示例6: writeTaskMessage

import org.jboss.netty.buffer.ChannelBufferOutputStream; //導入方法依賴的package包/類
/**
 * write a TaskMessage into a stream
 *
 * Each TaskMessage is encoded as:
 *  task ... short(2)
 *  len ... int(4)
 *  payload ... byte[]     *  
 */
private void writeTaskMessage(ChannelBufferOutputStream bout, TaskMessage message) throws Exception {
    int payload_len = 0;
    if (message.message() != null)
        payload_len =  message.message().length;

    int task_id = message.task();
    if (task_id > Short.MAX_VALUE)
        throw new RuntimeException("Task ID should not exceed "+Short.MAX_VALUE);
    
    bout.writeShort((short)task_id);
    bout.writeInt(payload_len);
    if (payload_len >0)
        bout.write(message.message());
}
 
開發者ID:metamx,項目名稱:incubator-storm,代碼行數:23,代碼來源:MessageBatch.java


注:本文中的org.jboss.netty.buffer.ChannelBufferOutputStream.writeInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。