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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? references.java

?? Chord package into p2psim
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************************
 *                                                                         *
 *                              References.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.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import de.uniba.wiai.lspi.chord.com.CommunicationException;
import de.uniba.wiai.lspi.chord.com.Entry;
import de.uniba.wiai.lspi.chord.com.Node;
import de.uniba.wiai.lspi.chord.com.Proxy;
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 all remote references of nodes the local node is connected to and
 * provides methods for querying and manipulating these references. Makes use of
 * one finger table, one successor list, and one predecessor reference.
 * 
 * @author Karsten Loesing
 * @version 1.0.5
 */
final class References {

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

	/**
	 * This node's finger table.
	 */
	private FingerTable fingerTable = null;

	/**
	 * This node's successor list
	 */
	private SuccessorList successorList = null;

	/**
	 * This node's predecessor.
	 */
	private Node predecessor = null;

	/**
	 * This node's local ID.
	 */
	private ID localID = null;

	private URL localURL = null;

	private Entries entries;

	/**
	 * Creates an References object which contains no references.
	 * 
	 * @param locID
	 *            ID of local node. Must not be <code>null</code>.
	 * @param numberOfEntriesInSuccessorList
	 *            Length of successor list to be created. Must be greater or
	 *            equal 1!
	 * @param entries
	 *            Reference on this nodes' entries which is passed to creation
	 *            of the successor list. Must not be <code>null</code>.   
	 * @throws IllegalArgumentException
	 *             If any parameters is <code>null</code> or 
	 *             if number of entries in successor list is less than 1.
	 */
	References(ID locID, URL locURL, int numberOfEntriesInSuccessorList, Entries entries) {

		if (locURL == null || locID == null || entries == null) {
			throw new IllegalArgumentException(
					"No parameter of constructor may be null!");
		}

		if (numberOfEntriesInSuccessorList < 1)
			throw new IllegalArgumentException(
					"Number of entries in successor list cannot be less than 1! "
							+ numberOfEntriesInSuccessorList
							+ " is not a valid value!");

		this.logger = Logger.getLogger(References.class.getName() + "."
				+ locID);

		this.logger.debug("Logger initialized.");

		// store node id
		this.localID = locID;
		
		this.localURL = locURL; 

		this.entries = entries;

		// create empty finger table and successor list
		this.fingerTable = new FingerTable(locID, this);
		this.successorList = new SuccessorList(locID,
				numberOfEntriesInSuccessorList, this, entries);
	}

