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

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

?? requesthandler.java

?? Chord package into p2psim
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************************
 *                                                                         *
 *                            RequestHandler.java                          *
 *                            -------------------                          *
 *   date                 : 02.09.2004, 14:02                              *
 *   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        *
 *                                                                         *
 ***************************************************************************/

/*
 * RequestHandler.java
 *
 * Created on 2. September 2004, 14:02
 */

package de.uniba.wiai.lspi.chord.com.socket;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.Socket;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import de.uniba.wiai.lspi.chord.com.CommunicationException;
import de.uniba.wiai.lspi.chord.com.Endpoint;
import de.uniba.wiai.lspi.chord.com.EndpointStateListener;
import de.uniba.wiai.lspi.chord.com.Entry;
import de.uniba.wiai.lspi.chord.com.Node;
import de.uniba.wiai.lspi.chord.com.RefsAndEntries;
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.*;

/**
 * This class handles {@link Request requests} for a single incoming connection
 * from another node sent through a {@link SocketProxy proxy} that represents
 * the local node at the remote node.
 * 
 * @author sven
 * @version 1.0.5
 */
final class RequestHandler extends Thread implements EndpointStateListener {

	/**
	 * Logger for this class.
	 */
	private static Logger logger = Logger.getLogger(RequestHandler.class);

	/**
	 * The node this RequestHandler invokes methods on.
	 */
	private Node node;

	/**
	 * The socket over that this RequestHandler receives requests.
	 */
	private Socket connection;

	/**
	 * {@link ObjectOutputStream}to write answers to.
	 */
	private ObjectOutputStream out;

	/**
	 * {@link ObjectInputStream}to read {@link Request requests}from.
	 */
	private ObjectInputStream in;

	/**
	 * Indicates if this RequestHandler is connected. Used in {@link #run()} to
	 * determine if this is still listening for requests.
	 */
	boolean connected = true;

	/**
	 * The state that the {@link SocketEndpoint endpoint}, that started this
	 * request handler, is currently in. See constants of class
	 * {@link de.uniba.wiai.lspi.chord.com.Endpoint}.
	 */
	private int state;

	/**
	 * The {@link SocketEndpoint endpoint}that started this handler.
	 */
	private SocketEndpoint endpoint;

	/**
	 * This {@link Vector}contains {@link Thread threads}waiting for a state
	 * of the {@link SocketEndpoint endpoint}that permits the execution of the
	 * methods the threads are about to execute. This is also used as
	 * synchronization variable for these threads.
	 */
	private Set<Thread> waitingThreads = new HashSet<Thread>();

	/**
	 * Creates a new instance of RequestHandler
	 * 
	 * @param node_
	 *            The {@link Node node}to delegate requested methods to.
	 * @param connection_
	 *            The {@link Socket}over which this receives requests.
	 * @param ep
	 * @throws IOException 
	 * 
	 * @throws IOException
	 *             Thrown if the establishment of a connection over the provided
	 *             socket fails.
	 */
	RequestHandler(Node node_, Socket connection_, SocketEndpoint ep) throws IOException {
		super("RequestHandler_" + ep.getURL());

		if (RequestHandler.logger.isEnabledFor(INFO)) {
			RequestHandler.logger.info("Initialising RequestHandler. Socket "
					+ connection_ + ", " + ", Endpoint " + ep);
		}
		// logger = Logger.getLogger(this.getClass().toString() +
		// connection.toString());
		this.node = node_;
		this.connection = connection_;
		this.out = new ObjectOutputStream(this.connection.getOutputStream());
		try {
			this.in = new ObjectInputStream(this.connection.getInputStream());
		} catch (IOException e1) {
			out.close(); 
			throw e1; 
		}
		try {
			Request r = (Request) this.in.readObject();
			if (r.getRequestType() != MethodConstants.CONNECT) {
				Response resp = new Response(Response.REQUEST_FAILED, r
						.getRequestType(), r.getReplyWith());
				try {
					out.writeObject(resp);
				} catch (IOException e) {
				}
				try {
					out.close();
				} catch (IOException e) {}
				try {
					in.close();
				} catch (IOException e) {} 
				throw new IOException("Unexpected Message received! " + r);
			} else {
				Response resp = new Response(Response.REQUEST_SUCCESSFUL, r
						.getRequestType(), r.getReplyWith());
				out.writeObject(resp); 
			}
		} catch (ClassNotFoundException e) {
			throw new IOException("Unexpected class type received! " + e.getMessage()); 
		}
		this.endpoint = ep;
		this.state = this.endpoint.getState();
		this.endpoint.register(this);
		logger.info("RequestHandler initialised.");
	}

