use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.
the class DistributedLock method unlock.
public boolean unlock(CacheConfigBean cacheConfigBean) {
final long applyTime = System.currentTimeMillis();
if (lockKey == null)
return false;
UnitResponse unitResponseObject = SyncXian.call("cache", "distributedUnLock", new JSONObject() {
{
put("cacheConfig", cacheConfigBean);
put("key", lockKey);
put("value", value);
}
});
if (!EnvUtil.getEnv().equals(EnvUtil.PRODUCTION)) {
final long receiveTime = System.currentTimeMillis();
final String result = unitResponseObject.succeeded() ? "成功" : "失败";
LOG.info(String.format("锁编号: %s, key: %s, lockKey: %s, value: %s, 分布式解锁, %s, 影响数量: %s, 耗时: %s 毫秒", autoIncrement, key, lockKey, value, result, unitResponseObject.getData(), (receiveTime - applyTime)));
}
if (!unitResponseObject.succeeded()) {
LOG.error(unitResponseObject);
return false;
}
return true;
}
use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.
the class CacheSystemUtil method jedisPoolAdd.
/**
* Add a cache datasource into the cache pool.
*
* @param cacheConfigBean the datasource configuration.
*/
public static void jedisPoolAdd(CacheConfigBean cacheConfigBean) {
UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "jedisPoolAdd", new JSONObject() {
{
put("host", cacheConfigBean.getHost());
put("port", cacheConfigBean.getPort());
put("password", cacheConfigBean.getPassword());
put("dbIndex", cacheConfigBean.getDbIndex());
}
});
unitResponseObject.throwExceptionIfNotSuccess();
}
use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.
the class CloudFile method save.
/**
* @param path 文件相对路径
* @param data 文件内容
* @param async 是否异步执行,如果不清楚,请使用{@linkplain CloudFile#save(String, String)}
*/
public static void save(String path, String data, boolean async) {
Map map = new HashMap<String, Object>() {
{
put("path", path);
put("data", data);
}
};
if (async) {
Xian.call("cosService", "cosWrite", map, new NotifyHandler() {
@Override
protected void handle(UnitResponse unitResponse) {
LOG.info(unitResponse);
}
});
} else {
SyncXian.call("cosService", "cosWrite", map);
}
}
use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.
the class AbstractDiyMonitorUnit method execute.
@Override
public UnitResponse execute(UnitRequest msg) {
JSONArray responseMonitor = new JSONArray();
String title = title();
if (title == null || "".equals(title.trim()))
// todo why success with empty array? not failure or exception?
return UnitResponse.success(responseMonitor);
Object monitor = execute0();
if (monitor != null) {
if (monitor instanceof UnitResponse)
padding(responseMonitor, ((UnitResponse) monitor).getData());
else
padding(responseMonitor, monitor);
}
return UnitResponse.success(responseMonitor);
}
use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.
the class CacheMapUtil method exists.
@Deprecated
public static boolean exists(CacheConfigBean cacheConfigBean, String key, String field) {
UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheMapExists", new JSONObject() {
{
put("cacheConfig", cacheConfigBean);
put("key", key);
put("field", field);
}
});
unitResponseObject.throwExceptionIfNotSuccess();
return (boolean) unitResponseObject.getData();
}
Aggregations