	/**
	 * Determines the closest preceding node for the given ID based on finger
	 * table, successor list, and predecessor, but without testing the node's
	 * liveliness.
	 * 
	 * @param key
	 *            ID to find closest preceding node for.
	 * @throws NullPointerException
	 *             If ID is <code>null</code>.
	 * @return Reference on closest preceding node.
	 */
	final synchronized Node getClosestPrecedingNode(ID key) {

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

		Map<ID, Node> foundNodes = new HashMap<ID, Node>();
		// determine closest preceding reference of finger table
		Node closestNodeFT = this.fingerTable.getClosestPrecedingNode(key);
		if (closestNodeFT != null) {
			foundNodes.put(closestNodeFT.getNodeID(), closestNodeFT);
		}

		// determine closest preceding reference of successor list
		Node closestNodeSL = this.successorList.getClosestPrecedingNode(key);
		if (closestNodeSL != null) {
			foundNodes.put(closestNodeSL.getNodeID(), closestNodeSL);
		}

		// predecessor is appropriate only if it precedes the given id
		Node predecessorIfAppropriate = null;
		if (this.predecessor != null
				&& key.isInInterval(this.predecessor.getNodeID(), this.localID)) {
			predecessorIfAppropriate = this.predecessor;
			foundNodes.put(this.predecessor.getNodeID(), predecessor);
		}

		// with three references which may be null, there are eight (8) cases we
		// have to enumerate...
		Node closestNode = null;
		List<ID> orderedIDList = new ArrayList<ID>(foundNodes.keySet());
		orderedIDList.add(key);
		int sizeOfList = orderedIDList.size();
		// size of list must be greater than one to not only contain the key.
		// if (sizeOfList > 1) {

		/*
		 * Sort list in ascending order
		 */
		Collections.sort(orderedIDList);
		/*
		 * The list item with one index lower than that of the key must be the
		 * id of the closest predecessor or the key.
		 */
		int keyIndex = orderedIDList.indexOf(key);
		/*
		 * As all ids are located on a ring if the key is the first item in the
		 * list we have to select the last item as predecessor with help of this
		 * calculation.
		 */
		int index = (sizeOfList + (keyIndex - 1)) % sizeOfList;
		/*
		 * Get the references to the node from the map of collected nodes.
		 */
		ID idOfclosestNode = orderedIDList.get(index);
		closestNode = foundNodes.get(idOfclosestNode);
		if (closestNode == null) {
			throw new NullPointerException("closestNode must not be null!");
		}

		/*
		 * Following code is too complicated.
		 */
		// if (closestNodeFT == null) {
		// if (closestNodeSL == null) {
		// if (predecessorIfAppropriate == null) {
		// // no reference is appropriate
		// closestNode = null;
		// } else {
		// // only predecessor is appropriate (case should not occur,
		// // but anyway...
		// closestNode = predecessorIfAppropriate;
		// }
		// } else {
		// if (predecessorIfAppropriate == null) {
		// // only reference of successor list is appropriate
		// closestNode = closestNodeSL;
		// } else {
		// // either predecessor or reference of successor list is
		// // appropriate; determine one of both
		// if (predecessorIfAppropriate.nodeID.isInInterval(
		// closestNodeSL.nodeID, key)) {
		// closestNode = predecessorIfAppropriate;
		// } else {
		// closestNode = closestNodeSL;
		// }
		// }
		// }
		// } else {
		// if (closestNodeSL == null) {
		// if (predecessorIfAppropriate == null) {
		// // only reference of finger table is appropriate
		// closestNode = closestNodeFT;
		// } else {
		// // either predecessor or reference of finger table is
		// // appropriate; determine one of both
		// if (predecessorIfAppropriate.nodeID.isInInterval(
		// closestNodeFT.nodeID, key)) {
		// closestNode = predecessorIfAppropriate;
		// } else {
		// closestNode = closestNodeFT;
		// }
		// }
		// } else {
		// if (predecessorIfAppropriate == null) {
		// // either reference of successor list or reference of finger
		// // table is appropriate; determine one of both
		// if (closestNodeSL.nodeID.isInInterval(closestNodeFT.nodeID,
		// key)) {
		// closestNode = closestNodeSL;
		// } else {
		// closestNode = closestNodeFT;
		// }
		// } else {
		// // either of the three reference is appropriate; determine
		// // first one of the references of successor list and finger
		// // table is more appropriate and afterwards compare with
		// // predecessor
		// if (closestNodeSL.nodeID.isInInterval(closestNodeFT.nodeID,
		// key)) {
		// if (predecessorIfAppropriate.nodeID.isInInterval(
		// closestNodeSL.nodeID, key)) {
		// closestNode = predecessorIfAppropriate;
		// } else {
		// closestNode = closestNodeSL;
		// }
		// } else {
		// if (predecessorIfAppropriate.nodeID.isInInterval(
		// closestNodeFT.nodeID, key)) {
		// closestNode = predecessorIfAppropriate;
		// } else {
		// closestNode = closestNodeFT;
		// }
		// }
		// }
		// }
		// }
		if (this.logger.isEnabledFor(DEBUG)) {
			this.logger.debug("Closest preceding node of ID "
					+ key
					+ " at node "
					+ this.localID.toString()
					+ " is "
					+ closestNode.getNodeID()
					+ " with closestNodeFT="
					+ (closestNodeFT == null ? "null" : ""
							+ closestNodeFT.getNodeID())
					+ " and closestNodeSL="
					+ (closestNodeSL == null ? "null" : ""
							+ closestNodeSL.getNodeID())
					+ " and predecessor (only if it precedes given ID)="
					+ (predecessorIfAppropriate == null ? "null" : ""
							+ predecessorIfAppropriate.getNodeID()));
		}
		return closestNode;
	}

