⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phtmessageack.java

📁 High performance DB query
💻 JAVA
字号:
/*
 * @(#)$Id: PHTMessageAck.java,v 1.1 2005/09/06 04:16:57 burkhart Exp $
 *
 * Copyright (c) 2001-2004 Regents of the University of California.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached BERKELEY-LICENSE
 * file. If you do not find these files, copies can be found by writing to:
 * Computer Science Division, Database Group, Universite of California,
 * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License
 *
 * Copyright (c) 2003-2004 Intel Corporation. All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE file.
 * If you do not find these files, copies can be found by writing to:
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300,
 * Berkeley, CA, 94704.  Attention:  Intel License Inquiry.
 */


package pier.indexes.prefixhashtree;

import java.net.InetSocketAddress;

import pier.messages.IndexMessage;
import services.network.Payload;
import util.network.serialization.GenericByteBuffer;
import util.network.serialization.SerializationManager;
import util.network.serialization.SerializeString;

/**
 * Class PHTMessageAck
 * 
 */
public class PHTMessageAck extends IndexMessage {
	
	public static long serialVersionUID =
		SerializationManager.getSerialUID("pier.indexes.prefixhashtree.PHTMessageAck");
	protected long messageIdToAck;
	protected short transferDone;
	
	
	/**
	 * Constructor
	 * @param inputBuffer
	 */
	public PHTMessageAck(GenericByteBuffer inputBuffer) {
		super(inputBuffer);
		this.messageIdToAck = inputBuffer.getLong();
		this.transferDone = inputBuffer.getShort();
	}
	
	/**
	 * Method serialize
	 *
	 * @param outputBuffer
	 * @return
	 */
	public long serialize(GenericByteBuffer outputBuffer) {
		super.serialize(outputBuffer);
		
		outputBuffer.putLong(messageIdToAck);
		outputBuffer.putShort(transferDone);
		
		return serialVersionUID;
	}
	
	/**
	 * Constructor QueryForwardRequest
	 */
	public PHTMessageAck() { }
	
	
	private void init(String indexName, String indexType, long lifetime,
			InetSocketAddress source, long messageID,
			Payload additionalData, long messageIdToAck, short transferDone) {
		super.init(indexName, indexType, lifetime, source, messageID,
				additionalData);
		
		this.messageIdToAck = messageIdToAck;
		this.transferDone = transferDone;
	}
	
	/**
	 * Method getAckedMessageId
	 * @return
	 */
	public long getAckedMessageId() {
		return this.messageIdToAck;
	}
	
	/**
	 * Method transferDone
	 * 
	 * @return - true if this message is an ack for a PHTTransferDoneMessage, false if not
	 */
	public boolean transferDone() {
		return (transferDone > 0);
	}
	
	/**
	 * Method getSize
	 * @return
	 */
	public int getSize() {
		int size = super.getSize(); 
		
		return size + Payload.LONG_SIZE + Payload.SHORT_SIZE;
	}
	
    /**
     * Method toString
     * @return
     */
    public String toString() {
        return "<PHTMessageAck: N:" + indexName + ", T:" + indexType + ", S:"
               + source + ", M:" + messageID + ", L:" + lifetime + ", D:"
               + additionalData + ", MITA:" + messageIdToAck + ", TD:" + transferDone + ">";
    }
	
	/**
	 * Method allocate
	 *
	 * @param indexName
	 * @param indexType
	 * @param lifetime
	 * @param source
	 * @param messageID
	 * @param additionalData
	 * @param messageIdToAck
	 * @param transferDone
	 * @return
	 */
	public static PHTMessageAck allocate(String indexName, String indexType,
			long lifetime,
			InetSocketAddress source,
			long messageID,
			Payload additionalData,
			long messageIdToAck, short transferDone) {
		PHTMessageAck message = new PHTMessageAck();
		
		message.init(indexName, indexType, lifetime, source, messageID,
				additionalData, messageIdToAck, transferDone);
		
		return message;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -