亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fingertable.java

?? Chord package into p2psim
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************************
 *                                                                         *
 *                             FingerTable.java                            *
 *                            -------------------                          *
 *   date                 : 16.08.2004                                     *
 *   copyright            : (C) 2004-2008 Distributed and                  *
 *                              Mobile Systems Group                       *
 *                              Lehrstuhl fuer Praktische Informatik       *
 *                              Universitaet Bamberg                       *
 *                              http://www.uni-bamberg.de/pi/              *
 *   email                : sven.kaffille@uni-bamberg.de                   *
 *   			    		karsten.loesing@uni-bamberg.de                 *
 *                                                                         *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   A copy of the license can be found in the license.txt file supplied   *
 *   with this software or at: http://www.gnu.org/copyleft/gpl.html        *
 *                                                                         *
 ***************************************************************************/
package de.uniba.wiai.lspi.chord.service.impl;

import static de.uniba.wiai.lspi.util.logging.Logger.LogLevel.DEBUG;
import static de.uniba.wiai.lspi.util.logging.Logger.LogLevel.INFO;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import de.uniba.wiai.lspi.chord.com.Node;
import de.uniba.wiai.lspi.chord.data.ID;
import de.uniba.wiai.lspi.chord.data.URL;
import de.uniba.wiai.lspi.util.logging.Logger;

/**
 * Stores references on the nodes in the finger table and provides methods for
 * querying and manipulating this table.
 * 
 * @author Karsten Loesing
 * @version 1.0.5
 */
final class FingerTable {

	/**
	 * ID of local node.
	 */
	private final ID localID;

	/**
	 * Finger table data.
	 */
	private final Node[] remoteNodes;

	/**
	 * Reference on parent object.
	 */
	private final References references;

	/**
	 * Object logger.
	 */
	private Logger logger;

	/**
	 * Creates an initially empty finger table. The table size is determined by
	 * the given ID's length. A reference on the parent object of type
	 * References is stored for being able to determine and disconnect unused
	 * references after removing them from the table.
	 * 
	 * @param localID
	 *            ID of local node.
	 * @param references
	 *            Reference on parent object.
	 * @throws NullPointerException
	 *             If either of the parameters is <code>null</code>.
	 */
	FingerTable(ID localID, References references) {

		if (localID == null || references == null) {
			throw new NullPointerException(
					"Neither parameter of the constructor may contain a null "
							+ "value!");
		}

		this.logger = Logger.getLogger(FingerTable.class + "." + localID);
		this.logger.debug("Logger initialized.");

		this.references = references;
		this.localID = localID;
		this.remoteNodes = new Node[localID.getLength()];
	}

