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

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

?? datamover.java

?? 簡單的分布式算法
?? JAVA
字號:
/* ***************************************************************************** * $Id: DataMover.java,v 1.5 2003/05/06 17:52:21 jheiss Exp $ ***************************************************************************** * This class passes data back and forth from clients and servers for * established connections through the load balancer. ***************************************************************************** * Copyright 2003 Jason Heiss *  * This file is part of Distributor. *  * Distributor 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. *  * Distributor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with Distributor; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA ***************************************************************************** */package oss.distributor;import java.io.IOException;import java.net.Socket;import java.nio.ByteBuffer;import java.nio.channels.Selector;import java.nio.channels.SelectionKey;import java.nio.channels.SocketChannel;import java.util.List;import java.util.Map;import java.util.HashMap;import java.util.Set;import java.util.Iterator;import java.util.logging.Logger;class DataMover implements Runnable{	Selector selector;	Logger logger;	List distributionAlgorithms;	Map clients;	Map servers;	Thread thread;	protected DataMover(Distributor distributor)	{		logger = distributor.getLogger();		distributionAlgorithms = distributor.getDistributionAlgorithms();		try		{			//logger.finer("Opening selector");			selector = Selector.open();		}		catch (IOException e)		{			logger.severe("Error creating selector: " + e.getMessage());			System.exit(1);		}		clients = new HashMap();		servers = new HashMap();		// Create a thread for ourselves and start it		thread = new Thread(this, getClass().getName());		thread.start();	}	protected void addConnection(Connection conn)	{		SocketChannel client = conn.getClient();		SocketChannel server = conn.getServer();		try		{			logger.finest("Setting channels to non-blocking mode");			client.configureBlocking(false);			server.configureBlocking(false);			clients.put(client, server);			servers.put(server, client);			synchronized (this)			{				// Wakeup the select so that it doesn't block us from				// registering the channels				selector.wakeup();				SelectionKey key;				logger.finest("Registering channels with selector");				key = client.register(selector, SelectionKey.OP_READ);				conn.setClientSelectionKey(key);				//logger.finest("Client registered");				key = server.register(selector, SelectionKey.OP_READ);				conn.setServerSelectionKey(key);				//logger.finest("Server registered");			}		}		catch (IOException e)		{			logger.warning(				"Error setting channels to non-blocking mode: " +				e.getMessage());			try			{				logger.fine("Closing channels");				client.close();				server.close();			}			catch (IOException ioe)			{				logger.warning("Error closing channels: " + ioe.getMessage());			}		}	}	public void run()	{		Set readyKeys;		Iterator keyIter;		SelectionKey key;		SocketChannel src;		SocketChannel dst;		boolean clientToServer;		Socket srcSocket;		Socket dstSocket;		boolean readMore;		Iterator algoIter;		DistributionAlgorithm algo;		final int bufferSize = 128 * 1024;		ByteBuffer buffer;		ByteBuffer reviewedBuffer;		int r;		buffer = ByteBuffer.allocateDirect(bufferSize);		WHILETRUE:  while(true)		{			r = 0;			try			{				//logger.finest("Calling select");				r = selector.select();			}			catch (IOException e)			{				// What's it mean to get an I/O exception from select?				// Is it bad enough that we should return or exit?				logger.warning(					"Error when selecting for ready channel: " +					e.getMessage());				continue WHILETRUE;			}			// If someone is in the process of adding a new channel to			// our selector (via the addConnection() method), wait for			// them to finish			synchronized (this)			{				// Do we need anything in here to keep the compiler from				// optimizing this block away?				//logger.finest("run has monitor");			}			if (r == 0)			{				// select was interrupted, go back to waiting				continue WHILETRUE;			}			logger.finest(				"select reports " + r + " channels ready to read");			// Work through the list of channels that have data to read			readyKeys = selector.selectedKeys();			keyIter = readyKeys.iterator();			while (keyIter.hasNext())			{				key = (SelectionKey) keyIter.next();				keyIter.remove();				// Figure out which direction this data is going and				// get the SocketChannel that is the other half of				// the connection.				src = (SocketChannel) key.channel();				if (clients.containsKey(src))				{					clientToServer = true;					dst = (SocketChannel) clients.get(src);				}				else				{					clientToServer = false;					dst = (SocketChannel) servers.get(src);				}				try				{					// Loop as long as the source has data to read					readMore = false;  // Assume there won't be more data					do  // while (readMore)					{						// Try to read data						buffer.clear();						r = src.read(buffer);						logger.finest("Read " + r + " bytes from " + src);						if (r > 0)  // Data was read						{							// If the buffer is full, the source will							// likely to have more data for us to read							if (! buffer.hasRemaining())							{								readMore = true;							}							buffer.flip();							// Give each of the distribution algorithms a							// chance to inspect/modify the data stream							algoIter = distributionAlgorithms.iterator();							reviewedBuffer = buffer;							while (algoIter.hasNext())							{								algo =									(DistributionAlgorithm) algoIter.next();								if (clientToServer)								{									reviewedBuffer =										algo.reviewClientToServerData(											src, dst, reviewedBuffer);								}								else								{									reviewedBuffer =										algo.reviewServerToClientData(											src, dst, reviewedBuffer);								}							}							// Send the data on to its destination							// *** This is potentially trouble (what if							// the destination isn't ready to accept data?)							while (reviewedBuffer.remaining() > 0)							{								dst.write(reviewedBuffer);							}						}						else if (r == -1)  // EOF						{							// Cancel this key, otherwise this channel							// will repeatedly trigger select to tell us							// that it is at EOF.							key.cancel();							srcSocket = src.socket();							dstSocket = dst.socket();							// If the other half of the socket is							// already shutdown then go ahead and close							// the socket							if (srcSocket.isOutputShutdown())							{								logger.finer("Closing source socket");								srcSocket.close();								if (clientToServer)								{									clients.remove(src);								}								else								{									servers.remove(src);								}							}							// Otherwise just close down the input							// stream.  This allows any return traffic							// to continue to flow.							else							{								logger.finest("Shutting down source input");								srcSocket.shutdownInput();							}							// Do the same thing for the destination,							// but using the reverse streams.							if (dstSocket.isInputShutdown())							{								logger.finer("Closing destination socket");								dstSocket.close();								if (clientToServer)								{									servers.remove(dst);								}								else								{									clients.remove(dst);								}							}							else							{								logger.finest("Shutting down dest output");								dstSocket.shutdownOutput();							}						}					} while (readMore);				}				catch (IOException e)				{					logger.warning(						"Error moving data between channels: " +						e.getMessage());					// Cancel this key for similar reasons as given					// in the EOF case above.					key.cancel();					// Drop the entries from the direction maps					if (clientToServer)					{						clients.remove(src);						servers.remove(dst);					}					else					{						clients.remove(dst);						servers.remove(src);					}					try					{						logger.fine("Closing channels");						src.close();						dst.close();					}					catch (IOException ioe)					{						logger.warning(							"Error closing channels: " + ioe.getMessage());					}				}			}		}	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区在线观看| www.亚洲激情.com| 一区视频在线播放| 日韩欧美一区二区三区在线| zzijzzij亚洲日本少妇熟睡| 久久精品999| 亚洲午夜久久久久中文字幕久| 精品久久久久久久久久久久久久久 | 欧美日韩一区二区三区视频| 三级成人在线视频| 国产精品美女久久久久久久久久久| 91麻豆精品国产| 国产一区二区剧情av在线| 亚洲乱码日产精品bd| 日韩亚洲欧美在线观看| 成人sese在线| 久久精品国产成人一区二区三区 | 91色.com| 裸体一区二区三区| 亚洲男人的天堂一区二区| 日韩欧美一区二区视频| 91黄色在线观看| 国产mv日韩mv欧美| 久草热8精品视频在线观看| 亚洲色图欧美在线| 久久久久久影视| 91精品国产综合久久久久| 91在线观看高清| 国产精品一区二区三区网站| 蜜臀av性久久久久蜜臀aⅴ| 一区二区三区在线视频免费观看 | 国产欧美一区在线| 日韩亚洲欧美在线观看| 欧美午夜电影在线播放| 99久久99久久精品免费观看| 国产精品一区二区你懂的| 秋霞影院一区二区| 亚洲成人自拍一区| 亚洲欧美日韩系列| 国产精品久久久久久户外露出| 精品日韩一区二区三区| 色欧美片视频在线观看| 91网站视频在线观看| 国产麻豆9l精品三级站| 日韩不卡一区二区| 亚洲色图.com| 欧美国产日产图区| 欧美精品v国产精品v日韩精品 | 久久久久久久久伊人| 欧美变态口味重另类| 91精品国产色综合久久久蜜香臀| 亚洲精品一区二区三区影院| 欧美撒尿777hd撒尿| 色婷婷综合中文久久一本| 91亚洲精品一区二区乱码| 99国产精品久久| 91视频xxxx| 色综合久久88色综合天天6 | 不卡电影一区二区三区| 久久精品国产色蜜蜜麻豆| 亚洲国产欧美在线| 婷婷久久综合九色综合绿巨人| 亚洲精品亚洲人成人网在线播放| 成人免费视频在线观看| 一区二区三区在线影院| 夜夜操天天操亚洲| 午夜久久久影院| 日本中文字幕一区二区视频 | 色一区在线观看| 欧美视频一二三区| 欧美日本一道本| 欧美一区二区三区四区高清| 日韩亚洲欧美综合| 久久久一区二区| 国产精品视频一二| 亚洲乱码国产乱码精品精98午夜| 亚洲精品久久7777| 亚洲高清不卡在线| 麻豆精品久久久| 成人福利视频在线| 欧美三级电影在线观看| 欧美一区二区三区四区久久| 久久久久久久久久久99999| 国产精品久久久久9999吃药| 亚洲制服丝袜在线| 精品在线你懂的| jlzzjlzz亚洲女人18| 欧美亚洲综合一区| 精品美女在线观看| 亚洲色图一区二区三区| 午夜在线成人av| 国产麻豆成人传媒免费观看| 96av麻豆蜜桃一区二区| 欧美日韩亚洲丝袜制服| 精品免费日韩av| 亚洲嫩草精品久久| 免费观看一级特黄欧美大片| 成人av在线电影| 欧美在线免费观看亚洲| 亚洲女厕所小便bbb| 性欧美大战久久久久久久久| 91精品欧美福利在线观看| 久久婷婷综合激情| 悠悠色在线精品| 国产一区二区三区黄视频| 免费在线观看成人| 99国产精品久| 久久久亚洲综合| 午夜一区二区三区在线观看| 亚洲一区二区免费视频| 国产69精品一区二区亚洲孕妇| 国产人伦精品一区二区| 亚洲国产一区二区在线播放| 波多野结衣亚洲一区| 欧美一区二区三区视频免费播放| 国产欧美日韩另类一区| 三级影片在线观看欧美日韩一区二区| 高清视频一区二区| 3d成人动漫网站| 国产精品久久久久久久久晋中 | 亚洲h在线观看| 成人av免费在线观看| 日韩精品综合一本久道在线视频| 国产婷婷精品av在线| 人人狠狠综合久久亚洲| 色综合久久久久综合体桃花网| 精品国产青草久久久久福利| 亚洲人一二三区| 婷婷夜色潮精品综合在线| 97se亚洲国产综合自在线| 国产丝袜在线精品| 久久精品理论片| 在线播放/欧美激情| 一区二区三区四区不卡在线| 不卡一区二区中文字幕| 欧美激情中文字幕| 国产伦精一区二区三区| 日韩精品中文字幕在线一区| 亚洲成人黄色影院| 在线区一区二视频| 亚洲欧美一区二区视频| 高清免费成人av| 国产午夜精品久久久久久久| 久久av资源网| 欧美一卡二卡三卡四卡| 丝袜诱惑亚洲看片| 欧美色区777第一页| 一区二区三区不卡视频在线观看| av电影天堂一区二区在线观看| 国产亚洲一区二区三区在线观看| 免费在线观看精品| 日韩午夜在线播放| 免费看日韩精品| 欧美xfplay| 精品一区二区三区影院在线午夜| 日韩视频在线永久播放| 日本三级亚洲精品| 欧美一卡在线观看| 无码av免费一区二区三区试看 | 国产女人18毛片水真多成人如厕| 国产一区二区三区精品视频| 久久久综合激的五月天| 国产成+人+日韩+欧美+亚洲| 欧美激情在线看| 99这里都是精品| 日韩精品成人一区二区三区| 制服丝袜激情欧洲亚洲| 日本成人在线电影网| 欧美一二三四在线| 极品少妇一区二区| 国产日产欧美精品一区二区三区| 成人av网站免费| 亚洲欧美日韩国产成人精品影院| 一本大道久久a久久精品综合| 中文字幕一区二区三区蜜月| www.日韩av| 亚洲一区影音先锋| 日韩片之四级片| 国产黑丝在线一区二区三区| 亚洲人成7777| 日韩一卡二卡三卡| a美女胸又www黄视频久久| 日本一不卡视频| 中文字幕欧美一区| 欧美成人r级一区二区三区| 99九九99九九九视频精品| 日本美女一区二区| 国产精品久久三| 精品毛片乱码1区2区3区| 91麻豆国产香蕉久久精品| 韩国一区二区视频| 亚洲精品乱码久久久久久日本蜜臀| 日韩一区二区在线看| 91免费观看视频在线| 国产呦精品一区二区三区网站| 一区二区三区影院| 欧美高清一级片在线观看| 日韩视频在线你懂得| 欧美日韩色综合| 91欧美一区二区|