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

📄 phtdatatransfermessage.java

📁 High performance DB query
💻 JAVA
字号:
/*
 * @(#)$Id: PHTDataTransferMessage.java,v 1.1 2005/09/06 04:16:15 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.IndexInsertMessage;
import services.network.Payload;
import util.network.serialization.GenericByteBuffer;
import util.network.serialization.SerializationManager;

/**
 * Class PHTDataTransferMessage
 * 
 */
public class PHTDataTransferMessage extends IndexInsertMessage {

    public static long serialVersionUID =
        SerializationManager.getSerialUID("pier.indexes.prefixhashtree.PHTDataTransferMessage");
    protected Payload sendingNode;
    protected Payload keySentTo;
    protected short transferDone;
    
    /**
     * Constructor QueryForwardRequest
     *
     * @param inputBuffer
     */
    public PHTDataTransferMessage(GenericByteBuffer inputBuffer) {
        super(inputBuffer);

        this.sendingNode = SerializationManager.deSerialize(inputBuffer);
        this.keySentTo = SerializationManager.deSerialize(inputBuffer);
        this.transferDone = inputBuffer.getShort();
    }

    /**
     * Method serialize
     *
     * @param outputBuffer
     * @return
     */
    public long serialize(GenericByteBuffer outputBuffer) {
        super.serialize(outputBuffer);
        SerializationManager.serialize(outputBuffer, sendingNode);
        SerializationManager.serialize(outputBuffer, keySentTo);
        outputBuffer.putShort(transferDone);

        return serialVersionUID;
    }

    /**
     * Constructor QueryForwardRequest
     */
    protected PHTDataTransferMessage() {}

    /**
     * Method init
     * 
     * @param indexName
     * @param indexType
     * @param lifetime
     * @param source
     * @param messageID
     * @param additionalData
     * @param key
     * @param value
     * @param sendingNode
     * @param keySentTo
     * @param transferDone
     */
    protected void init(String indexName, String indexType, long lifetime,
                      InetSocketAddress source, long messageID,
                      Payload additionalData, Payload key, Payload value,
					  Payload sendingNode, Payload keySentTo, short transferDone) {
        super.init(indexName, indexType, lifetime, source, messageID,
                   additionalData);

        this.key = key;
        this.value = value;
        this.sendingNode = sendingNode;
        this.keySentTo = keySentTo;
        this.transferDone = transferDone;
    }

    /**
     * Method getSendingNode
     * @return
     */
    public Payload getSendingNode() {
    	return sendingNode;
    }
    
    /**
     * Method getKeySentTo
     * @return
     */
    public Payload getKeySentTo() {
    	return keySentTo;
    }
    
    /**
     * Method transferDone
     * @return - true if this indicates the end of the data being sent, false otherwise
     */
    public boolean transferDone() {
    	return (transferDone > 0);
    }
    
    /**
     * Method getSize
     * @return
     */
    public int getSize() {
        int size = super.getSize();

        if (sendingNode != null) {
            size += sendingNode.getSize();
        }
        if (keySentTo != null) {
            size += keySentTo.getSize();
        }

        return size + Payload.SHORT_SIZE;
    }
    
    /**
     * Method toString
     * @return
     */
    public String toString() {
        return "<PHTDataTransferMessage: N:" + indexName + ", T:" + indexType + ", S:"
               + source + ", M:" + messageID + ", L:" + lifetime + ", D:"
               + additionalData + ", K:" + key + ", V:" + value + ", SN:" + sendingNode + 
			   ", KST:" + keySentTo + ", TD:" + transferDone + ">";
    }

    /**
     * Method allocate
     *
     * @param indexName
     * @param indexType
     * @param lifetime
     * @param source
     * @param messageID
     * @param additionalData
     * @param key
     * @param value
     * @param sendingNode
     * @param keySentTo
     * @param transferDone
     * @return
     */
    public static PHTDataTransferMessage allocate(String indexName,
                                              String indexType, long lifetime,
                                              InetSocketAddress source,
                                              long messageID,
                                              Payload additionalData,
                                              Payload key, Payload value,
											  Payload sendingNode, 
											  Payload keySentTo, short transferDone) {
        PHTDataTransferMessage message = new PHTDataTransferMessage();

        message.init(indexName, indexType, lifetime, source, messageID,
                     additionalData, key, value, sendingNode, keySentTo, transferDone);

        return message;
    }
}

⌨️ 快捷键说明

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