All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.javaclub.mq.common.netty.protocol.BrokerStatusProtocol Maven / Gradle / Ivy

package com.github.javaclub.mq.common.netty.protocol;

import io.netty.buffer.ByteBuf;

/**
 *	broker机器节点间的状态反馈包
 */
public class BrokerStatusProtocol extends AbstractProtocol{
	private static byte code = CodeProtocol.broker_status;  
	private long ip;	 
	
	public void encode(ByteBuf out) {
		super.setCode(code);
		super.encode(out);
		out.writeLong(ip);
	}

	public int decode(ByteBuf in){
		int readindex = super.decode(in);
		if(readindex != -1){  
			if(in.readableBytes() >= 8){
				ip = in.readLong();
				return 0;
			}else{
				in.readerIndex(readindex); // 恢复readindex
				return -1;
			}
		}
		return -1;
	}
	
	public byte getCode() {
		return code;
	}

	public void setCode(byte code) {
		BrokerStatusProtocol.code = code;
	}

	public long getIp() {
		return ip;
	}

	public void setIp(long ip) {
		this.ip = ip;
	}

	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy