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

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

?? requesthandler.java

?? Chord package into p2psim
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
			return;
		}
		logger.debug("Trying to send failure response. Failure reason "
				+ failure);
		Response failureResponse = new Response(Response.REQUEST_FAILED,
				request.getRequestType(), request.getReplyWith());
		failureResponse.setFailureReason(failure);
		failureResponse.setThrowable(t);
		try {
			synchronized (this.out) {
				this.out.writeObject(failureResponse);
				this.out.flush();
				this.out.reset();
			}
			logger.debug("Response send.");
		} catch (IOException e) {
			if (this.connected) {
				logger.debug("Connection seems to be broken down. Could not "
						+ "send failure response. Connection is closed. ", e);
				this.disconnect();
			}
		}
	}

	/**
	 * Invokes methods on {@link #node}.
	 * 
	 * @param methodType
	 *            The type of the method to invoke. See {@link MethodConstants}.
	 * @param parameters
	 *            The parameters to pass to the method.
	 * @return The result of the invoked method. May be <code>null</code> if
	 *         method is void.
	 * @throws Exception
	 */
	Serializable invokeMethod(int methodType, Serializable[] parameters)
			throws Exception {

		String method = MethodConstants.getMethodName(methodType);
		this.waitForMethod(method);
		/* If we got disconnected while waiting */
		if (!this.connected) {
			/* throw an Exception */
			throw new CommunicationException("Connection closed.");
		}
		Serializable result = null;
		logger.debug("Trying to invoke method " + methodType
				+ " with parameters: ");
		for (Serializable parameter : parameters) {
			logger.debug(parameter);
		}
		switch (methodType) {
		case MethodConstants.FIND_SUCCESSOR: {
			Node chordNode = this.node.findSuccessor((ID) parameters[0]);
			result = new RemoteNodeInfo(chordNode.getNodeURL(), chordNode.getNodeID());
			break;
		}
		case MethodConstants.GET_NODE_ID: {
			result = this.node.getNodeID();
			break;
		}
		case MethodConstants.INSERT_ENTRY: {
			this.node.insertEntry((Entry) parameters[0]);
			break;
		}
		case MethodConstants.INSERT_REPLICAS: {
			this.node.insertReplicas((Set<Entry>) parameters[0]);
			break;
		}
		case MethodConstants.LEAVES_NETWORK: {
			RemoteNodeInfo nodeInfo = (RemoteNodeInfo) parameters[0];
			this.node.leavesNetwork(SocketProxy.create(nodeInfo.getNodeURL(),
					this.node.getNodeURL(), nodeInfo.getNodeID()));
			break;
		}
		case MethodConstants.NOTIFY: {
			RemoteNodeInfo nodeInfo = (RemoteNodeInfo) parameters[0];
			List<Node> l = this.node.notify(SocketProxy.create(nodeInfo
					.getNodeURL(), this.node.getNodeURL(), nodeInfo.getNodeID()));
			List<RemoteNodeInfo> nodeInfos = new LinkedList<RemoteNodeInfo>();
			for (Node current : l) {
				nodeInfos.add(new RemoteNodeInfo(current.getNodeURL(),
						current.getNodeID()));
			}
			result = (Serializable) nodeInfos;
			break;
		}
		case MethodConstants.NOTIFY_AND_COPY: {
			RemoteNodeInfo nodeInfo = (RemoteNodeInfo) parameters[0];
			RefsAndEntries refs = this.node.notifyAndCopyEntries(SocketProxy
					.create(nodeInfo.getNodeURL(), this.node.getNodeURL(), nodeInfo
							.getNodeID()));
			List<Node> l = refs.getRefs();
			List<RemoteNodeInfo> nodeInfos = new LinkedList<RemoteNodeInfo>();
			for (Node current : l) {
				nodeInfos.add(new RemoteNodeInfo(current.getNodeURL(),
						current.getNodeID()));
			}
			RemoteRefsAndEntries rRefs = new RemoteRefsAndEntries(refs
					.getEntries(), nodeInfos);
			result = rRefs;
			break;
		}
		case MethodConstants.PING: {
			logger.debug("Invoking ping()");
			this.node.ping();
			logger.debug("ping() invoked.");
			break;
		}
		case MethodConstants.REMOVE_ENTRY: {
			this.node.removeEntry((Entry) parameters[0]);
			break;
		}
		case MethodConstants.REMOVE_REPLICAS: {
			this.node.removeReplicas((ID) parameters[0],
					(Set<Entry>) parameters[1]);
			break;
		}
		case MethodConstants.RETRIEVE_ENTRIES: {
			result = (Serializable) this.node
					.retrieveEntries((ID) parameters[0]);
			break;
		}
		default: {
			logger.warn("Unknown method requested " + method);
			throw new Exception("Unknown method requested " + method);
		}
		}
		logger.debug("Returning result.");
		return result;
	}

	/**
	 * This method is used to block threads that want to make a method call
	 * until the method invocation is permitted by the endpoint. Invocation of a
	 * method depends on the state of the endpoint.
	 * 
	 * @param method
	 *            The name of the method to invoke. TODO: change this to another
	 *            type.
	 */
	private void waitForMethod(String method) {

		logger
				.debug(method
						+ " allowed? "
						+ !(Collections.binarySearch(
								Endpoint.METHODS_ALLOWED_IN_ACCEPT_ENTRIES,
								method) >= 0));
		synchronized (this.waitingThreads) {
			while ((!(this.state == Endpoint.ACCEPT_ENTRIES))
					&& (this.connected)
					&& ((Collections.binarySearch(
							Endpoint.METHODS_ALLOWED_IN_ACCEPT_ENTRIES, method) >= 0))) {

				Thread currentThread = Thread.currentThread();
				boolean debug = logger.isEnabledFor(DEBUG);
				if (debug) {
					logger.debug("HERE!!!" + currentThread
							+ " waiting for permission to " + "execute "
							+ method);
				}
				this.waitingThreads.add(currentThread);
				try {
					this.waitingThreads.wait();
				} catch (InterruptedException e) {
					// do nothing
				}
				if (debug) {
					logger.debug("HERE!!!" + currentThread
							+ " has been notified.");
				}
				this.waitingThreads.remove(currentThread);
			}
		}
		logger.debug("waitForMethod(" + method + ") returns!");
	}

	/**
	 * Disconnect this RequestHandler. Forces the socket, which this
	 * RequestHandler is bound to, to be closed and {@link #run()}to be
	 * stopped.
	 */
	public void disconnect() {

		logger.info("Disconnecting.");
		if (this.connected) {
			/* cause the while loop in run() method to be finished */
			/* and notify all threads waiting for execution of a method */
			synchronized (this.waitingThreads) {
				this.connected = false;
				this.waitingThreads.notifyAll();
			}
			/* release reference to node. */
			this.node = null;
			/* try to close the socket */
			try {
				synchronized (this.out) {
					this.out.close();
					this.out = null;
				}
			} catch (IOException e) {
				/* should not occur */
				/* if closing of socket fails, that does not matter!??? */
				logger.debug("Exception while closing output stream "
						+ this.out);
			}
			try {
				this.in.close();
				this.in = null;
			} catch (IOException e) {
				/* should not occur */
				/* if closing of socket fails, that does not matter!??? */
				logger.debug("Exception while closing input stream" + this.in);
			}
			try {
				logger.info("Closing socket " + this.connection);
				this.connection.close();
				this.connection = null;
				logger.info("Socket closed.");
			} catch (IOException e) {
				/* should not occur */
				/* if closing of socket fails, that does not matter!??? */
				logger.debug("Exception while closing socket "
						+ this.connection);
			}
			this.endpoint.deregister(this);
		}
		logger.debug("Disconnected.");
	}

	/**
	 * Test if this RequestHandler is disconnected
	 * 
	 * @return <code>true</code> if this is still connected to its remote end.
	 */
	public boolean isConnected() {
		return this.connected;
	}

	public void notify(int newState) {
		logger.debug("notify(" + newState + ") called.");
		this.state = newState;
		/* notify all threads waiting for a state change */
		synchronized (this.waitingThreads) {
			logger.debug("HERE!!! Notifying waiting threads. "
					+ this.waitingThreads);
			this.waitingThreads.notifyAll();
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
夜夜嗨av一区二区三区网页| 欧美日韩一区二区欧美激情| 制服.丝袜.亚洲.另类.中文| 一区二区在线看| 91极品视觉盛宴| 亚洲午夜激情网页| 欧美专区亚洲专区| 日韩影视精彩在线| 欧美一区二区三区小说| 免费久久精品视频| 精品国产不卡一区二区三区| 国产乱子轮精品视频| 国产人成亚洲第一网站在线播放 | 综合久久久久综合| 一本色道**综合亚洲精品蜜桃冫 | 日韩欧美国产精品一区| 免费在线成人网| 日韩精品中文字幕一区二区三区| 免费在线观看一区二区三区| 精品国产伦一区二区三区免费| 精品无人码麻豆乱码1区2区| 久久一区二区三区国产精品| 成人精品一区二区三区中文字幕 | 国产午夜久久久久| 日本久久电影网| 激情欧美一区二区| **欧美大码日韩| 精品免费视频.| 日本久久电影网| 狠狠色综合日日| 亚洲最新视频在线观看| 国产日韩亚洲欧美综合| 欧美日韩国产在线观看| 国产91丝袜在线18| 五月婷婷色综合| 亚洲另类色综合网站| 精品国产免费人成电影在线观看四季| 91在线国产福利| 国产高清精品在线| 99视频热这里只有精品免费| 亚洲国产综合色| 国产精品丝袜一区| 国产亚洲精品超碰| 精品国产乱子伦一区| 9191国产精品| 欧美日韩不卡在线| 欧美丰满美乳xxx高潮www| 国产成人免费视频网站高清观看视频| 色综合激情五月| av网站一区二区三区| 欧美日韩一二三区| 久久亚洲一区二区三区明星换脸| 国产精品久久久久久久久久免费看| 色噜噜狠狠成人中文综合| 欧美视频在线一区二区三区| 久久亚洲一区二区三区明星换脸 | 日本一区二区成人在线| 亚洲免费色视频| 精品一区二区影视| 欧美三级蜜桃2在线观看| 久久―日本道色综合久久| 一区二区国产视频| 高清国产一区二区| 制服丝袜中文字幕一区| 亚洲激情自拍偷拍| 国产99久久久国产精品免费看 | 精品免费视频.| 国产精品女同一区二区三区| 亚洲国产成人av网| 国产91高潮流白浆在线麻豆| 欧美日韩一区 二区 三区 久久精品| 91精品国产综合久久精品| 国产精品视频在线看| 日本网站在线观看一区二区三区| 色94色欧美sute亚洲线路一ni| 欧美三电影在线| 国产精品久久久久久久久免费樱桃 | 久久精品人人爽人人爽| 美女视频黄 久久| 欧美丝袜第三区| 亚洲精品视频在线观看免费| 国内精品第一页| 精品久久久久久最新网址| 亚洲高清在线精品| 成熟亚洲日本毛茸茸凸凹| 久久网这里都是精品| 秋霞国产午夜精品免费视频| 欧美视频一区二区三区| 亚洲国产精品天堂| 色婷婷亚洲精品| 亚洲综合免费观看高清在线观看 | 狠狠色狠狠色综合| 日韩精品一区二区三区中文不卡| 亚洲一区二区视频| 色偷偷久久人人79超碰人人澡 | 久久品道一品道久久精品| 日本女人一区二区三区| 日韩欧美一区在线| 91国产免费观看| 亚洲国产日日夜夜| 日韩免费观看高清完整版在线观看| 五月婷婷另类国产| 国产欧美视频在线观看| 东方欧美亚洲色图在线| 五月天欧美精品| 精品国产凹凸成av人网站| 国产91丝袜在线观看| 亚洲欧美国产毛片在线| 欧美日韩成人综合| 久久99国内精品| 亚洲欧洲日韩av| 欧美美女一区二区在线观看| 麻豆91在线看| 曰韩精品一区二区| www激情久久| 欧美日韩国产高清一区二区三区 | 91在线播放网址| 日韩精品亚洲一区| 国产三级一区二区三区| 在线播放中文一区| 成人18视频日本| 狠狠狠色丁香婷婷综合激情| 亚洲一区在线看| 国产精品进线69影院| 欧美电视剧在线观看完整版| 在线一区二区三区做爰视频网站| 国产美女精品人人做人人爽| 亚洲一二三区在线观看| 国产精品乱人伦中文| 日韩精品中文字幕在线不卡尤物| 欧美日韩国产bt| 色8久久精品久久久久久蜜| 91在线视频免费91| 成人av网站免费| 成人av电影免费观看| 成人免费视频网站在线观看| 久久99久久99精品免视看婷婷 | 99r精品视频| 国产91精品免费| 成人一区二区三区视频在线观看 | 久久aⅴ国产欧美74aaa| 天天av天天翘天天综合网色鬼国产| 中文字幕一区二区在线观看| 亚洲嫩草精品久久| 亚洲国产日日夜夜| 国产精品99久| 7777精品久久久大香线蕉| 国产精品视频yy9299一区| 日本三级亚洲精品| 99精品欧美一区二区三区综合在线| 91精品国产一区二区| 成人欧美一区二区三区黑人麻豆| 日韩成人午夜精品| av中文字幕亚洲| 亚洲国产成人一区二区三区| 日韩不卡在线观看日韩不卡视频| 国产91精品一区二区| 91麻豆成人久久精品二区三区| 色哦色哦哦色天天综合| 欧美一级日韩免费不卡| 国产亚洲一本大道中文在线| 一区二区三区在线视频免费| 久久精品二区亚洲w码| av午夜精品一区二区三区| 欧美日韩国产一级片| 国产精品乱码人人做人人爱| 热久久免费视频| 成人性色生活片免费看爆迷你毛片| 欧美日韩一区中文字幕| 国产精品欧美一区二区三区| 国内偷窥港台综合视频在线播放| 欧美午夜一区二区| 亚洲国产精品v| 国产自产高清不卡| 日韩三级在线观看| 日韩精品欧美成人高清一区二区| 国产成人99久久亚洲综合精品| 91精品蜜臀在线一区尤物| 亚洲国产视频一区| 欧美性淫爽ww久久久久无| 亚洲美女偷拍久久| 99精品偷自拍| 综合久久一区二区三区| 99久久久久免费精品国产| 国产精品久久久久久亚洲伦| 成人免费黄色在线| 国产精品久久网站| 成人激情图片网| 中文字幕欧美一区| 色综合激情久久| 亚洲午夜av在线| 91精品国产日韩91久久久久久| 国产精品视频线看| 国产精品久久三| 97aⅴ精品视频一二三区| 五月激情综合色| 国产精品电影院| 日韩免费一区二区三区在线播放| 成人av资源在线| 久久国产麻豆精品|