Search in sources :

Example 31 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheListUtil method addHead.

/**
 * append element to the list's head.
 *
 * @param cacheConfigBean cacheConfigBean
 * @param cacheKey        cacheKey
 * @param value           value
 * @return true on success, false on failure.
 */
public static boolean addHead(CacheConfigBean cacheConfigBean, String cacheKey, Object value) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheListAddHead", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
            put("valueObj", value);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    if (unitResponseObject.succeeded())
        return true;
    else
        return false;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 32 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheListUtil method getAll.

/**
 * @return 返回list,如果key不存在,那么返回null,如果key为空列表,那么返回size=0的ArrayList
 */
public static <T> List<T> getAll(String cacheKey, Class<T> clazz) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheListGetAll", new JSONObject() {

        {
            put("key", cacheKey);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    return unitResponseObject.dataToTypedList(clazz);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 33 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheListUtil method exists.

@Deprecated
public static boolean exists(CacheConfigBean cacheConfigBean, String cacheKey) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheListExists", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    return (boolean) unitResponseObject.getData();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 34 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheListUtil method get.

public static <T> T get(CacheConfigBean cacheConfigBean, String cacheKey, int index, Class<T> clazz) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheListGetByIndex", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
            put("index", index);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    if (unitResponseObject.getData() == null)
        return null;
    return Reflection.toType(unitResponseObject.getData(), clazz);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 35 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheListUtil method length.

public static long length(CacheConfigBean cacheConfigBean, String cacheKey) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheListLength", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    long length = (long) unitResponseObject.getData();
    return length > 0 ? length : 0;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Aggregations

UnitResponse (info.xiancloud.core.message.UnitResponse)106 JSONObject (com.alibaba.fastjson.JSONObject)74 HashMap (java.util.HashMap)22 UnitRequest (info.xiancloud.core.message.UnitRequest)17 NotifyHandler (info.xiancloud.core.NotifyHandler)16 JSONArray (com.alibaba.fastjson.JSONArray)9 Unit (info.xiancloud.core.Unit)6 UnitMeta (info.xiancloud.core.UnitMeta)6 CacheGroup (info.xiancloud.cache.service.CacheGroup)5 Group (info.xiancloud.core.Group)5 Input (info.xiancloud.core.Input)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Redis (info.xiancloud.cache.redis.Redis)4 CacheConfigBean (info.xiancloud.core.support.cache.CacheConfigBean)4 ThreadPoolManager (info.xiancloud.core.thread_pool.ThreadPoolManager)3 LOG (info.xiancloud.core.util.LOG)3 Set (java.util.Set)3 Test (org.junit.Test)3 MessageType (info.xiancloud.core.distribution.MessageType)2 UnitUndefinedException (info.xiancloud.core.distribution.exception.UnitUndefinedException)2