	/**
	 * Returns a reference to the endpoint this {@link RequestHandler} belongs
	 * to.
	 * 
	 * @return Reference to the endpoint this {@link RequestHandler} belongs to.
	 */
	SocketEndpoint getEndpoint() {
		return this.endpoint;
	}

	/**
	 * The task of this Thread. Listens for incoming requests send over the
	 * {@link #connection}of this thread. The thread can be stopped by invoking
	 * {@link #disconnect()}.
	 */
	@Override
	public void run() {
		/*
		 * As long as this is connected
		 */
		while (this.connected) {
			Request request = null;
			try {
				/* wait for incoming requests */
				logger.debug("Waiting for request...");
				request = (Request) this.in.readObject();
				if (request.getRequestType() == MethodConstants.SHUTDOWN) {
					logger.debug("Received shutdown request");
					this.disconnect();
				} else {
					logger.debug("Received request " + request);
					new InvocationThread(this, request, /*
														 * "Request_" +
														 * MethodConstants.getMethodName(request
														 * .getRequestType()) +
														 * "_" +
														 * request.getReplyWith(),
														 */this.out);
				}
			} catch (IOException e) {
				/*
				 * This can also occur if disconnect() is called, as the socket
				 * is closed then
				 */
				logger.debug("Exception occured while receiving a request. "
						+ "Maybe socket has been closed.");
				/* cannot do anything here but disconnect */
				this.disconnect();
			} catch (ClassNotFoundException cnf) {
				/* Should not occur as all nodes should have the same classes */
				logger.error("Exception occured while receiving a request ",
						cnf);
				/* cannot do anything here */
				this.disconnect();
			} catch (Throwable t) {
				logger
						.fatal("Unexpected throwable while receiving message!",
								t);
				this.disconnect();
			}
		}
	}

