本文整理汇总了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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
示例9: getHost
import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo) {
return getLoadPattern().getHost(clientInfo);
}
示例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);
}
示例11: getHost
import org.quickserver.net.client.ClientInfo; //导入依赖的package包/类
public Host getHost(ClientInfo clientInfo);