Search in sources :

Example 11 with ConcurrentList

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;
}
Also used : ConcurrentList(j.util.ConcurrentList) ConcurrentMap(j.util.ConcurrentMap) Client(j.service.Client) HttpClient(org.apache.http.client.HttpClient)

Example 12 with ConcurrentList

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;
}
Also used : ConcurrentList(j.util.ConcurrentList) Client(j.service.Client) HttpClient(org.apache.http.client.HttpClient)

Example 13 with ConcurrentList

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);
}
Also used : ConcurrentList(j.util.ConcurrentList)

Example 14 with ConcurrentList

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);
}
Also used : ConcurrentList(j.util.ConcurrentList)

Example 15 with ConcurrentList

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);
}
Also used : ConcurrentList(j.util.ConcurrentList) JUtilString(j.util.JUtilString)

Aggregations

ConcurrentList (j.util.ConcurrentList)22 ConcurrentMap (j.util.ConcurrentMap)5 JUtilList (j.util.JUtilList)4 List (java.util.List)4 Client (j.service.Client)3 JUtilString (j.util.JUtilString)3 JCacheParams (j.cache.JCacheParams)2 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 HttpClient (org.apache.http.client.HttpClient)2 JHttpContext (j.http.JHttpContext)1 Http (j.service.Http)1 Rmi (j.service.Rmi)1 JUtilSorter (j.util.JUtilSorter)1 File (java.io.File)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 ServletException (javax.servlet.ServletException)1 HttpSession (javax.servlet.http.HttpSession)1