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

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

?? successorlist.java

?? Chord package into p2psim
?? JAVA
字號(hào):
/***************************************************************************
 *                                                                         *
 *                            SuccessorList.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 java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
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.data.ID;
import de.uniba.wiai.lspi.util.logging.Logger;
import static de.uniba.wiai.lspi.util.logging.Logger.LogLevel.*;

/**
 * Stores references on the next nodes in the Chord ring and provides methods
 * for querying and manipulating this list.
 * 
 * @author Karsten Loesing
 * @version 1.0.5
 */
final class SuccessorList {

	/**
	 * List storing the successor references in correct order.
	 */
	private List<Node> successors = null;

	/**
	 * Local node ID - initialized in constructor.
	 */
	private ID localID;

	/**
	 * Maximum number of references - initialized in constructor.
	 */
	private int capacity;

	/**
	 * Reference on parent object of type References.
	 */
	private References references;

	/**
	 * Reference on Entries.
	 */
	private Entries entries;

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

	/**
	 * Creates an empty list of successors.
	 * 
	 * @param localID
	 *            This node's ID; is used for comparison operations of other
	 *            node references.
	 * @param numberOfEntries
	 *            Number of entries to be stored in this successor list.
	 * @param parent
	 *            Reference on this objects parent.
	 * @param entries
	 *            Reference on the entry repository for replication purposes.
	 */
	SuccessorList(ID localID, int numberOfEntries, References parent,
			Entries entries) {
		this.logger = Logger.getLogger(SuccessorList.class + "." + localID);
		this.logger.debug("Logger initialized.");
		if (localID == null || parent == null || entries == null) {
			NullPointerException e = new NullPointerException(
					"Neither paremeter of this constructor may have value "
							+ "null!");
			this.logger.error("Null pointer", e);
			throw e;
		}
		if (numberOfEntries < 1) {
			throw new IllegalArgumentException(
					"SuccessorList has to be at least of length 1! "
							+ numberOfEntries + "is not a valid value!");
		}
		this.localID = localID;
		this.capacity = numberOfEntries;
		this.successors = new LinkedList<Node>();
		this.references = parent;
		this.entries = entries;

	}

	/**
	 * Adds a successor references, preserving ordering of list elements.
	 * 
	 * @param nodeToAdd
	 *            Reference to be added.
	 * @throws NullPointerException
	 *             If node to add is <code>null</code>.
	 */
	final void addSuccessor(Node nodeToAdd) {

		// check parameters
		if (nodeToAdd == null) {
			NullPointerException e = new NullPointerException(
					"Parameter may not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}

		boolean debug = logger.isEnabledFor(DEBUG);
		boolean info = logger.isEnabledFor(INFO);
		// is reference already contained in successor list?
		if (this.successors.contains(nodeToAdd)) {
			if (debug) {
				this.logger.debug("Reference to new node "
						+ nodeToAdd.toString()
						+ " is not added to successor list, because it is "
						+ "already contained.");
			}
			return;
		}

		// if new ID is between last ID in list and this node's own ID _AND_
		// successor list already has maximum allowed list, the new reference IS
		// NOT added!
		if (this.successors.size() >= this.capacity
				&& nodeToAdd.getNodeID().isInInterval(
						this.successors.get(this.successors.size() - 1)
								.getNodeID(), this.localID)) {
			// do nothing
			if (debug) {
				this.logger.debug("Reference to new node "
						+ nodeToAdd.toString()
						+ " is not added to successor list, because the "
						+ "list is already full and the new reference is "
						+ "further away from the local node than all other "
						+ "successors.");
			}
			return;
		}

		// insert node to successors

		// insert before an existing element?
		boolean inserted = false;

		for (int i = 0; i < this.successors.size() && !inserted; i++) {
			if (nodeToAdd.getNodeID().isInInterval(this.localID,
					this.successors.get(i).getNodeID())) {
				this.successors.add(i, nodeToAdd);
				if (info) {
					this.logger.info("Added new reference at position " + i);
				}
				inserted = true;
			}
		}

		// insert at end if list not long enough
		if (!inserted) {
			this.successors.add(nodeToAdd);
			if (info) {
				this.logger.info("Added new reference to end of list");
			}
			inserted = true;
		}

		// determine ID range of entries this node is responsible for
		// and replicate them on new node
		ID fromID;
		Node predecessor = this.references.getPredecessor();
		if (predecessor != null) {
			// common case: have a predecessor
			fromID = predecessor.getNodeID();
		} else {
			// have no predecessor
			// do I have any preceding node?
			Node precedingNode = this.references
					.getClosestPrecedingNode(this.localID);
			if (precedingNode != null) {
				// use ID of preceding node
				fromID = precedingNode.getNodeID();
			} else {
				// use own ID (leads to replicating the whole ring); should not
				// happen
				fromID = this.localID;
			}
		}

		// replicate entries from determined ID up to local ID
		ID toID = this.localID;
		Set<Entry> entriesToReplicate = this.entries.getEntriesInInterval(
				fromID, toID);
		try {
			nodeToAdd.insertReplicas(entriesToReplicate);
			this.logger.debug("Inserted replicas to new reference");
		} catch (CommunicationException e) {
			this.logger.warn("Entries could not be replicated to node "
					+ nodeToAdd + "!", e);
		}

		// remove last element from this.successors, if maximum exceeded

		if (this.successors.size() > this.capacity) {
			Node nodeToDelete = this.successors.get(this.successors.size() - 1);
			this.successors.remove(nodeToDelete);

			// determine ID range of entries this node is responsible
			// for and remove replicates of them from discarded successor
			// 
			// Could be replaced by a new method:
			// nodeToDelete.removeReplicas(fromID, toID);
			// Set<Entry> replicatedEntries = this.entries.getEntriesInInterval(
			// fromID, toID);
			try {
				// remove all replicas!
				nodeToDelete.removeReplicas(this.localID, new HashSet<Entry>());
				this.logger.debug("Removed replicas from node " + nodeToDelete);
			} catch (CommunicationException e) {
				this.logger.warn("Replicas of entries could not be removed "
						+ "from node " + nodeToDelete + "!", e);
			}

			if (debug) {
				this.logger.debug("If no other reference to node "
						+ nodeToDelete
						+ " exists any more, it is disconnected.");
			}
			this.references.disconnectIfUnreferenced(nodeToDelete);
		}

	}

	/**
	 * Removes a successor reference without leaving a gap in the list
	 * 
	 * @param nodeToDelete
	 *            Reference to be removed.
	 * @throws NullPointerException
	 *             If reference to remove is <code>null</code>.
	 */
	final void removeReference(Node nodeToDelete) {
		if (nodeToDelete == null) {
			NullPointerException e = new NullPointerException(
					"Reference to remove may not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}
		this.successors.remove(nodeToDelete);

		// try to add references of finger table to fill 'hole' in successor
		// list
		List<Node> referencesOfFingerTable = this.references
				.getFirstFingerTableEntries(this.capacity);
		referencesOfFingerTable.remove(nodeToDelete);
		for (Node referenceToAdd : referencesOfFingerTable) {
			this.addSuccessor(referenceToAdd);
		}
	}

	/**
	 * Returns an unmodifiable copy of the ordered successor list, starting with
	 * the closest following node.
	 * 
	 * @return Unmodifiable copy of successor list.
	 */
	final List<Node> getReferences() {
		return Collections.unmodifiableList(this.successors);
	}

	/**
	 * Returns a string representation of this successor list.
	 * 
	 * @return String representation of list.
	 */
	public final String toString() {
		StringBuilder result = new StringBuilder("Successor List:\n");
		for (Node next : this.successors) {
			result.append("  " + next.getNodeID().toString() + ", "
					+ next.getNodeURL() + "\n");
		}
		return result.toString();
	}

	/**
	 * Returns closest preceding node of given ID.
	 * 
	 * @param idToLookup
	 *            ID of which closest preceding node is sought-after.
	 * @throws NullPointerException
	 *             If ID to look up is <code>null</code>.
	 * @return Reference on closest preceding node of given ID.
	 */
	final Node getClosestPrecedingNode(ID idToLookup) {

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

		for (int i = this.successors.size() - 1; i >= 0; i--) {
			Node nextNode = this.successors.get(i);
			if (nextNode.getNodeID().isInInterval(this.localID, idToLookup)) {
				return nextNode;
			}
		}

		return null;
	}

	/**
	 * Determines if the given reference is contained in this successor list.
	 * 
	 * @param nodeToLookup
	 *            Reference to look up.
	 * @throws NullPointerException
	 *             If node to look up is <code>null</code>.
	 * @return <code>true</code>, if reference is contained, and
	 *         <code>false</code>, else.
	 */
	final boolean containsReference(Node nodeToLookup) {
		if (nodeToLookup == null) {
			NullPointerException e = new NullPointerException(
					"Node to look up may not be null!");
			this.logger.error("Null pointer", e);
			throw e;
		}
		return this.successors.contains(nodeToLookup);
	}

	/**
	 * Returns the reference on the direct successor; may be <code>null</code>,
	 * if the list is empty.
	 * 
	 * @return Direct successor (or <code>null</code> if list is empty).
	 */
	final Node getDirectSuccessor() {
		if (this.successors.size() == 0) {
			return null;
		}
		return this.successors.get(0);
	}

	/**
	 * @return the capacity
	 */
	final int getCapacity() {
		return capacity;
	}

	final int getSize() {
		return this.successors.size();
	}

}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一卡2卡三卡4卡5免费| 国产日韩亚洲欧美综合| 久久综合久久鬼色中文字| 日本一区二区三区免费乱视频| 中文字幕在线不卡一区| 日韩av午夜在线观看| 北条麻妃国产九九精品视频| 91精品国产综合久久久久久漫画| 国产欧美日韩一区二区三区在线观看| 一个色妞综合视频在线观看| 国产成人亚洲精品狼色在线| 欧美一二三四区在线| 亚洲一区二区四区蜜桃| 成人精品免费看| 精品久久国产字幕高潮| 亚洲一区二区三区三| 成人午夜电影久久影院| 2023国产一二三区日本精品2022| 亚洲一卡二卡三卡四卡| 99国产精品国产精品毛片| 久久九九久久九九| 国产综合一区二区| 91精品中文字幕一区二区三区| 综合网在线视频| 大桥未久av一区二区三区中文| 精品美女一区二区三区| 日本韩国视频一区二区| 国产清纯在线一区二区www| 极品美女销魂一区二区三区 | 色网站国产精品| 久久精品亚洲国产奇米99| 蜜桃久久精品一区二区| 欧美日韩三级一区| 亚洲影视在线观看| 在线观看免费成人| 亚洲一区二区不卡免费| 欧美日韩一区二区三区在线 | 26uuu久久综合| 日韩va欧美va亚洲va久久| 欧美体内she精视频| 亚洲成人一区二区在线观看| 欧美乱妇一区二区三区不卡视频| 五月婷婷欧美视频| 7777精品伊人久久久大香线蕉超级流畅 | 国产成人免费高清| 欧美国产激情二区三区| 成人免费观看av| 国产精品久久久99| 91视频免费观看| 夜夜爽夜夜爽精品视频| 欧美日韩黄色一区二区| 视频一区在线视频| 日韩视频免费观看高清完整版在线观看| 舔着乳尖日韩一区| 日韩免费性生活视频播放| 麻豆精品久久精品色综合| 精品国产乱码久久久久久图片 | 一卡二卡欧美日韩| 欧美绝品在线观看成人午夜影视 | 亚洲一区二区三区不卡国产欧美| 欧美优质美女网站| 美腿丝袜在线亚洲一区| 久久久不卡影院| 91美女精品福利| 日韩av成人高清| 久久奇米777| 色婷婷久久久久swag精品| 丝袜亚洲另类欧美| 26uuu国产日韩综合| 成人精品一区二区三区中文字幕| 一级中文字幕一区二区| 久久蜜桃av一区二区天堂| 91国产免费看| 国产一区不卡精品| 亚洲高清中文字幕| 日本一区二区高清| 欧美日韩二区三区| 懂色中文一区二区在线播放| 亚洲成人av在线电影| 国产欧美精品一区二区色综合 | 久久久久久影视| 色婷婷av一区| 国产99久久久国产精品潘金网站| 亚洲第一搞黄网站| 亚洲国产成人私人影院tom| 538在线一区二区精品国产| 国产美女精品人人做人人爽| 亚洲色图都市小说| 精品福利一区二区三区| 欧美日高清视频| av电影一区二区| 狠狠色狠狠色综合| 青娱乐精品在线视频| 亚洲一级二级三级| 国产精品国产三级国产aⅴ原创 | 久久99精品网久久| 亚洲国产日产av| 国产精品亲子乱子伦xxxx裸| 欧美一级生活片| 欧美日韩免费电影| 色av成人天堂桃色av| 成人精品一区二区三区四区| 国产精品一线二线三线精华| 免费在线看一区| 日精品一区二区| 亚洲国产精品久久人人爱| 亚洲欧美在线视频观看| 国产精品无人区| 国产偷国产偷亚洲高清人白洁| 精品少妇一区二区三区免费观看| 88在线观看91蜜桃国自产| 欧美日韩三级视频| 欧美精品少妇一区二区三区| 欧美丝袜丝交足nylons图片| 欧美视频精品在线观看| 欧美艳星brazzers| 欧美日韩你懂得| 欧美伦理电影网| 91精品国产色综合久久不卡电影| 在线播放91灌醉迷j高跟美女| 欧美日本一区二区三区| 欧美日韩激情一区二区| 91精品国产91久久综合桃花| 日韩一级片在线播放| 日韩免费视频一区二区| 久久综合网色—综合色88| 久久久久久久国产精品影院| 国产欧美一区二区在线| 中文字幕免费观看一区| 亚洲日本在线观看| 亚洲综合成人在线视频| 亚欧色一区w666天堂| 免费高清在线视频一区·| 九九九久久久精品| 成人性生交大合| 欧洲精品中文字幕| 日韩精品一区二区三区老鸭窝| 欧美精品一区二区久久婷婷| 国产拍揄自揄精品视频麻豆| 亚洲欧美日韩综合aⅴ视频| 无吗不卡中文字幕| 久久综合综合久久综合| 国产69精品一区二区亚洲孕妇| 99久久国产综合精品色伊| 欧美日韩夫妻久久| 国产色91在线| 亚洲一区在线观看免费观看电影高清 | 亚洲视频在线一区二区| 亚洲不卡一区二区三区| 国产中文字幕精品| 欧洲精品一区二区| www欧美成人18+| 一区二区三区资源| 韩国毛片一区二区三区| 一本到不卡精品视频在线观看| 欧美一级搡bbbb搡bbbb| 亚洲欧洲另类国产综合| 亚洲va在线va天堂| 国产不卡视频在线播放| 欧美日韩极品在线观看一区| 国产亚洲精久久久久久| 亚洲一区二区三区四区五区黄| 国产制服丝袜一区| 欧美日韩一区久久| 日本一区二区电影| 日韩经典中文字幕一区| caoporn国产一区二区| 欧美一区二区三区的| 一区二区三区在线看| 国产精品1024久久| 欧美丰满美乳xxx高潮www| 国产精品美女一区二区三区| 蜜桃视频一区二区| 在线视频你懂得一区二区三区| 久久噜噜亚洲综合| 青青草97国产精品免费观看 | 免费高清不卡av| 欧洲人成人精品| 中文字幕av一区二区三区免费看| 日韩电影在线免费看| 色婷婷狠狠综合| 亚洲欧洲一区二区在线播放| 国产主播一区二区| 日韩美女在线视频| 日韩激情一二三区| 欧美中文字幕一区| 国产精品福利在线播放| 国产寡妇亲子伦一区二区| 2023国产精品视频| 紧缚捆绑精品一区二区| 日韩一区二区视频| 奇米影视一区二区三区小说| 欧美日本在线播放| 亚洲第一主播视频| 一本大道av一区二区在线播放| 国产精品理论在线观看| 东方aⅴ免费观看久久av| 久久久久久免费网| 国产一区不卡精品| 亚洲国产精品精华液ab|