当前位置: 首页>>代码示例>>Java>>正文


Java ClientInfo类代码示例

本文整理汇总了Java中org.quickserver.net.client.ClientInfo的典型用法代码示例。如果您正苦于以下问题:Java ClientInfo类的具体用法?Java ClientInfo怎么用?Java ClientInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClientInfo类属于org.quickserver.net.client包,在下文中一共展示了ClientInfo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
	List activeList = getHostList().getActiveList();
	
	if(activeList==null || activeList.isEmpty()) {
		logger.warning("No active list available to service requests");
		return null;
	}
	
	if(clientInfo!=null) {
		if(clientInfo.getHostName()!=null) {
			Host host = hostList.getHostByName(clientInfo.getHostName());
			if(host==null) {
				logger.log(Level.WARNING, "Host will name [{0}] not in hostlist!{1}", 
					new Object[]{clientInfo.getHostName(), hostList});
			} else {
				if(host.getStatus()==Host.ACTIVE) {
					return host;
				}
			}				
		}
	}
	
	//always return firstActive from List
	return (Host) activeList.get(0);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:26,代码来源:FirstActiveLoadPattern.java

示例2: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
	List activeList = getHostList().getActiveList();
	
	if(activeList==null || activeList.isEmpty()) {
		logger.warning("No active list available to service requests");
		return null;
	}
	
	if(clientInfo!=null) {
		if(clientInfo.getHostName()!=null) {
			Host host = hostList.getHostByName(clientInfo.getHostName());
			if(host==null) {
				logger.log(Level.WARNING, "Host will name [{0}] not in hostlist!{1}", 
					new Object[]{clientInfo.getHostName(), hostList});
			} else {
				if(host.getStatus()==Host.ACTIVE) {
					return host;
				}
			}
		}
	}
	
	int size = activeList.size();
	int pos = random.nextInt(size);
	return (Host) activeList.get(pos);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:27,代码来源:RandomLoadPattern.java