	/**
	 * Sets one table entry to the given reference.
	 * 
	 * @param index
	 *            Index of table entry.
	 * @param proxy
	 *            Reference to store.
	 * @throws ArrayIndexOutOfBoundsException
	 *             If given index is not contained in the finger table.
	 * @throws NullPointerException
	 *             If given reference is <code>null</code>.
	 */
	private final void setEntry(int index, Node proxy) {

		if (index < 0 || index >= this.remoteNodes.length) {
			ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(
					"setEntry was invoked with an index out of array "
							+ "bounds; index=" + index + ", length of array="
							+ this.remoteNodes.length);
			this.logger.error("Out of bounds!", e);
			throw e;
		}

		if (proxy == null) {
			NullPointerException e = new NullPointerException(
					"Reference to proxy may not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}

		this.remoteNodes[index] = proxy;

		if (this.logger.isEnabledFor(DEBUG)) {
			this.logger.debug("Entry " + index + " set to " + proxy.toString());
		}
	}

	/**
	 * Returns the reference stored at the given index.
	 * 
	 * @param index
	 *            Index of entry to be returned.
	 * @throws ArrayIndexOutOfBoundsException
	 *             If given index is not contained in the finger table.
	 * @return Reference stored at the given index.
	 */
	private final Node getEntry(int index) {

		if (index < 0 || index >= this.remoteNodes.length) {
			ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(
					"getEntry was invoked with an index out of array "
							+ "bounds; index=" + index + ", length of array="
							+ this.remoteNodes.length);
			this.logger.error("Out of bounds!", e);
			throw e;
		}

		return this.remoteNodes[index];
	}

	/**
	 * Sets the reference at the given index to <code>null</code> and triggers
	 * to disconnect that node, if no other reference to it is kept any more.
	 * 
	 * @param index
	 *            Index of entry to be set to <code>null</code>.
	 * @throws ArrayIndexOutOfBoundsException
	 *             If given index is not contained in the finger table.
	 */
	private final void unsetEntry(int index) {
		if (index < 0 || index >= this.remoteNodes.length) {
			ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(
					"unsetEntry was invoked with an index out of array "
							+ "bounds; index=" + index + ", length of array="
							+ this.remoteNodes.length);
			this.logger.error("Out of bounds!", e);
			throw e;
		}

		// remember overwritten reference
		Node overwrittenNode = this.getEntry(index);

		// set reference to null
		this.remoteNodes[index] = null;

		if (overwrittenNode == null) {
			this.logger.debug("unsetEntry did not change anything, because "
					+ "entry was null before.");
		} else {
			// check if overwritten reference does not exist any more
			this.references.disconnectIfUnreferenced(overwrittenNode);
			if (this.logger.isEnabledFor(DEBUG)) {
				this.logger.debug("Entry set to null: index=" + index
						+ ", overwritten node=" + overwrittenNode.toString());
			}
		}
	}

	/**
	 * Adds the given reference to all finger table entries of which the start
	 * index is in the interval (local node ID, new node ID) and of which the
	 * current entry is <code>null</code> or further away from the local node
	 * ID than the new node ID (ie. the new node ID is in the interval (local
	 * node ID, currently stored node ID) ).
	 * 
	 * @param proxy
	 *            Reference to be added to the finger table.
	 * @throws NullPointerException
	 *             If given reference is <code>null</code>.
	 */
	final void addReference(Node proxy) {

		if (proxy == null) {
			NullPointerException e = new NullPointerException(
					"Reference to add may not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}

		// for logging
		int lowestWrittenIndex = -1;
		int highestWrittenIndex = -1;

		for (int i = 0; i < this.remoteNodes.length; i++) {

			ID startOfInterval = this.localID.addPowerOfTwo(i);
			if (!startOfInterval.isInInterval(this.localID, proxy.getNodeID())) {
				break;
			}

			// for logging
			if (lowestWrittenIndex == -1) {
				lowestWrittenIndex = i;
			}
			highestWrittenIndex = i;

			if (getEntry(i) == null) {
				setEntry(i, proxy);
			} else if (proxy.getNodeID().isInInterval(this.localID,
					getEntry(i).getNodeID())) {
				Node oldEntry = getEntry(i);
				setEntry(i, proxy);
				this.references.disconnectIfUnreferenced(oldEntry);
			}
		}

		// logging
		if (this.logger.isEnabledFor(DEBUG)) {
			if (highestWrittenIndex == -1) {

				this.logger
						.debug("addReference did not add the given reference, "
								+ "because it did not fit anywhere!");

			}
		}
		if (this.logger.isEnabledFor(INFO)) {
			if (highestWrittenIndex == lowestWrittenIndex) {

				this.logger.info("Added reference to finger table entry "
						+ highestWrittenIndex);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区在线电影| 欧美日韩五月天| 亚洲精品水蜜桃| 69p69国产精品| 暴力调教一区二区三区| 日韩国产一区二| 亚洲人午夜精品天堂一二香蕉| 欧美日韩在线播放一区| 成人爱爱电影网址| 久久国产精品72免费观看| 亚洲一区二区三区自拍| 26uuu色噜噜精品一区二区| 欧美综合久久久| www.亚洲在线| 国产精品主播直播| 免费不卡在线观看| 亚洲国产另类av| 一区二区三区在线视频观看| 国产欧美日韩视频在线观看| 91精品国产综合久久久久久久久久| 91丨九色丨蝌蚪富婆spa| 风间由美中文字幕在线看视频国产欧美| 视频一区在线播放| 亚洲成av人影院在线观看网| 亚洲免费观看高清完整版在线观看熊| 国产欧美日韩麻豆91| 久久久精品一品道一区| 欧美成人一区二区三区片免费| 欧美亚洲国产一卡| 日本韩国一区二区三区视频| 91首页免费视频| 91影院在线免费观看| 日韩免费观看2025年上映的电影 | 日韩手机在线导航| 欧美色中文字幕| 在线观看视频一区二区欧美日韩| 91视视频在线直接观看在线看网页在线看| 国产揄拍国内精品对白| 精品午夜久久福利影院| 激情欧美日韩一区二区| 老司机精品视频在线| 免费人成在线不卡| 精品系列免费在线观看| 国产精品资源网| 成人久久久精品乱码一区二区三区| 黑人巨大精品欧美一区| 国产精品综合二区| 高清av一区二区| 波多野结衣中文字幕一区二区三区 | 成人免费观看av| 成人精品视频一区二区三区尤物| 成人午夜看片网址| 91首页免费视频| 欧美视频一二三区| 91精品国产综合久久精品app| 欧美一区二区三区性视频| 欧美精选在线播放| 欧美α欧美αv大片| 国产色综合一区| 亚洲免费观看高清| 日本不卡不码高清免费观看| 麻豆一区二区99久久久久| 国产真实乱偷精品视频免| 懂色av一区二区夜夜嗨| 一本久道久久综合中文字幕| 欧美日本不卡视频| 26uuu另类欧美亚洲曰本| 国产精品视频一二三区| 成人看片黄a免费看在线| 91视频免费播放| 欧美精品三级日韩久久| 久久久久久久久久久电影| 国产精品伦理一区二区| 亚洲永久免费av| 久久精品国产精品亚洲红杏| 成人国产在线观看| 欧美在线不卡一区| 精品精品国产高清a毛片牛牛 | 国产欧美久久久精品影院| 亚洲乱码国产乱码精品精98午夜 | 国内精品免费**视频| 91年精品国产| 日韩免费性生活视频播放| 中文字幕制服丝袜一区二区三区 | 精品国产91久久久久久久妲己 | 免费久久精品视频| 99久久综合狠狠综合久久| 欧美日韩小视频| 国产精品国产三级国产普通话99| 亚洲电影一区二区三区| 国产成人啪午夜精品网站男同| 欧美中文字幕亚洲一区二区va在线 | 日韩无一区二区| 国产精品久久三| 久久爱www久久做| 在线中文字幕不卡| 亚洲国产精品ⅴa在线观看| 亚洲成av人片在线| 91在线播放网址| 久久精品免视看| 日韩av中文字幕一区二区三区| 99久久国产免费看| 精品日韩一区二区| 亚洲va欧美va人人爽| 不卡的电视剧免费网站有什么| 91精品国产色综合久久ai换脸| 中文字幕中文字幕一区二区| 国产精品456| 日韩欧美卡一卡二| 午夜精品久久久久久久99樱桃| 成人免费视频视频| 国产网红主播福利一区二区| 日本视频一区二区三区| 欧美午夜片在线观看| 日韩码欧中文字| 国产成人精品亚洲日本在线桃色| 欧美一区二区三区四区在线观看| 亚洲精品成人精品456| 成人av资源站| 欧美韩国日本综合| 国产精品夜夜嗨| 久久夜色精品一区| 国产精品自产自拍| 久久久久久久性| 国产一区二区在线电影| 精品三级在线观看| 久久精品国产一区二区三区免费看| 欧美日韩国产乱码电影| 亚洲成人免费在线观看| 亚洲精品一二三四区| av动漫一区二区| 国产精品国产三级国产aⅴ原创 | 岛国精品在线播放| 久久久99精品免费观看| 国产一区美女在线| 日韩精品在线一区二区| 久久er精品视频| 精品免费日韩av| 国产精品一区在线| 欧美国产亚洲另类动漫| 成人高清视频在线| 亚洲欧洲精品天堂一级| 99riav久久精品riav| 亚洲精品中文在线观看| 欧美性感一类影片在线播放| 午夜电影网一区| 日韩免费高清视频| 国产精品综合在线视频| 中文子幕无线码一区tr| 成人福利视频网站| 亚洲精品亚洲人成人网在线播放| 欧美中文字幕久久| 免费视频一区二区| 国产清纯在线一区二区www| 成人免费视频视频在线观看免费 | 久久久久久久久久久久久女国产乱| 国产乱妇无码大片在线观看| 中文字幕第一页久久| 不卡一卡二卡三乱码免费网站| 中文字幕五月欧美| 欧美中文字幕一区二区三区亚洲| 无码av免费一区二区三区试看| 日韩视频在线一区二区| 国产精品资源在线观看| 樱桃国产成人精品视频| 91精品国产一区二区| 成人午夜在线免费| 亚洲成av人片www| 久久伊99综合婷婷久久伊| aaa欧美大片| 天堂影院一区二区| 国产欧美日韩麻豆91| 色av成人天堂桃色av| 日韩中文字幕区一区有砖一区 | 亚洲永久免费视频| 日韩欧美不卡一区| 国产91精品一区二区| 亚洲精选免费视频| 日韩丝袜情趣美女图片| 99精品国产91久久久久久 | 99热精品一区二区| 亚洲国产精品一区二区久久 | 国产人伦精品一区二区| 欧美日韩在线三区| 成人激情动漫在线观看| 日韩精品乱码av一区二区| 国产欧美日产一区| 欧美一二三四在线| 欧洲在线/亚洲| 国产成人亚洲精品青草天美| 五月婷婷激情综合| 国产精品伦理一区二区| 精品国产亚洲在线| 欧美四级电影在线观看| 成人午夜精品一区二区三区| 久久99这里只有精品| 亚洲综合自拍偷拍| 国产精品三级电影| 精品伦理精品一区| 欧美日韩三级在线|