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

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

?? httpservicetest.java

?? 簡單的分布式算法
?? JAVA
字號:
/* ***************************************************************************** * $Id: HTTPServiceTest.java,v 1.6 2003/05/05 22:49:50 jheiss Exp $ ***************************************************************************** * Performs service tests against an HTTP server ***************************************************************************** * 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.*;import java.util.LinkedHashMap;import java.util.Map;import java.util.Map.Entry;import java.util.List;import java.util.Iterator;import java.util.logging.Logger;import java.net.HttpURLConnection;import java.net.URL;import java.net.MalformedURLException;import org.w3c.dom.Element;import org.w3c.dom.Node;import org.w3c.dom.NodeList;class HTTPServiceTest implements Runnable{	Distributor distributor;	Logger logger;	int frequency;  // How often should the test be done?	int timeout;  // How long do we wait for the test to complete before	              // deciding that it has failed?	boolean useSSL;	String path;	String userAgent;	protected static final int REQUIREMENT_RESPONSE_CODE = 1;	protected static final int REQUIREMENT_CONTENT_TYPE = 2;	protected static final int REQUIREMENT_DOCUMENT_TEXT = 3;	Map requirements;	Thread thread;	/*	 * Because the service tests are instantiated via Class.forName(),	 * they must have public constructors.	 */	public HTTPServiceTest(Distributor distributor, Element configElement)	{		this.distributor = distributor;		logger = distributor.getLogger();		frequency = 60000;  // Default of 60s		try		{			frequency =				Integer.parseInt(configElement.getAttribute("frequency"));		}		catch (NumberFormatException e)		{			logger.warning("Invalid frequency, using default:  " +				e.getMessage());		}		logger.config("Test frequency:  " + frequency);		timeout = 5000;  // Default of 5s		try		{			timeout =				Integer.parseInt(configElement.getAttribute("timeout"));		}		catch (NumberFormatException e)		{			logger.warning("Invalid timeout, using default:  " +				e.getMessage());		}		logger.config("Test timeout:  " + timeout);		useSSL = false;		if (configElement.getAttribute("use_ssl").equals("yes"))		{			useSSL = true;		}		logger.config("Use SSL:  " + useSSL);		userAgent = "Distributor - http://distributor.sourceforge.net/";		if (! configElement.getAttribute("user_agent").equals(""))		{			userAgent = configElement.getAttribute("user_agent");		}		logger.config("User agent:  " + userAgent);		if (! configElement.getAttribute("ssl_keystore").equals(""))		{			System.setProperty(				"javax.net.ssl.trustStore",				configElement.getAttribute("ssl_keystore"));		}		logger.config("SSL keystore:  " +			System.getProperty("javax.net.ssl.trustStore"));		// *** All of the auth related attributes are ignored for now		// Extract document path and requirements from XML document.		// Document structure:		// 		// <get path="/index.html">		//     <response_code value="200"/>		//     <content_type value="text/html"/>		//     <document_text value="Welcome to XYZ Corp"/>		// </get>		requirements = new LinkedHashMap();		NodeList configChildren = configElement.getChildNodes();		for (int i=0 ; i<configChildren.getLength() ; i++)		{			Node configNode = configChildren.item(i);			if (configNode.getNodeName().equals("get"))			{				Element getElement = (Element) configNode;				path = getElement.getAttribute("path");				NodeList getChildren = getElement.getChildNodes();				for (int j=0 ; j<getChildren.getLength() ; j++)				{					Node getNode = getChildren.item(j);					if (getNode.getNodeName().equals("response_code"))					{						Element responseCodeElement = (Element) getNode;						int code =							Integer.parseInt(								responseCodeElement.getAttribute("value"));						requirements.put(							new Integer(REQUIREMENT_RESPONSE_CODE),							new Integer(code));					}					else if (getNode.getNodeName().equals("content_type"))					{						Element contentTypeElement = (Element) getNode;						String type =							contentTypeElement.getAttribute("value");						requirements.put(							new Integer(REQUIREMENT_CONTENT_TYPE),							type);					}					else if (getNode.getNodeName().equals("document_text"))					{						Element documentTextElement = (Element) getNode;						String requiredText =							documentTextElement.getAttribute("value");						requirements.put(							new Integer(REQUIREMENT_DOCUMENT_TEXT),							requiredText);					}				}			}		}		if (path == null)		{			logger.severe("A path is required");			System.exit(1);  // ***		}		if (requirements.size() == 0)		{			// Insert a simple requirement			requirements.put(				new Integer(REQUIREMENT_RESPONSE_CODE),				new Integer(HttpURLConnection.HTTP_OK));		}		logger.config("Path:  " + path);		logger.config("Requirements:  " + requirements);		thread = new Thread(this, getClass().getName());		thread.start();	}	public void run()	{		List targets;		Iterator i;		Target target;		boolean result;		while (true)		{			targets = distributor.getTargets();			// distributor.getTargets() constructs a new List, puts			// all of the Targets into it, and returns it.  As such, we			// don't have to worry about holding everything else up by			// synchronizing on the list for a long time (the testing			// could take many seconds).  In fact, we really don't have			// to synchronize at all since we're the only ones with a			// reference to that list, but we do anyway for consistency.			synchronized (targets)			{				i = targets.iterator();				while (i.hasNext())				{					try					{						target = (Target) i.next();						HTTPBackgroundTest httpTest =							new HTTPBackgroundTest(target);						synchronized (httpTest)						{							httpTest.startTest();							httpTest.wait(timeout);						}						if (httpTest.getResult() ==							BackgroundTest.RESULT_SUCCESS)						{							result = true;						}						else						{							result = false;							if (httpTest.getResult() ==								BackgroundTest.RESULT_NOTFINISHED)							{								logger.warning("Test timed out");							}						}						if (result && ! target.isEnabled())						{							// I was tempted to log this at info but							// if someone has their log level set to							// warning then they'd only see the disable							// messages and not the enable messages.							logger.warning("Enabling: " + target);							target.enable();						}						else if (! result && target.isEnabled())						{							logger.warning("Disabling: " + target);							target.disable();						}					}					catch (InterruptedException e)					{						logger.warning("Service test interrupted");					}				}			}			try			{				Thread.sleep(frequency);			} catch (InterruptedException e) {}		}	}	class HTTPBackgroundTest extends BackgroundTest	{		protected HTTPBackgroundTest(Target target)		{			super(target);		}		public void test()		{			try			{				String proto = "http";				if (useSSL)				{					proto = "https";				}				URL serverURL = new URL(					proto,					target.getInetAddress().getHostName(),					target.getPort(),					path);				logger.fine("Server URL is " + serverURL);				logger.fine("Opening connection to server");				HttpURLConnection conn =					(HttpURLConnection) serverURL.openConnection();				// Set the user agent (aka "browser") field				conn.setRequestProperty("User-Agent", userAgent);				// Check the returned attributes to make sure everything the				// user required is present.				Iterator i = requirements.entrySet().iterator();				success = true;				while (i.hasNext() && success)				{					Entry requirementEntry = (Entry) i.next();					int requirement =						((Integer) requirementEntry.getKey()).intValue();					switch (requirement)					{					case REQUIREMENT_RESPONSE_CODE:						int requiredCode =							((Integer) requirementEntry.getValue()).intValue();						logger.finer("Checking for response code: " +							requiredCode);						if (conn.getResponseCode() != requiredCode)						{							logger.warning(								"Required response code is " + requiredCode +								", got " + conn.getResponseCode());								success = false;						}						break;					case REQUIREMENT_CONTENT_TYPE:						String requiredType =							(String) requirementEntry.getValue();						logger.finer("Checking for content type: " +							requiredType);						if (! conn.getContentType().equals(requiredType))						{							logger.warning(								"Required content type is " + requiredType +								", got " + conn.getContentType());								success = false;						}						break;					case REQUIREMENT_DOCUMENT_TEXT:						String requiredText =							(String) requirementEntry.getValue();						logger.finer("Checking for document text: " +							requiredText);						BufferedReader docReader =							new BufferedReader(								new InputStreamReader(									conn.getInputStream()));						success = false;						String docLine;						while ((docLine = docReader.readLine()) != null)						{							if (docLine.indexOf(requiredText) != -1)							{								success = true;								logger.finer("Required text found");							}						}						if (! success)						{							logger.warning("Required text not found");						}						break;					}				}				conn.disconnect();				if (success)				{					logger.fine("Server met all requirements");				}				finished = true;				synchronized (this)				{					notify();				}			}			catch (MalformedURLException e)			{				logger.warning("Error building URL: " +					e.getMessage());				// We don't want the server to get disabled when this happens				finished = true;				success = true;				return;			}			catch (IOException e)			{				logger.warning("Error communicating with server: " +					e.getMessage());				return;			}		}	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品久久久久久久网曝门| 欧洲精品在线观看| 色综合久久久网| 日韩欧美国产综合| 玉米视频成人免费看| 蜜臀av一区二区三区| 色综合天天性综合| 久久综合九色综合欧美亚洲| 亚洲麻豆国产自偷在线| 国产乱码字幕精品高清av| 欧美亚洲国产一区二区三区va| 久久噜噜亚洲综合| 首页国产欧美日韩丝袜| 色伊人久久综合中文字幕| 国产丝袜美腿一区二区三区| 日韩高清不卡在线| 欧美在线免费视屏| 亚洲美女偷拍久久| 国产a久久麻豆| 国产色婷婷亚洲99精品小说| 卡一卡二国产精品| 欧美精品在欧美一区二区少妇| 国产精品欧美综合在线| 国产美女精品人人做人人爽 | 94-欧美-setu| 国产女主播一区| 国产a视频精品免费观看| 久久久综合激的五月天| 久久国产精品一区二区| 精品理论电影在线| 久久av资源网| 久久久www成人免费毛片麻豆| 久久99久久久久久久久久久| 欧美videos中文字幕| 免费av成人在线| 欧美成人福利视频| 国产一区二区日韩精品| 久久久99久久| www.色综合.com| 亚洲欧美日本韩国| 欧美人伦禁忌dvd放荡欲情| 日韩精品高清不卡| 日韩网站在线看片你懂的| 精品一区二区三区免费播放 | 亚洲三级电影网站| 99精品国产91久久久久久| 欧美一区二区三区精品| 狠狠色综合播放一区二区| 日韩欧美国产一区二区在线播放| 秋霞国产午夜精品免费视频| 欧美日本在线观看| 日韩高清不卡一区二区三区| 在线综合亚洲欧美在线视频| 日本不卡视频在线观看| 337p亚洲精品色噜噜噜| 天天综合网 天天综合色| 91免费视频观看| 一区二区三区精品在线| 欧洲一区二区三区在线| 亚洲bt欧美bt精品777| 欧美日韩你懂得| 蜜臂av日日欢夜夜爽一区| 久久综合九色综合欧美亚洲| 丁香激情综合五月| 亚洲视频你懂的| 在线一区二区三区四区| 日韩电影在线观看一区| 精品福利二区三区| 不卡av电影在线播放| 亚洲黄色小视频| 免费观看在线综合| av中文字幕在线不卡| 国产蜜臀97一区二区三区| 成人精品视频网站| 中文字幕一区二区三| 色噜噜狠狠成人网p站| 午夜不卡av免费| 久久午夜电影网| 91老司机福利 在线| 日韩精品一二区| 国产欧美一区二区精品忘忧草| eeuss鲁片一区二区三区在线观看| 亚洲蜜臀av乱码久久精品| 91精品国产日韩91久久久久久| 麻豆精品在线看| 亚洲一线二线三线久久久| 日韩欧美在线不卡| av亚洲精华国产精华| 日韩1区2区日韩1区2区| 中文字幕一区av| 欧美日韩中文一区| 国产成人啪免费观看软件| 一卡二卡欧美日韩| 久久精品免费在线观看| 欧美私人免费视频| 成人短视频下载| 图片区日韩欧美亚洲| 亚洲丝袜制服诱惑| 欧美日韩在线播| 成人美女在线视频| 美女视频一区二区三区| 中文字幕在线免费不卡| 国产偷国产偷精品高清尤物| 91精品午夜视频| 色婷婷久久久综合中文字幕 | 99久久久久久| 热久久国产精品| 亚洲免费在线播放| 亚洲精品一线二线三线| 欧美亚洲一区三区| 成人99免费视频| 韩国欧美国产1区| 亚洲午夜私人影院| 亚洲综合色网站| 亚洲欧洲三级电影| 国产精品色婷婷久久58| 久久综合久久综合亚洲| 日韩亚洲欧美成人一区| 欧美性生活一区| 91论坛在线播放| 99久久久无码国产精品| 99精品久久免费看蜜臀剧情介绍| 久久成人av少妇免费| 久久精品国产成人一区二区三区| 丝袜亚洲另类欧美综合| 亚洲国产视频网站| 亚洲高清一区二区三区| 久久综合色天天久久综合图片| 99精品久久只有精品| 国产91高潮流白浆在线麻豆| 国产精品77777| 国产一区二区三区黄视频| 青青草国产成人99久久| 日日骚欧美日韩| 日韩电影在线观看网站| 日韩精品欧美精品| 首页国产丝袜综合| 免费看精品久久片| 精品一区二区在线看| 精品一区二区三区免费播放| 国产美女在线精品| 国产乱子伦视频一区二区三区 | 538prom精品视频线放| 欧美精品三级在线观看| 91麻豆精品国产综合久久久久久 | 日韩欧美国产三级| 欧美成人vps| 国产农村妇女精品| 国产精品天美传媒沈樵| 亚洲男人的天堂在线aⅴ视频| 樱花影视一区二区| 日韩精品一级中文字幕精品视频免费观看 | 欧美午夜精品久久久久久超碰| 欧美色成人综合| 日韩午夜在线影院| 国产农村妇女精品| 亚洲国产精品欧美一二99| 亚洲va国产va欧美va观看| 久国产精品韩国三级视频| 国产一区999| 色88888久久久久久影院野外| 3d动漫精品啪啪1区2区免费 | 91在线无精精品入口| 一本大道久久a久久精二百| 欧美高清视频www夜色资源网| 精品日韩99亚洲| 亚洲天堂成人在线观看| 婷婷国产在线综合| 精品一区二区日韩| aaa欧美日韩| 欧美一区二区三区公司| 中文字幕亚洲在| 麻豆成人久久精品二区三区红| 国精品**一区二区三区在线蜜桃| 欧美色图在线观看| 国产日韩欧美精品一区| 五月婷婷另类国产| 国产suv精品一区二区6| 欧美日韩的一区二区| 国产精品视频一区二区三区不卡| 亚洲第一久久影院| 成人在线综合网| 欧美成人精品1314www| 一区二区三区在线播| 国产精品99久久久久久有的能看| 欧美色视频一区| 日本一区免费视频| 麻豆精品在线观看| 97精品久久久久中文字幕 | 成人午夜在线视频| 精品99久久久久久| 视频在线观看91| 在线免费视频一区二区| 国产欧美一区二区在线观看| 免费视频最近日韩| 欧美色图在线观看| 伊人性伊人情综合网| 成人av影院在线| 在线播放国产精品二区一二区四区 | 精品久久久久久久久久久久久久久|