use of j.util.ConcurrentList in project JFramework by gugumall.
the class JRouterImpl method unregister.
/*
* (non-Javadoc)
* @see j.service.router.RouterInterface#unregister(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public String unregister(String clientUuid, String clusterCode, String uuid, String md54Routing) throws RemoteException {
if (Constants.PRIVICY_PUBLIC.equalsIgnoreCase(routerConfig.getPrivacy())) {
// is public, nothing to do
} else if (Constants.PRIVICY_MD5.equalsIgnoreCase(routerConfig.getPrivacy())) {
Client client = routerConfig.getClient(clientUuid);
if (client == null) {
log.log("client " + clientUuid + " is not exists.", Logger.LEVEL_DEBUG);
return Constants.AUTH_FAILED;
}
String md5 = "";
md5 += clientUuid;
md5 += clusterCode;
md5 += uuid;
md5 += client.getKey();
md5 = JUtilMD5.MD5EncodeToHex(md5);
if (!md5.equalsIgnoreCase(md54Routing)) {
return Constants.AUTH_FAILED;
}
} else {
// 未实现的隐私策略
return Constants.AUTH_FAILED;
}
ConcurrentList clusterNodes = (ConcurrentList) serviceNodesOfClusters.get(clusterCode);
ConcurrentMap servantsOfCluster = (ConcurrentMap) servantsOfClusters.get(clusterCode);
ConcurrentMap httpsOfCluster = (ConcurrentMap) httpsOfClusters.get(clusterCode);
if (clusterNodes != null) {
for (int i = 0; i < clusterNodes.size(); i++) {
Service node = (Service) clusterNodes.get(i);
if (node.uuid.equals(uuid)) {
if (nodeInfoList.contains(node.toString()))
nodeInfoList.remove(node.toString());
clusterNodes.remove(i);
if (servantsOfCluster != null)
servantsOfCluster.remove(node.uuid);
if (httpsOfCluster != null)
httpsOfCluster.remove(node.uuid);
update = SysUtil.getNow();
break;
}
}
}
if (clusterNodes == null || clusterNodes.isEmpty()) {
serviceNodesOfClusters.remove(clusterCode);
servantsOfClusters.remove(clusterCode);
httpsOfClusters.remove(clusterCode);
clusterCodes.remove(clusterCode);
}
return Constants.INVOKING_DONE;
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class JRouterImpl method register.
/*
* (non-Javadoc)
* @see j.service.router.RouterInterface#register(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public String register(String clientUuid, String clusterCode, String uuid, String rmi, String http, String interfaceClassName, String md54Routing) throws RemoteException {
if (Constants.PRIVICY_PUBLIC.equalsIgnoreCase(routerConfig.getPrivacy())) {
// is public, nothing to do
} else if (Constants.PRIVICY_MD5.equalsIgnoreCase(routerConfig.getPrivacy())) {
Client client = routerConfig.getClient(clientUuid);
if (client == null) {
log.log("client " + clientUuid + " is not exists.", Logger.LEVEL_DEBUG);
return Constants.AUTH_FAILED;
}
String md5 = "";
md5 += clientUuid;
md5 += clusterCode;
md5 += uuid;
md5 += rmi;
md5 += http;
md5 += interfaceClassName;
md5 += client.getKey();
md5 = JUtilMD5.MD5EncodeToHex(md5);
if (!md5.equalsIgnoreCase(md54Routing)) {
return Constants.AUTH_FAILED;
}
} else {
// 未实现的隐私策略
return Constants.AUTH_FAILED;
}
ConcurrentList clusterNodes = (ConcurrentList) serviceNodesOfClusters.get(clusterCode);
if (clusterNodes == null) {
clusterNodes = new ConcurrentList();
}
Service node = new Service(uuid, rmi, http, interfaceClassName, clusterCode);
if (!nodeInfoList.contains(node.toString())) {
log.log("register new service - " + node.toString(), -1);
nodeInfoList.add(node.toString());
clusterNodes.add(node);
update = SysUtil.getNow();
}
serviceNodesOfClusters.put(clusterCode, clusterNodes);
if (!clusterCodes.contains(clusterCode))
clusterCodes.add(clusterCode);
return Constants.INVOKING_DONE;
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class Online method removeMessageInFirst.
public void removeMessageInFirst(String sellerId) {
ConcurrentList temp = (ConcurrentList) messagesWithSellerIn.get(sellerId);
if (temp == null)
temp = new ConcurrentList();
if (!temp.isEmpty()) {
temp.remove(0);
}
messagesWithSellerIn.put(sellerId, temp);
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class Online method addMessageIn.
public void addMessageIn(Serializable msg, String sellerId) {
ConcurrentList temp = (ConcurrentList) messagesWithSellerIn.get(sellerId);
if (temp == null)
temp = new ConcurrentList();
temp.add(msg);
messagesWithSellerIn.put(sellerId, temp);
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class DBMirror method connect.
/**
* @param clazz
* @return
* @throws Exception
*/
DAO connect(Class clazz, long timeout) throws Exception {
synchronized (this) {
if (factory == null) {
factory = DAOFactory.getInstance(dbname, config);
factory.resetIgnoreColsWhileUpdating();
ConcurrentList cols = db.getIgnoreColsWhileUpdateViaBean();
for (int i = 0; i < cols.size(); i++) {
String col = (String) cols.get(i);
factory.ignoreColWhileUpdating(col.substring(0, col.indexOf(",")).trim(), col.substring(col.indexOf(",") + 1).trim());
}
}
}
return factory.createDAO(clazz, timeout, this);
}
Aggregations