Search in sources :

Example 6 with ConcurrentList

use of j.util.ConcurrentList in project JFramework by gugumall.

the class JObject method getStaticList.

/**
 * @param key
 * @return
 */
public static ConcurrentList getStaticList(String key) {
    if (statics.containsKey(key)) {
        return (ConcurrentList) statics.get(key);
    } else {
        ConcurrentList s = new ConcurrentList();
        statics.put(key, s);
        return s;
    }
}
Also used : ConcurrentList(j.util.ConcurrentList)

Example 7 with ConcurrentList

use of j.util.ConcurrentList in project JFramework by gugumall.

the class JCacheUnitMap method keys.

/*
	 *  (non-Javadoc)
	 * @see j.cache.JCacheUnit#keys(j.cache.JCacheParams)
	 */
public ConcurrentList keys(JCacheParams params) throws Exception {
    checkStatus(false);
    JCacheFilter keyFileter = params == null ? null : params.keyFilter;
    JCacheFilter valueFilter = params == null ? null : params.valueFilter;
    int recordsPerPage = params == null ? 0 : params.recordsPerPage;
    int pageNum = params == null ? 0 : params.pageNum;
    ConcurrentMap mappings = container.snapshot();
    List keys = mappings.listKeys();
    if (keyFileter != null || valueFilter != null) {
        for (int i = 0; i < keys.size(); i++) {
            Object key = keys.get(i);
            Object value = mappings.get(key);
            boolean remove = false;
            if (keyFileter != null && !keyFileter.matches(key)) {
                remove = true;
            } else if (valueFilter != null && !valueFilter.matches(value)) {
                remove = true;
            }
            if (remove) {
                keys.remove(i);
            }
        }
    }
    mappings.clear();
    mappings = null;
    ConcurrentList result = new ConcurrentList();
    result.setTotal(keys.size());
    if (recordsPerPage > 0 && pageNum > 0) {
        // 分页
        int start = recordsPerPage * (pageNum - 1);
        int to = recordsPerPage * pageNum;
        if (start >= 0) {
            if (keys.size() > start) {
                keys = JUtilList.subConcurrentList(keys, start, to > keys.size() ? keys.size() : to);
            } else {
                keys.clear();
            }
        }
    }
    result.addAll(keys);
    return result;
}
Also used : ConcurrentList(j.util.ConcurrentList) ConcurrentMap(j.util.ConcurrentMap) List(java.util.List) ConcurrentList(j.util.ConcurrentList) JUtilList(j.util.JUtilList)

Example 8 with ConcurrentList

use of j.util.ConcurrentList in project JFramework by gugumall.

the class JDCache method keys.

/*
	 *  (non-Javadoc)
	 * @see j.cache.JCache#keys(java.lang.String, j.cache.JCacheParams)
	 */
public ConcurrentList keys(String cacheId, JCacheParams jdcParams) throws Exception {
    Servant info = findService(cacheId);
    if (info.service != null) {
        return info.service.keys(cacheId, jdcParams);
    } else {
        Map params = new HashMap();
        params.put("cacheId", cacheId);
        params.put("params", JObject.serializable2String((Serializable) jdcParams));
        String response = Client.httpCallPost(info.jhttp, info.jclient, info.serviceCode, info.httpChannel, "keys", params);
        params.clear();
        params = null;
        return (ConcurrentList) JObject.string2Serializable(response);
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ConcurrentList(j.util.ConcurrentList) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(j.util.ConcurrentMap)

Example 9 with ConcurrentList

use of j.util.ConcurrentList in project JFramework by gugumall.

the class JCacheUnitMap method values.

/*
	 *  (non-Javadoc)
	 * @see j.cache.JCacheUnit#values(j.cache.JCacheParams)
	 */
public ConcurrentList values(JCacheParams params) throws Exception {
    checkStatus(false);
    JCacheFilter keyFileter = params == null ? null : params.keyFilter;
    JCacheFilter valueFilter = params == null ? null : params.valueFilter;
    JUtilSorter sorter = params == null ? null : params.sorter;
    String sortType = params == null ? null : params.sortType;
    int recordsPerPage = params == null ? 0 : params.recordsPerPage;
    int pageNum = params == null ? 0 : params.pageNum;
    ConcurrentMap mappings = container.snapshot();
    List values = null;
    if (keyFileter != null || valueFilter != null) {
        values = new ConcurrentList();
        List keys = mappings.listKeys();
        for (int i = 0; i < keys.size(); i++) {
            Object key = keys.get(i);
            Object value = mappings.get(key);
            boolean remove = false;
            if (keyFileter != null && !keyFileter.matches(key)) {
                remove = true;
            } else if (valueFilter != null && !valueFilter.matches(value)) {
                remove = true;
            }
            if (!remove) {
                values.add(value);
            }
        }
        keys.clear();
        keys = null;
    } else {
        values = mappings.listValues();
    }
    mappings.clear();
    mappings = null;
    if (sorter != null) {
        // 排序
        values = sorter.mergeSort(values, sortType);
    }
    ConcurrentList result = new ConcurrentList();
    result.setTotal(values.size());
    if (recordsPerPage > 0 && pageNum > 0) {
        // 分页
        int start = recordsPerPage * (pageNum - 1);
        int to = recordsPerPage * pageNum;
        if (start >= 0) {
            if (values.size() > start) {
                values = JUtilList.subConcurrentList(values, start, to > values.size() ? values.size() : to);
            } else {
                values.clear();
            }
        }
    }
    result.addAll(values);
    return result;
}
Also used : ConcurrentList(j.util.ConcurrentList) JUtilSorter(j.util.JUtilSorter) ConcurrentMap(j.util.ConcurrentMap) List(java.util.List) ConcurrentList(j.util.ConcurrentList) JUtilList(j.util.JUtilList)

Example 10 with ConcurrentList

use of j.util.ConcurrentList in project JFramework by gugumall.

the class ServiceManager method getServices.

/**
 * @param code
 * @param initializing
 * @return
 */
public static ServiceConfig[] getServices(String code, boolean initializing) {
    if (!initializing)
        waitWhileLoading();
    ConcurrentList ls = (ConcurrentList) servicesOfClusters.get(code);
    if (ls == null)
        return null;
    else {
        ServiceConfig[] array = new ServiceConfig[ls.size()];
        ls.toArray(array);
        return array;
    }
}
Also used : ConcurrentList(j.util.ConcurrentList)

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