当前位置: 首页>>代码示例>>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;未经允许,请勿转载。