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


Java BlockingClient类代码示例

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


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

示例1: sendCmdOutToAll

import org.quickserver.net.client.BlockingClient; //导入依赖的package包/类
private void sendCmdOutToAll(String data) throws TimeoutException {
	PooledBlockingClient pbc[] = blockingClientPool.getOneBlockingClientForAllActiveHosts();
	if (pbc == null) {
		throw new TimeoutException("we do not have any client array [pbc] to connect to server!");
	}

	for (int i = 0; i < pbc.length; i++) {
		try {
			BlockingClient bc = pbc[i].getBlockingClient();
			if (bc == null) {
				throw new TimeoutException("we do not have any client[bc] to connect to server!");
			}

			bc.sendBytes(data, charset);
		} catch (IOException e) {
			if (pbc != null) {
				logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
				pbc[i].close();
			}
		} finally {
			blockingClientPool.returnBlockingClient(pbc[i]);
			pbc[i] = null;
		}
	}

}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:27,代码来源:QuickCachedClientImpl.java

示例2: sendDataOut

import org.quickserver.net.client.BlockingClient; //导入依赖的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

示例3: getStats

import org.quickserver.net.client.BlockingClient; //导入依赖的package包/类
public Map getStats() throws Exception {
	Map<InetSocketAddress, Map<String, String>> map = new HashMap<InetSocketAddress, Map<String, String>>();

	PooledBlockingClient pbc[] = blockingClientPool.getOneBlockingClientForAllActiveHosts();
	if (pbc == null) {
		throw new TimeoutException("we do not have any client array [pbc] to connect to server!");
	}

	Map<String, String> inmap = null;
	for (int i = 0; i < pbc.length; i++) {
		try {
			BlockingClient bc = pbc[i].getBlockingClient();
			if (bc == null) {
				throw new TimeoutException("we do not have any client[bc] to connect to server!");
			}

			inmap = getStats(bc);

			map.put(pbc[i].getSocketBasedHost().getInetSocketAddress(), inmap);
		} catch (IOException e) {
			if (pbc != null) {
				logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
				pbc[i].close();
			}
		} finally {
			blockingClientPool.returnBlockingClient(pbc[i]);
			pbc[i] = null;
		}
	}

	return map;
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:33,代码来源:QuickCachedClientImpl.java

示例4: getVersions

import org.quickserver.net.client.BlockingClient; //导入依赖的package包/类
public Map getVersions() throws TimeoutException {
	Map<InetSocketAddress, String> map = new HashMap<InetSocketAddress, String>();

	PooledBlockingClient pbc[] = blockingClientPool.getOneBlockingClientForAllActiveHosts();
	if (pbc == null) {
		throw new TimeoutException("we do not have any client array [pbc] to connect to server!");
	}

	String version = null;
	for (int i = 0; i < pbc.length; i++) {
		try {
			BlockingClient bc = pbc[i].getBlockingClient();
			if (bc == null) {
				throw new TimeoutException("we do not have any client[bc] to connect to server!");
			}

			version = getVersion(bc);

			map.put(pbc[i].getSocketBasedHost().getInetSocketAddress(), version);
		} catch (IOException e) {
			if (pbc != null) {
				logger.log(Level.WARNING, "We had an ioerror will close client! " + e, e);
				pbc[i].close();
			}
		} finally {
			blockingClientPool.returnBlockingClient(pbc[i]);
			pbc[i] = null;
		}
	}

	return map;
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:33,代码来源:QuickCachedClientImpl.java

示例5: run

import org.quickserver.net.client.BlockingClient; //导入依赖的package包/类
public void run() {
	logger.log(Level.FINE, "start thread {0}", getName());
	
	byte data[];
	while(true) {
		try	{
			if(init==false) {
				synchronized(lock) {
					lock.wait();
				}
				
				if(stopThead) {
					logger.log(Level.FINE, "stop thread {0}", getName());
					return;
				} else {
					continue;
				}
			}
			
			data = BlockingClient.readInputStream(bin);
			if(data==null) {
				init = false;
				logger.fine("got eof from remote pipe");
				handler.closeConnection();
			} else {
				interfaceServer.getStats().getOutByteCount().addAndGet(data.length);
				handler.sendClientBinary(data);
				
				if(logText) {
					logger.log(Level.FINE, "S:Text: {0}", new String(data));
				}
				if(logHex) {
					logger.log(Level.FINE, "S:Hex : {0}", hexencode(data));
				}
			}
		} catch(Exception e) {
			if(interfaceServer!=null) {
				interfaceServer.getStats().getConErrorCount().incrementAndGet();
			}
			init = false;
			if(closed==false) {
				logger.log(Level.WARNING, "Error in data thread : "+e, e);
			} else {
				//logger.log(Level.FINEST, "Error after connection was closed in data thread : {0}", e);
			}
			//e.printStackTrace();
		}
	}//end of while
}
 
开发者ID:QuickServerLab,项目名称:QuickLB,代码行数:50,代码来源:Data.java

示例6: readDataOutCAS

import org.quickserver.net.client.BlockingClient; //导入依赖的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

示例7: sendCmdOut

import org.quickserver.net.client.BlockingClient; //导入依赖的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

示例8: getBlockingClient

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

示例9: setBlockingClient

import org.quickserver.net.client.BlockingClient; //导入依赖的package包/类
public void setBlockingClient(BlockingClient blockingClient) {
	this.blockingClient = blockingClient;
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:4,代码来源:PooledBlockingClient.java

示例10: createBlockingClient

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

示例11: closeBlockingClient

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

示例12: sendNoOp

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


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