亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美日韩中文字幕一区| 亚洲免费电影在线| 国内精品国产成人国产三级粉色| 日韩一卡二卡三卡国产欧美| 美国十次了思思久久精品导航| 日韩欧美中文字幕制服| 日韩av一级片| 国产日韩av一区| 色哟哟国产精品免费观看| 亚洲与欧洲av电影| 日韩女优毛片在线| 成人av在线播放网站| 亚洲欧美日韩国产综合在线| 精品视频一区二区三区免费| 乱一区二区av| 国产精品国产精品国产专区不蜜 | 国产乱码精品一区二区三区忘忧草| 久久精品人人爽人人爽| 99re成人精品视频| 亚洲成av人在线观看| 精品国产一区二区国模嫣然| 不卡一区中文字幕| 午夜精品一区二区三区免费视频| 欧美变态tickling挠脚心| 成人免费黄色大片| 亚洲成人免费视| 国产无一区二区| 欧美日韩在线播| 国产成都精品91一区二区三| 亚洲成人你懂的| 国产精品乱码人人做人人爱| 欧美日韩中字一区| 成人午夜视频网站| 久久精品久久99精品久久| 国产午夜精品一区二区| 日本韩国欧美一区二区三区| 美女网站在线免费欧美精品| 成人免费在线播放视频| 91麻豆精品国产| 国产ts人妖一区二区| 亚洲成a人片在线观看中文| 欧美国产精品一区二区三区| 4438成人网| 色综合久久久久网| 粉嫩久久99精品久久久久久夜| 亚洲午夜电影在线| 国产精品美女久久久久久久久| 91精品国产综合久久精品| 成人黄色777网| 麻豆91在线播放| 亚洲成精国产精品女| 中文字幕在线不卡国产视频| 欧美大片一区二区三区| 欧美日韩中文字幕一区| 91在线视频官网| 春色校园综合激情亚洲| 久草精品在线观看| 日韩电影在线观看一区| 亚洲国产日产av| 亚洲啪啪综合av一区二区三区| 日本一区二区三区dvd视频在线| 日韩精品一区二区三区老鸭窝| 欧美日韩免费视频| 欧美又粗又大又爽| 色综合久久久久久久久久久| 99re亚洲国产精品| 成人av午夜影院| 成人性视频网站| 国产成人av一区二区三区在线观看| 精品一区二区三区的国产在线播放| 亚洲午夜精品网| 午夜国产精品一区| 亚洲v精品v日韩v欧美v专区| 亚洲一区免费视频| 亚洲激情六月丁香| 一区二区三区高清| 亚洲国产成人精品视频| 亚洲国产成人av好男人在线观看| 亚洲精品成人悠悠色影视| 一区二区三区不卡视频| 亚洲一区二区三区小说| 亚洲高清不卡在线| 五月婷婷综合网| 麻豆精品一区二区三区| 国产一区二区主播在线| 国产成人午夜视频| 成人高清视频在线观看| 91麻豆123| 欧美亚洲综合色| 日韩三区在线观看| 久久久久国产精品厨房| 欧美国产精品一区二区三区| 亚洲免费观看高清完整版在线观看熊| 亚洲人吸女人奶水| 亚洲图片欧美视频| 秋霞成人午夜伦在线观看| 国产一区二区三区美女| 成人做爰69片免费看网站| 日本精品一区二区三区高清 | 首页国产丝袜综合| 秋霞午夜av一区二区三区| 国产成人精品三级| 91理论电影在线观看| 欧美性感一区二区三区| 91精品国产综合久久国产大片 | 欧美日韩一区在线观看| 欧美一区二区人人喊爽| 国产亚洲1区2区3区| 亚洲精品伦理在线| 亚洲第一福利一区| 国产福利一区二区三区在线视频| 91老师片黄在线观看| 日韩三级av在线播放| 亚洲欧洲韩国日本视频| 水野朝阳av一区二区三区| 国产精品资源在线看| 日本韩国一区二区三区视频| 欧美日韩国产一级片| 国产精品欧美精品| 日日骚欧美日韩| 成人av网站免费观看| 日韩一区二区三区在线| 中文字幕一区av| 久久国产精品色| 色欧美88888久久久久久影院| 日韩一区二区在线播放| 亚洲丝袜另类动漫二区| 久久99精品一区二区三区三区| 北岛玲一区二区三区四区| 欧美一区二区三区影视| 中文字幕一区免费在线观看| 另类调教123区| 色8久久精品久久久久久蜜| 久久影院视频免费| 亚洲国产欧美日韩另类综合| 国产a区久久久| 精品国产三级a在线观看| 亚洲一区二区三区三| 高清不卡在线观看av| 欧美成人video| 视频一区在线播放| 91理论电影在线观看| 国产欧美一区二区精品性色| 美女网站一区二区| 欧美电影在线免费观看| 亚洲日本一区二区三区| 岛国av在线一区| 欧美精品一区视频| 免费观看一级特黄欧美大片| 欧美最新大片在线看| 最新日韩在线视频| 成人国产精品免费| 国产日韩欧美综合一区| 国产一区不卡在线| 精品国产sm最大网站免费看| 日韩av中文字幕一区二区| 欧美日韩国产美| 婷婷六月综合亚洲| 欧美日韩国产123区| 亚洲一卡二卡三卡四卡五卡| 91精品福利视频| 亚洲精品视频自拍| 色天天综合久久久久综合片| 一区二区三区四区乱视频| 91网站黄www| 日本sm残虐另类| 欧美三级视频在线| 亚洲一区二区三区视频在线播放| 在线视频一区二区三区| 亚洲综合视频在线观看| 91麻豆福利精品推荐| 亚洲免费观看高清完整| 欧美午夜精品一区二区三区| 亚洲一区二区成人在线观看| 欧美日韩免费电影| 日本成人在线视频网站| 日韩女优毛片在线| 国产精品一二一区| 国产精品国产三级国产aⅴ中文 | 99精品在线观看视频| 亚洲卡通动漫在线| 在线视频你懂得一区二区三区| 亚洲一区二区高清| 91麻豆精品国产无毒不卡在线观看| 午夜视频一区二区三区| 欧美成人a视频| 国产91色综合久久免费分享| 日韩理论片在线| 538在线一区二区精品国产| 麻豆传媒一区二区三区| 久久久久国产精品厨房| 色综合久久中文字幕综合网| 无吗不卡中文字幕| 欧美精品一区二区久久婷婷| 国产mv日韩mv欧美| 亚洲高清视频中文字幕| 欧美电影免费观看高清完整版| 丁香激情综合五月| 午夜视频在线观看一区| 久久久综合精品|