📄 treemessageupstream.java
字号:
/* * @(#)$Id: TreeMessageUpstream.java,v 1.5 2005/08/02 17:57:05 huebsch 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.helpers.trees;import java.net.InetSocketAddress;import services.network.Payload;import util.BitID;import util.network.serialization.GenericByteBuffer;import util.network.serialization.SerializationManager;import util.network.serialization.SerializeBool;/** * Class Expression */public class TreeMessageUpstream extends TreeMessage { public static long serialVersionUID = SerializationManager.getSerialUID( "pier.helpers.trees.TreeMessageUpstream"); protected int totalAdvertisedSlots; protected byte height; protected Payload userMessage; protected boolean deliverOnRedirect; protected TreeDetails treeDetails; /** * Constructor TreeMessage * * @param inputBuffer */ public TreeMessageUpstream(GenericByteBuffer inputBuffer) { super(inputBuffer); this.totalAdvertisedSlots = inputBuffer.getInt(); this.height = inputBuffer.get(); this.userMessage = SerializationManager.deSerialize(inputBuffer); boolean[] flags = SerializeBool.deSerialize(inputBuffer, 2); this.deliverOnRedirect = flags[0]; if (flags[1] == true) { this.treeDetails = new TreeDetails(inputBuffer); } else { this.treeDetails = null; } } /** * Method serialize * * @param outputBuffer * @return */ public long serialize(GenericByteBuffer outputBuffer) { super.serialize(outputBuffer); outputBuffer.putInt(totalAdvertisedSlots); outputBuffer.put(height); SerializationManager.serialize(outputBuffer, userMessage); boolean detailFlag = (treeDetails != null) ? true : false; SerializeBool.serialize(outputBuffer, deliverOnRedirect, detailFlag); if (detailFlag) { treeDetails.serialize(outputBuffer); } return serialVersionUID; } /** * Constructor TreeMessage * * * @param sourceSocketAddress * @param sourceID * @param totalAdvertisedSlots * @param height * @param userMessage * @param deliverOnRedirect * @param treeDetails */ public TreeMessageUpstream(InetSocketAddress sourceSocketAddress, BitID sourceID, int totalAdvertisedSlots, byte height, Payload userMessage, boolean deliverOnRedirect, TreeDetails treeDetails) { super(sourceSocketAddress, sourceID); this.totalAdvertisedSlots = totalAdvertisedSlots; this.height = height; this.userMessage = userMessage; this.deliverOnRedirect = deliverOnRedirect; this.treeDetails = treeDetails; } /** * Method getTotalAdvertisedSlots * @return */ public int getTotalAdvertisedSlots() { return totalAdvertisedSlots; } /** * Method getHeight * @return */ public byte getHeight() { return height; } /** * Method getUserMessage * @return */ public Payload getUserMessage() { return userMessage; } /** * Method getDeliverOnRedirect * @return */ public boolean getDeliverOnRedirect() { return deliverOnRedirect; } /** * Method getTreeDetails * @return */ public TreeDetails getTreeDetails() { return treeDetails; } /** * Method getSize * @return */ public int getSize() { int size = Payload.INT_SIZE + Payload.BYTE_SIZE + Payload.BOOLEAN_SIZE + super.getSize(); if (userMessage != null) { size += userMessage.getSize(); } if (treeDetails != null) { size += treeDetails.getSize(); } return size; } /** * Method toString * @return */ public String toString() { return "<TreeUpstream: S:" + sourceID + "(" + sourceSocketAddress + "), T:" + totalAdvertisedSlots + ", H:" + height + ", R:" + deliverOnRedirect + ", D: " + treeDetails + ", M:" + userMessage + ">"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -