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

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

?? chordimpl.java

?? Chord package into p2psim
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:

		// set nodeID
		this.setID(localID1);

		// establish connection
		this.createHelp();

	}

	/**
	 * Performs all necessary tasks for creating a new Chord ring. Assumes that
	 * localID and localURL are correctly set. Is invoked by the methods
	 * {@link #create()}, {@link #create(URL)}, and {@link #create(URL, ID)}
	 * only.
	 * 
	 * @throws RuntimeException
	 */
	private final void createHelp() {

		this.logger.debug("Help method for creating a new Chord ring invoked.");

		// create local repository for entries
		this.entries = new Entries();

		// create local repository for node references
		if (NUMBER_OF_SUCCESSORS >= 1) {
			this.references = new References(this.getID(), this.getURL(), 
					NUMBER_OF_SUCCESSORS, this.entries);
		} else {
			throw new RuntimeException(
					"NUMBER_OF_SUCCESSORS intialized with wrong value! "
							+ NUMBER_OF_SUCCESSORS);
		}

		// create NodeImpl instance for communication
		this.localNode = new NodeImpl(this, this.getID(), this.localURL,
				this.references, this.entries);

		// create tasks for fixing finger table, checking predecessor and
		// stabilizing
		this.createTasks();

		// accept content requests from outside
		this.localNode.acceptEntries();

	}

	/**
	 * Creates the tasks that must be executed periodically to maintain the
	 * Chord overlay network and schedules them with help of a
	 * {@link ScheduledExecutorService}.
	 */
	private final void createTasks() {

		// start thread which periodically stabilizes with successor
		this.maintenanceTasks.scheduleWithFixedDelay(new StabilizeTask(
				this.localNode, this.references, this.entries),
				ChordImpl.STABILIZE_TASK_START,
				ChordImpl.STABILIZE_TASK_INTERVAL, TimeUnit.SECONDS);

		// start thread which periodically attempts to fix finger table
		this.maintenanceTasks.scheduleWithFixedDelay(new FixFingerTask(
				this.localNode, this.getID(), this.references),
				ChordImpl.FIX_FINGER_TASK_START,
				ChordImpl.FIX_FINGER_TASK_INTERVAL, TimeUnit.SECONDS);

		// start thread which periodically checks whether predecessor has
		// failed
		this.maintenanceTasks.scheduleWithFixedDelay(new CheckPredecessorTask(
				this.references), ChordImpl.CHECK_PREDECESSOR_TASK_START,
				ChordImpl.CHECK_PREDECESSOR_TASK_INTERVAL, TimeUnit.SECONDS);
	}

	public final void join(URL bootstrapURL) throws ServiceException {

		// check if parameters are valid
		if (bootstrapURL == null) {
			throw new NullPointerException(
					"At least one parameter is null which is not permitted!");
		}

		// is node already connected?
		if (this.localNode != null) {
			throw new ServiceException(
					"Cannot join network; node is already connected!");
		}

		// has nodeURL been set?
		if (this.localURL == null) {
			throw new ServiceException("Node URL is not set yet! Please "
					+ "set URL with help of setURL(URL) "
					+ "before invoking join(URL)!");
		}

		// if necessary, generate nodeID out of nodeURL
		if (this.getID() == null) {
			this.setID(this.hashFunction.createUniqueNodeID(this.localURL));
		}

		// establish connection
		this.joinHelp(bootstrapURL);

	}

	public final void join(URL localURL1, URL bootstrapURL)
			throws ServiceException {

		// check if parameters are valid
		if (localURL1 == null || bootstrapURL == null) {
			throw new NullPointerException(
					"At least one parameter is null which is not permitted!");
		}

		// is node already connected?
		if (this.localNode != null) {
			throw new ServiceException(
					"Cannot join network; node is already connected!");
		}

		// set nodeURL
		this.localURL = localURL1;

		// if necessary, generate nodeID out of nodeURL
		if (this.getID() == null) {
			this.setID(this.hashFunction.createUniqueNodeID(this.localURL));
		}

		// establish connection
		this.joinHelp(bootstrapURL);

	}

	public final void join(URL localURL1, ID localID1, URL bootstrapURL)
			throws ServiceException {

		// check if parameters are valid
		if (localURL1 == null || localID1 == null || bootstrapURL == null) {
			throw new NullPointerException(
					"At least one parameter is null which is not permitted!");
		}

		// is node already connected?
		if (this.localNode != null) {
			throw new ServiceException(
					"Cannot join network; node is already connected!");
		}

		// set nodeURL
		this.localURL = localURL1;

		// set nodeID
		this.setID(localID1);

		// establish connection
		this.joinHelp(bootstrapURL);

	}

	/**
	 * Performs all necessary tasks for joining an existing Chord ring. Assumes
	 * that localID and localURL are correctly set. Is invoked by the methods
	 * {@link #join(URL)}, {@link #join(URL, URL)}, and
	 * {@link #join(URL, ID, URL)} only.
	 * 
	 * @param bootstrapURL
	 *            URL of bootstrap node. Must not be null!.
	 * @throws ServiceException
	 *             If anything goes wrong during the join process.
	 * @throws RuntimeException
	 *             Length of successor list has not been initialized correctly.
	 * @throws IllegalArgumentException
	 *             <code>boostrapURL</code> is null!
	 */
	private final void joinHelp(URL bootstrapURL) throws ServiceException {

		// create local repository for entries
		this.entries = new Entries();

		// create local repository for node references
		if (NUMBER_OF_SUCCESSORS >= 1) {
			this.references = new References(this.getID(), this.getURL(), 
					NUMBER_OF_SUCCESSORS, this.entries);
		} else {
			throw new RuntimeException(
					"NUMBER_OF_SUCCESSORS intialized with wrong value! "
							+ NUMBER_OF_SUCCESSORS);
		}

		// create NodeImpl instance for communication
		this.localNode = new NodeImpl(this, this.getID(), this.localURL,
				this.references, this.entries);

		// create proxy for outgoing connection to bootstrap node
		Node bootstrapNode;
		try {
			bootstrapNode = Proxy.createConnection(this.localURL, bootstrapURL);
		} catch (CommunicationException e) {
			throw new ServiceException(
					"An error occured when creating a proxy for outgoing "
							+ "connection to bootstrap node! Join operation"
							+ "failed!", e);

		}

		// only an optimization: store reference on bootstrap node
		this.references.addReference(bootstrapNode);

		// Asking for my successor at node bootstrapNode.nodeID

		// find my successor
		Node mySuccessor;
		try {
			mySuccessor = bootstrapNode.findSuccessor(this.getID());
		} catch (CommunicationException e1) {
			throw new ServiceException("An error occured when trying to find "
					+ "the successor of this node using bootstrap node "
					+ "with url " + bootstrapURL.toString() + "! Join "
					+ "operation failed!", e1);
		}

		// store reference on my successor
		this.logger.info(this.localURL + " has successor "
				+ mySuccessor.getNodeURL());
		this.references.addReference(mySuccessor);

		// notify successor for the first time and copy keys from successor
		RefsAndEntries copyOfRefsAndEntries;
		try {
			copyOfRefsAndEntries = mySuccessor
					.notifyAndCopyEntries(this.localNode);
		} catch (CommunicationException e2) {
			throw new ServiceException("An error occured when contacting "
					+ "the successor of this node in order to "
					+ "obtain its references and entries! Join "
					+ "operation failed!", e2);
		}

		List<Node> refs = copyOfRefsAndEntries.getRefs();
		/*
		 * The first list item is the current predecessor of our successor. Now
		 * we are the predecessor, so we can assume, that it must be our
		 * predecessor. 10.06.2007 sven.
		 */
		boolean predecessorSet = false;
		int count = 0;
		while (!predecessorSet) {
			logger.debug("Size of refs: " + refs.size());
			// there is only one other peer in the network
			if (refs.size() == 1) {
				logger
						.info("Adding successor as predecessor as there are only two peers! "
								+ mySuccessor);
				this.references.addReferenceAsPredecessor(mySuccessor);
				predecessorSet = true;
				logger.debug("Actual predecessor: "
						+ this.references.getPredecessor());
			} else {
				// we got the right predecessor and successor
				if (this.getID().isInInterval(refs.get(0).getNodeID(),
						mySuccessor.getNodeID())) {
					this.references.addReferenceAsPredecessor(refs.get(0));
					predecessorSet = true;
				} else {
					/*
					 * if ID of potential predecessor is greater than ours it
					 * can be our successor...
					 */
					logger.info("Wrong successor found. Going backwards!!!");
					this.references.addReference(refs.get(0));
					try {
						copyOfRefsAndEntries = refs.get(0)
								.notifyAndCopyEntries(this.localNode);
						refs = copyOfRefsAndEntries.getRefs();
					} catch (CommunicationException e) {
						throw new ServiceException(
								"An error occured when contacting "
										+ "the successor of this node in order to "
										+ "obtain its references and entries! Join "
										+ "operation failed!", e);
					}
				}
			}
		}

		// add new references, if pings are successful //removed ping to new
		// references. 17.09.2007 sven
		for (Node newReference : copyOfRefsAndEntries.getRefs()) {
			if (newReference != null && !newReference.equals(this.localNode)
					&& !this.references.containsReference(newReference)) {

				ChordImpl.this.references.addReference(newReference);
				if (ChordImpl.this.logger.isEnabledFor(DEBUG)) {
					ChordImpl.this.logger.debug("Added reference on "
							+ newReference.getNodeID() + " which responded to "
							+ "ping request");
				}

			}
		}

		// add copied entries of successor
		this.entries.addAll(copyOfRefsAndEntries.getEntries());

		// accept content requests from outside
		this.localNode.acceptEntries();

		// create tasks for fixing finger table, checking predecessor and
		// stabilizing
		this.createTasks();
	}

	public final void leave() {

		if (this.localNode == null) {
			// ring has not been created or joined, st. leave has no effect
			return;
		}

		this.maintenanceTasks.shutdownNow();

		try {
			Node successor = this.references.getSuccessor();
			if (successor != null && this.references.getPredecessor() != null) {
				successor.leavesNetwork(this.references.getPredecessor());
			}
		} catch (CommunicationException e) {
			/*
			 * throw new ServiceException( "An unknown error occured when trying
			 * to contact the " + "successor of this node to inform it about " +
			 * "leaving! Leave operation failed!");
			 */

		}

		this.localNode.disconnect();
		this.asyncExecutor.shutdownNow();
		this.localNode = null;

	}

	public final void insert(Key key, Serializable s) {

		// check parameters
		if (key == null || s == null) {
			throw new NullPointerException(
					"Neither parameter may have value null!");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产农村妇女毛片精品久久麻豆 | 99久久久久久| 精品一区二区影视| 日本欧美久久久久免费播放网| 亚洲人午夜精品天堂一二香蕉| 国产精品亲子乱子伦xxxx裸| 久久亚洲精品国产精品紫薇| 精品国产乱码91久久久久久网站| 欧美一区欧美二区| 制服丝袜日韩国产| 91麻豆精品国产91久久久使用方法| 欧美三级日韩三级国产三级| 欧美欧美欧美欧美首页| 欧美肥妇bbw| 日韩一区二区在线看| 精品国产亚洲一区二区三区在线观看| 欧美va在线播放| 亚洲精品一区二区三区99| 欧美精品一区二区三区蜜桃| 久久综合狠狠综合| 中文字幕不卡在线| 亚洲少妇屁股交4| 亚洲一区二区精品3399| 丝袜美腿一区二区三区| 精品午夜久久福利影院| 国产成都精品91一区二区三| 97久久精品人人澡人人爽| 欧洲色大大久久| 51精品视频一区二区三区| 精品久久一区二区| 国产精品高潮呻吟| 亚洲一区视频在线观看视频| 日韩精品成人一区二区在线| 成人动漫精品一区二区| 色欧美片视频在线观看在线视频| 在线欧美小视频| 欧美一区二区三区男人的天堂| 2017欧美狠狠色| 日韩久久一区二区| 天天综合色天天综合| 韩国av一区二区三区在线观看| 成人免费视频视频| 精品视频色一区| 久久免费视频色| 亚洲视频中文字幕| 奇米精品一区二区三区在线观看 | 国产欧美精品国产国产专区| 亚洲女同ⅹxx女同tv| 日本午夜精品视频在线观看| 成人午夜视频网站| 欧美另类久久久品| 中文字幕精品综合| 亚洲成人av免费| 国产一区二区三区在线观看免费 | 成人av在线播放网址| 欧美亚洲丝袜传媒另类| 日韩精品一区二区三区蜜臀| 亚洲欧美自拍偷拍色图| 美国精品在线观看| 97成人超碰视| 精品国产免费人成在线观看| 亚洲日穴在线视频| 久久超级碰视频| 色域天天综合网| 久久久久88色偷偷免费| 夜夜夜精品看看| 男男成人高潮片免费网站| a4yy欧美一区二区三区| 欧美一区二区二区| 亚洲欧美另类综合偷拍| 黑人精品欧美一区二区蜜桃 | 国产精品福利一区二区| 美美哒免费高清在线观看视频一区二区 | 成人黄色综合网站| 日韩美女视频在线| 亚洲成人免费在线| bt欧美亚洲午夜电影天堂| 精品粉嫩aⅴ一区二区三区四区| 一区二区三区自拍| 国产69精品一区二区亚洲孕妇| 91精品国产综合久久久蜜臀粉嫩| 亚洲欧美日韩国产一区二区三区| 国产精品一区二区久久不卡| 欧美一区二区三区小说| 亚洲综合久久av| 91丨九色丨尤物| 国产日产亚洲精品系列| 久久精品国产99久久6| 欧美日韩久久不卡| 亚洲另类一区二区| 不卡视频一二三四| 国产欧美日韩激情| 国产在线一区观看| 精品国产麻豆免费人成网站| 免费成人在线影院| 欧美一级搡bbbb搡bbbb| 天天爽夜夜爽夜夜爽精品视频| 91久久国产最好的精华液| 亚洲四区在线观看| 99精品视频在线观看| 国产精品美女久久久久久久久久久| 精东粉嫩av免费一区二区三区| 日韩一区二区影院| 奇米影视一区二区三区| 欧美一区二区三区免费| 日本亚洲天堂网| 91精品国产乱码久久蜜臀| 三级亚洲高清视频| 日韩午夜在线影院| 美女爽到高潮91| 精品乱人伦一区二区三区| 国产真实乱子伦精品视频| 国产亚洲精久久久久久| 国产成a人亚洲| 国产精品国产馆在线真实露脸| 91伊人久久大香线蕉| 一区二区三区四区在线播放| 在线观看免费亚洲| 三级在线观看一区二区| 精品理论电影在线观看 | 色一区在线观看| 亚洲综合成人在线视频| 欧美老年两性高潮| 久久精品国产精品青草| 中文字幕第一区二区| 91丝袜美腿高跟国产极品老师 | 97久久久精品综合88久久| 亚洲伦理在线精品| 欧美精品自拍偷拍动漫精品| 日韩成人av影视| 国产亚洲人成网站| 91色porny| 午夜久久久影院| 精品国产乱码久久久久久闺蜜| 成人性生交大片免费看在线播放 | 亚洲成a人在线观看| 日韩一区二区三区视频在线| 国产一区二区0| 亚洲色图.com| 日韩一区二区免费在线电影| 国产黄色成人av| 一区2区3区在线看| 日韩欧美在线影院| 不卡电影免费在线播放一区| 亚洲黄色在线视频| 欧美不卡一区二区| 91在线免费看| 日本亚洲电影天堂| 中文字幕一区二| 欧美一区二区三区免费大片| 成人白浆超碰人人人人| 亚洲成人av一区二区三区| 久久久美女毛片| 欧美视频在线一区二区三区| 国产一区二区三区综合| 亚洲综合在线第一页| 欧美精品一区二区三区久久久| 99在线精品观看| 美女视频黄免费的久久| 亚洲人成影院在线观看| 日韩无一区二区| 色域天天综合网| 国产一二精品视频| 午夜精品一区二区三区免费视频| 国产欧美视频一区二区三区| 欧美精品第1页| 99久久精品国产一区| 久久99精品网久久| 亚洲一区二区三区四区五区黄| 国产欧美日韩精品在线| 日韩欧美综合在线| 欧美色图片你懂的| 99免费精品视频| 国产一区二区精品久久| 奇米精品一区二区三区四区| 亚洲色大成网站www久久九九| 久久蜜臀精品av| 日韩美女天天操| 7777精品伊人久久久大香线蕉最新版 | av一本久道久久综合久久鬼色| 蜜桃视频第一区免费观看| 亚洲与欧洲av电影| 国产精品第五页| 久久久久久久久蜜桃| 91精品国产综合久久蜜臀| 欧美亚州韩日在线看免费版国语版| 床上的激情91.| 国产成a人亚洲精| 激情成人午夜视频| 蜜臀精品一区二区三区在线观看| 亚洲在线观看免费| 亚洲综合成人在线| 亚洲精选视频在线| 国产精品久久久久久久久久久免费看| 欧美成人一区二区三区片免费| 欧美高清视频在线高清观看mv色露露十八| 91一区二区三区在线播放| 成人av网址在线观看| 国产成人精品亚洲日本在线桃色| 国产综合色精品一区二区三区|