	/**
	 * Method to create failure responses and send them to the requestor.
	 * 
	 * @param t
	 * @param failure
	 * @param request
	 */
	void sendFailureResponse(Throwable t, String failure, Request request) {
		if (!this.connected) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
3d成人h动漫网站入口| 国产白丝精品91爽爽久久| 91同城在线观看| 欧美高清在线视频| 夜夜精品浪潮av一区二区三区| 国产98色在线|日韩| 欧美精品一区二区蜜臀亚洲| 亚洲中国最大av网站| 色天天综合色天天久久| 精品毛片乱码1区2区3区| 久久精品国产99| 欧美成人性战久久| 黄色小说综合网站| 日韩一卡二卡三卡国产欧美| 免费国产亚洲视频| 欧美网站一区二区| 天天综合天天综合色| 日韩一二三区不卡| 韩国欧美一区二区| 国产欧美一区二区在线观看| 理论片日本一区| 精品国产乱子伦一区| 国精产品一区一区三区mba视频| 欧美精品一区二区三区四区 | 成人午夜电影小说| 日本一区二区三区高清不卡| 99re热视频这里只精品| 偷窥少妇高潮呻吟av久久免费| 亚洲精品在线三区| 91福利精品视频| 韩国午夜理伦三级不卡影院| 亚洲少妇最新在线视频| 精品少妇一区二区三区视频免付费 | 国产精品传媒在线| 69久久99精品久久久久婷婷| 粉嫩aⅴ一区二区三区四区五区| 亚洲成人7777| 亚洲国产高清不卡| 日韩欧美国产午夜精品| 91免费视频网址| 国模大尺度一区二区三区| 一区二区三区四区不卡在线| 久久久久久久综合色一本| 欧美日韩国产经典色站一区二区三区| 国产精品夜夜嗨| 日韩不卡手机在线v区| 亚洲三级视频在线观看| 久久久精品tv| 日韩美女在线视频| 欧美日韩精品久久久| 日本精品一区二区三区四区的功能| 精品一二线国产| 亚洲h在线观看| 综合久久久久久| 中文字幕欧美激情一区| 精品国产乱码久久| 欧美一区永久视频免费观看| 日本韩国一区二区三区视频| www.av精品| 国产mv日韩mv欧美| 国产一区 二区| 男女男精品视频| 亚洲成人一区二区| 午夜精品爽啪视频| 亚洲午夜羞羞片| 亚洲午夜精品网| 亚洲最新视频在线观看| 一区二区三区在线观看网站| 国产精品九色蝌蚪自拍| 欧美激情一二三区| 国产欧美精品一区二区色综合朱莉| 日韩美女视频在线| 日韩欧美www| 久久午夜电影网| 久久女同互慰一区二区三区| 久久综合狠狠综合久久综合88| 精品欧美一区二区在线观看 | 精品福利一二区| 欧美videossexotv100| 欧美mv日韩mv亚洲| 欧美精品一区二区三区在线| 久久日韩精品一区二区五区| 久久亚洲精华国产精华液| 精品福利一二区| 国产欧美一区二区在线观看| 亚洲欧洲日韩女同| 亚洲激情在线播放| 日韩福利电影在线观看| 久久爱www久久做| 国产激情精品久久久第一区二区 | 国产精品伦一区| 亚洲欧美二区三区| 亚洲国产精品久久艾草纯爱| 日日摸夜夜添夜夜添亚洲女人| 日本欧美加勒比视频| 国产精品一卡二| 91小宝寻花一区二区三区| 在线视频欧美精品| 91精品在线免费| 久久久av毛片精品| 亚洲欧美在线视频| 亚洲成人先锋电影| 国产一区二区三区免费看| 粉嫩一区二区三区在线看| youjizz久久| 在线观看视频欧美| 精品久久久久久亚洲综合网 | 午夜欧美电影在线观看| 男人的天堂亚洲一区| 国产精品1区2区| 91捆绑美女网站| 日韩欧美一区在线| 日韩理论在线观看| 免费欧美日韩国产三级电影| 成人h版在线观看| 欧美精品aⅴ在线视频| 国产欧美视频一区二区三区| 亚洲自拍都市欧美小说| 国产精品资源在线| 欧美日韩在线播放三区| 久久久久久久久蜜桃| 一区二区三区高清不卡| 国产精品66部| 欧美精品乱码久久久久久| 国产亚洲精品aa午夜观看| 亚洲国产精品久久久男人的天堂| 懂色av一区二区三区蜜臀| 欧美猛男男办公室激情| 国产精品国产三级国产三级人妇 | 一本大道久久a久久精二百| 日韩一区二区三区免费观看| 日韩一区在线看| 极品美女销魂一区二区三区 | 色婷婷国产精品久久包臀| 欧美变态口味重另类| 亚洲国产欧美一区二区三区丁香婷| 国内精品国产成人国产三级粉色| 欧美日韩在线播放一区| 中文字幕在线视频一区| 久久 天天综合| 欧美久久一二三四区| 亚洲你懂的在线视频| 国产激情视频一区二区在线观看 | 在线播放视频一区| 亚洲人成在线观看一区二区| 国产美女av一区二区三区| 日韩一区二区麻豆国产| 三级一区在线视频先锋| 91福利社在线观看| 亚洲天堂a在线| 丁香婷婷综合激情五月色| 久久综合一区二区| 久久国产精品色| 日韩美一区二区三区| 蜜桃久久精品一区二区| 日韩欧美一级在线播放| 婷婷久久综合九色综合绿巨人| 欧洲一区在线电影| 亚洲毛片av在线| 91日韩精品一区| ...av二区三区久久精品| 成人h动漫精品一区二| 国产精品青草综合久久久久99| 国产成人日日夜夜| 国产人成一区二区三区影院| 国产一区二区三区最好精华液| 日韩欧美视频一区| 麻豆精品国产传媒mv男同| 欧美一区二区三区不卡| 久久国产尿小便嘘嘘| 日韩欧美中文字幕公布| 精品一区二区影视| 久久综合中文字幕| 大陆成人av片| 亚洲色图.com| 欧美日韩在线免费视频| 免费人成网站在线观看欧美高清| 91精品国产免费| 国产一区二区三区在线观看免费| 久久久一区二区| yourporn久久国产精品| 一区2区3区在线看| 91精品久久久久久久99蜜桃| 久久99精品国产麻豆不卡| 久久精品一区二区三区不卡| 成人自拍视频在线观看| 日韩美女啊v在线免费观看| 在线欧美日韩国产| 男女性色大片免费观看一区二区| 久久久久国产精品人| 不卡的电影网站| 亚洲国产中文字幕| 欧美电影精品一区二区| 成人aa视频在线观看| 一区二区三区日韩| 精品精品欲导航| 色噜噜狠狠一区二区三区果冻| 日韩高清不卡一区| 国产精品理伦片| 这里只有精品99re|