示例3: sendDataOut

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
private String sendDataOut(String key, String data) throws TimeoutException {
	ClientInfo ci = new ClientInfo();
	ci.setClientKey(key);

	PooledBlockingClient pbc = null;

	try {
		pbc = blockingClientPool.getBlockingClient(ci);
		if (pbc == null) {
			throw new TimeoutException("sdo: we do not have any client[pbc] to connect to server!");
		}

		BlockingClient bc = pbc.getBlockingClient();
		if (bc == null) {
			throw new TimeoutException("we do not have any client[bc] to connect to server!");
		}

		bc.sendBytes(data, charset);

		return bc.readCRLFLine();
	} catch (IOException e) {            
           if (pbc != null) {
			logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
			pbc.close();
		}
           if(e instanceof TimeoutException) {
               throw (TimeoutException) e;
           } else {
               throw new TimeoutException("We had ioerror " + e);
           }	
	} finally {
		if (pbc != null) {
			blockingClientPool.returnBlockingClient(pbc);
		}
	}
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:37,代码来源:QuickCachedClientImpl.java

示例4: getBlockingClient

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public PooledBlockingClient getBlockingClient(ClientInfo clientInfo) {		
	SocketBasedHost host = (SocketBasedHost) 
		getPoolableBlockingClient().getLoadDistributor().getHost(clientInfo);
	if(host==null) {
		logger.log(Level.WARNING, "LoadDistributor.. gave null host!");
		return null;
	}
	
	if(host.getStatus()!=Host.ACTIVE && host.getStatus()!=Host.UNKNOWN) {
		logger.log(Level.WARNING, "host is not up! sending null host!");
		return null;
	}
	
	return getBlockingClientByHost(host);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:16,代码来源:BlockingClientPool.java

示例5: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
	List activeList = getHostList().getActiveList();
	
	if(activeList==null || activeList.isEmpty()) {
		logger.log(Level.WARNING, "No active list available to service requests {0}", activeList);
		return null;
	}
	
	if(clientInfo!=null) {
		if(clientInfo.getHostName()!=null) {
			Host host = hostList.getHostByName(clientInfo.getHostName());
			if(host==null) {
				logger.log(Level.WARNING, "Host will name [{0}] not in hostlist!{1}", 
					new Object[]{clientInfo.getHostName(), hostList});
			} else {
				if(host.getStatus()==Host.ACTIVE) {
					return host;
				}
			}				
		}
	}
	
	int size = activeList.size();
	
	int mypos;
	synchronized(lock) {
		pos++;
		if(pos>=size) {
			pos = 0;
		}
		mypos = pos;
	}
	return (Host) activeList.get(mypos);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:35,代码来源:RoundRobinLoadPattern.java

示例6: gotConnected

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
@Override
public void gotConnected(ClientHandler handler)
		throws SocketTimeoutException, IOException {
	logger.log(Level.FINE, "Connection opened: {0}", handler.getHostAddress());		
	
	if(interfaceServer==null) {
		QuickServer server = handler.getServer();
		//path, is
		Object[] storeObj = server.getStoreObjects();
		interfaceServer = (InterfaceServer) storeObj[1];
	}
	
	interfaceServer.getStats().getClientCount().incrementAndGet();
	
	ClientInfo ci = new ClientInfo();
	ci.setInetAddress(handler.getSocket().getInetAddress());
	ci.setClientKey(handler.getHostAddress());
	
	LoadDistributor lb = interfaceServer.getInterfaceHosts().getLoadDistributor();
	SocketBasedHost host = (SocketBasedHost) lb.getHost(ci);
	if(host==null) {
		if(downtimeStarted==false) {
			downtimeStarted = true;
			downtimeStartTime = System.currentTimeMillis();
		}
		logger.warning("We do not have any host to send traffic to.. so closing it down");
		handler.closeConnection();
		
		interfaceServer.getStats().getDroppedCount().incrementAndGet();
		return;
	}
	
	if(downtimeStarted) {
		downtimeStarted = false;
		long diff = (System.currentTimeMillis() - downtimeStartTime);
		interfaceServer.getStats().addDownTime(diff);
	}
	
	logger.log(Level.FINEST, "SocketBasedHost: {0}", host);
	
	Data data = (Data) handler.getClientData();
	data.setRemoteHost(host.getInetAddress().getHostAddress());
	data.setRemotePort(host.getInetSocketAddress().getPort());
	data.setInterfaceServer(interfaceServer);
	
	data.init(new Socket(data.getRemoteHost(), 
		data.getRemotePort()), handler);
}
 
开发者ID:QuickServerLab,项目名称:QuickLB,代码行数:49,代码来源:CommandHandler.java

示例7: readDataOutCAS

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
private CASValue readDataOutCAS(String key, String data) throws TimeoutException {
	long casUnique = 0;

	ClientInfo ci = new ClientInfo();
	ci.setClientKey(key);

	PooledBlockingClient pbc = null;

	try {
		pbc = blockingClientPool.getBlockingClient(ci);
		if (pbc == null) {
			throw new TimeoutException("rdo: we do not have any client[pbc] to connect to server!");
		}

		BlockingClient bc = pbc.getBlockingClient();
		if (bc == null) {
			throw new TimeoutException("we do not have any client[bc] to connect to server!");
		}

		bc.sendBytes(data, charset);
		String resMain = bc.readCRLFLine();

		if (resMain == null) {
			throw new TimeoutException("we got null reply!");
		}

		/*
		 VALUE <key> <flags> <bytes> [<cas unique>]\r\n
		 <data block>\r\n
		 END\r\n
		 */

		if (resMain.startsWith("VALUE ")) {
			String cmdData[] = resMain.split(" ");
			if (cmdData.length < 4) {
				return null;
			}
			int flag = Integer.parseInt(cmdData[2]);
			int bytes = Integer.parseInt(cmdData[3]);


			if (cmdData.length >= 5) {
				casUnique = Long.parseLong(cmdData[4]);
			}

			byte[] dataBuff = bc.readBytes(bytes);

			//read the footer 7 char extra \r\nEND\r\n
			bc.readBytes(7);

			if (dataBuff == null) {
				throw new TimeoutException("we don't have data!");
			}

			if (flag == FLAGS_GENRIC_STRING) {
				return new CASValue(casUnique, new String(dataBuff, charset));
			} else {
				return new CASValue(casUnique, retriveObject(dataBuff));
			}
		} else if (resMain.equals("END")) {
			return null;
		} else {
			logger.log(Level.WARNING, "unknown res got! : {0}", resMain);
			throw new TimeoutException("unknown res got! : " + resMain);
		}
	} catch (IOException e) {
		if (pbc != null) {
			logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
			pbc.close();
		}
           if(e instanceof TimeoutException) {
               throw (TimeoutException) e;
           } else {
               throw new TimeoutException("We had ioerror " + e);
           }			
	} finally {
		if (pbc != null) {
			blockingClientPool.returnBlockingClient(pbc);
		}
	}
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:82,代码来源:QuickCachedClientImpl.java

示例8: sendCmdOut

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
private String sendCmdOut(String key, String data) throws TimeoutException {
	ClientInfo ci = new ClientInfo();
	ci.setClientKey(key);

	PooledBlockingClient pbc = null;

	try {
		pbc = blockingClientPool.getBlockingClient(ci);
		if (pbc == null) {
			throw new TimeoutException("cmo: we do not have any client[pbc] to connect to server!");
		}

		BlockingClient bc = pbc.getBlockingClient();
		if (bc == null) {
			throw new TimeoutException("we do not have any client[bc] to connect to server!");
		}

		bc.sendBytes(data, charset);

		String resMain = bc.readCRLFLine();
		if (resMain == null) {
			throw new TimeoutException("we got null reply!");
		}

		return resMain;
	} catch (IOException e) {
		if (pbc != null) {
			logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
			pbc.close();
		}
           if(e instanceof TimeoutException) {
               throw (TimeoutException) e;
           } else {
               throw new TimeoutException("We had ioerror " + e);
           }			
	} finally {
		if (pbc != null) {
			blockingClientPool.returnBlockingClient(pbc);
		}
	}
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:42,代码来源:QuickCachedClientImpl.java

示例9: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
	return getLoadPattern().getHost(clientInfo);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:4,代码来源:LoadDistributor.java

示例10: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
	List activeList = getHostList().getActiveList();
	
	if(activeList==null || activeList.isEmpty()) {
		logger.warning("No active list available to service requests");
		return null;
	}
	int size = activeList.size();
               
               int hash =  -1;
	
	if(clientInfo!=null) {
		if(clientInfo.getHostName()!=null) {
                           Host host = hostList.getHostByName(clientInfo.getHostName());
                           if(host==null) {
                               logger.log(Level.WARNING, "Host will name [{0}] not in hostlist!{1}", 
                                       new Object[]{clientInfo.getHostName(), hostList});
                               //pass through
                           } else {
                               if(host.getStatus()==Host.ACTIVE) {
                                   return host;
                               } else {
                                   //pass through
                               }
                           }		
		} else if(clientInfo.getClientKey()==null) {
                           throw new NullPointerException("ClientKey was null!");
		} else {
                           //pass though
                       }
	} else {
                   throw new NullPointerException("clientInfo was null!");
	}
               
               if(clientInfo.getClientKey()!=null) {
                   hash = clientInfo.getClientKey().hashCode();
               } else {
                   hash = clientInfo.getHostName().hashCode();
               }
               
	int mod = hash % size;
	if(mod<0) mod = mod*-1;
	
	return (Host) activeList.get(mod);
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:46,代码来源:HashedLoadPattern.java

示例11: getHost

import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo); 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:2,代码来源:LoadPattern.java


注:本文中的org.quickserver.net.client.ClientInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。