	/**
	 * Adds the given node reference to the finger table and successor list, if
	 * appropriate. The reference is NOT set as predecessor, even if is closer
	 * to this node. Therefore use {@link #addReferenceAsPredecessor(Node)}.
	 * 
	 * @param newReference
	 *            Reference to be added to the local data structures.
	 * @throws NullPointerException
	 *             If the given reference is null.
	 */
	final synchronized void addReference(Node newReference) {

		if (newReference == null) {
			NullPointerException e = new NullPointerException(
					"Node reference to be added must not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}

		boolean debug = this.logger.isEnabledFor(DEBUG);
		// June 21, 2006. Moved here by sven to avoid failing of checkIfProxy()
		if (newReference.getNodeID().equals(this.localID)) {
			if (debug) {
				this.logger.debug("Reference on myself was not added");
			}
			return;
		}

		// check parameters
		this.checkIfProxy(newReference);

		this.fingerTable.addReference(newReference);
		this.successorList.addSuccessor(newReference);

		if (debug) {
			this.logger.debug("Attempted to add reference "

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲精品bt天堂精选| 国产精品一区二区91| 国产真实乱偷精品视频免| 韩国午夜理伦三级不卡影院| 99国产精品久| 精品国产伦一区二区三区免费 | 精品久久久网站| 亚洲最大成人综合| 国产精品 欧美精品| 欧美一级艳片视频免费观看| 一色屋精品亚洲香蕉网站| 韩国成人在线视频| 欧美久久久久中文字幕| 亚洲免费视频中文字幕| 风间由美一区二区av101| 精品少妇一区二区三区日产乱码| 亚洲免费av在线| 99精品国产99久久久久久白柏 | 天堂av在线一区| 欧美性videosxxxxx| 亚洲激情校园春色| 色综合久久88色综合天天6| 国产精品美女久久久久aⅴ| 国产麻豆成人精品| 久久久777精品电影网影网| 久久99久久久久| 欧美一卡二卡在线| 日本不卡不码高清免费观看 | 精品国免费一区二区三区| 婷婷开心久久网| av在线综合网| 亚洲欧美日韩在线| 91农村精品一区二区在线| 亚洲男同1069视频| 欧美日韩在线三区| 亚洲精品一卡二卡| 99综合影院在线| 国产尤物一区二区| 精品国产一区a| 亚洲欧美日韩在线| 久久精品国产色蜜蜜麻豆| eeuss鲁片一区二区三区| 久久看人人爽人人| 国产精品传媒入口麻豆| 日韩欧美电影在线| 亚洲成人av在线电影| 欧美日韩aaa| 国产米奇在线777精品观看| 国产精品久久毛片a| 欧美日韩在线观看一区二区| 日韩高清不卡在线| 国产欧美日韩在线视频| 色综合久久综合中文综合网| 国产清纯白嫩初高生在线观看91| 一个色综合av| 欧美一区二区三区婷婷月色| 风间由美一区二区av101| 亚洲6080在线| 91精品国产91久久久久久最新毛片| 国产一区高清在线| 亚洲九九爱视频| 久久视频一区二区| 欧美日韩一级视频| 成人激情午夜影院| 美女视频一区二区三区| 国产日韩影视精品| 欧美男女性生活在线直播观看| 成人丝袜视频网| 麻豆成人在线观看| 亚洲18影院在线观看| 国产精品丝袜久久久久久app| 91精品国产福利| 欧美日韩亚洲综合在线 | 国产欧美精品一区aⅴ影院| 欧美日韩综合色| 91麻豆产精品久久久久久| 日日摸夜夜添夜夜添亚洲女人| 国产亚洲一区二区三区四区| 欧美精品三级日韩久久| 欧美中文字幕不卡| 91福利国产精品| 色综合亚洲欧洲| 欧美视频在线一区二区三区 | 精品国产一区二区在线观看| 欧美一区二区高清| 欧美一级艳片视频免费观看| 欧美高清性hdvideosex| 欧美人狂配大交3d怪物一区| 欧美欧美欧美欧美| 欧美一区二区三区影视| 日韩你懂的在线播放| 久久久五月婷婷| 国产精品乱码人人做人人爱 | 亚洲欧美日韩久久精品| 亚洲精品视频在线观看网站| 日韩一区欧美一区| 一区二区三区 在线观看视频| 亚洲国产视频在线| 免费在线观看一区| 国产一区二区三区久久悠悠色av| 国产成人亚洲综合a∨婷婷| 成人av在线资源网| 欧美三级三级三级| 欧美一卡二卡三卡四卡| 欧美不卡一区二区三区四区| 91精品国产色综合久久不卡蜜臀| 欧美日韩综合色| 国产日本欧洲亚洲| 亚洲国产日韩a在线播放性色| 亚洲成人高清在线| 日本视频中文字幕一区二区三区| 国产精品综合视频| 在线亚洲+欧美+日本专区| 91精品午夜视频| 国产精品欧美一区喷水| 91在线视频观看| 日韩午夜精品电影| 亚瑟在线精品视频| 91一区二区在线| 久久精品在线免费观看| 精品一区二区三区免费| 欧美日韩国产美| 亚洲精品一二三| 97久久超碰国产精品电影| 欧美韩国日本一区| 国产成人综合自拍| 欧美mv日韩mv国产网站| 免费观看在线色综合| 欧美日韩中文一区| 亚洲成人在线网站| 欧美日韩中文字幕精品| 午夜在线电影亚洲一区| 色婷婷国产精品| 亚洲一区在线观看网站| 欧美日韩成人在线一区| 日韩经典中文字幕一区| 91精品国产91久久久久久一区二区 | 国产麻豆成人传媒免费观看| 欧美情侣在线播放| 日韩高清不卡一区二区三区| 欧美一级电影网站| 国内外成人在线| 1区2区3区国产精品| 欧美综合在线视频| 五月激情丁香一区二区三区| 777午夜精品免费视频| 捆绑紧缚一区二区三区视频| 久久久精品黄色| 色综合天天综合色综合av| 亚洲五码中文字幕| 久久人人97超碰com| 91视频一区二区| 天堂成人国产精品一区| 久久尤物电影视频在线观看| 99久久国产综合色|国产精品| 亚洲一区二区高清| 久久婷婷国产综合国色天香| 99久久免费国产| 免费成人美女在线观看.| 中文字幕av资源一区| 欧美影院精品一区| 国产成人免费视频| 图片区小说区国产精品视频| 久久久99精品免费观看不卡| 一本色道久久综合亚洲91| 久久99精品久久久久| 亚洲影视资源网| 国产亚洲一区字幕| 欧美丰满嫩嫩电影| 99精品久久只有精品| 久久99精品视频| 天堂午夜影视日韩欧美一区二区| 中文字幕欧美国产| 91麻豆精品国产| 91久久久免费一区二区| 国产精品资源网站| 老司机免费视频一区二区三区| 亚洲精品你懂的| 国产精品伦理在线| 国产日韩欧美在线一区| 精品久久久久久久久久久久包黑料 | 亚洲第一av色| 亚洲精品综合在线| 国产精品麻豆网站| 国产精品久久三| 国产欧美日韩激情| 国产日韩v精品一区二区| 精品99999| 欧美一级午夜免费电影| 91麻豆精品国产综合久久久久久| 91电影在线观看| 在线视频欧美区| 欧美日韩免费视频| 欧美日韩免费在线视频| 欧美日韩第一区日日骚| 91精品久久久久久久99蜜桃| 制服丝袜中文字幕一区| 日韩欧美你懂的| 国产精品网曝门| 中文字幕视频一区|