Search in sources :

Example 6 with UnitResponse

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

the class AppTransaction method rollbackAndCloseTogether.

public void rollbackAndCloseTogether() throws SQLException {
    // 发送远程请求,将其他数据库事务提交和关闭
    JSONArray clientIds = TransactionalCache.clear();
    if (clientIds != null) {
        for (int i = 0; i < clientIds.size(); i++) {
            final String clientId = clientIds.getString(i);
            if (!LocalNodeManager.LOCAL_NODE_ID.equals(clientId)) {
                UnitRequest request = UnitRequest.create(RollbackAndCloseTogetherUnit.class);
                request.getContext().setDestinationNodeId(clientId);
                LocalNodeManager.send(request, new NotifyHandler() {

                    protected void handle(UnitResponse unitResponse) {
                        LOG.info(clientId + "的事务已经回滚");
                    }
                });
            }
        }
    }
    // 回滚和关闭自己的数据库事务
    connection.rollback();
    connection.close();
    // 清除本地事务
    localTransMap.remove(transactionId);
}
Also used : UnitRequest(info.xiancloud.core.message.UnitRequest) UnitResponse(info.xiancloud.core.message.UnitResponse) JSONArray(com.alibaba.fastjson.JSONArray) NotifyHandler(info.xiancloud.core.NotifyHandler)

Example 7 with UnitResponse

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

the class UpdateAction method check.

protected UnitResponse check(Unit daoUnit, Map map, Connection connection) {
    UnitResponse unitResponseObject = super.check(daoUnit, map, connection);
    if (!unitResponseObject.getCode().equals(Group.CODE_SUCCESS)) {
        return unitResponseObject;
    }
    UnitResponse safetyUnitResponse = SafetyChecker.doCheck(this, map);
    if (!safetyUnitResponse.getCode().equals(DaoGroup.CODE_SUCCESS)) {
        return safetyUnitResponse;
    }
    try {
        return new UniqueChecker(this).checkUnique();
    } catch (SQLException e) {
        LOG.error(e);
        return UnitResponse.error(DaoGroup.CODE_SQL_ERROR, e, "SQL异常");
    }
}
Also used : SQLException(java.sql.SQLException) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 8 with UnitResponse

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

the class DDLAction method check.

@Override
protected UnitResponse check(Unit daoUnit, Map map, Connection connection) {
    UnitResponse unitResponseObject = super.check(daoUnit, map, connection);
    if (!unitResponseObject.getCode().equals(Group.CODE_SUCCESS)) {
        return unitResponseObject;
    }
    DaoUnit daounit = (DaoUnit) daoUnit;
    return DDLChecker.check(daounit);
}
Also used : DaoUnit(info.xiancloud.dao.group.unit.DaoUnit) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 9 with UnitResponse

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

the class TestIssueToken method main.

public static void main(String[] args) throws ClassNotFoundException {
    Class.forName(RedisStartup.class.getName());
    JSONObject body = new JSONObject().fluentPut("appId", "25874717e9b1807c5cfb66427f7d3c8da02ecfe4").fluentPut("appSecret", "fa090344347a2cb867833678754e461c36449dc2429e9ee228ddaf3bd1ac0330");
    UnitResponse o = new IssueAccessToken().execute(new UnitRequest().setArgMap(body));
    System.out.println(o);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitRequest(info.xiancloud.core.message.UnitRequest) UnitResponse(info.xiancloud.core.message.UnitResponse) IssueAccessToken(com.apifest.oauth20.unit.IssueAccessToken) RedisStartup(info.xiancloud.cache.startup.RedisStartup)

Example 10 with UnitResponse

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

the class DeployApplications method execute.

@Override
public UnitResponse execute(UnitRequest msg) {
    String applications = msg.getString("applications");
    UnitResponse unitResponseObject;
    if (applications != null && applications.contains("=")) {
        // todo 目前向下兼容,保留一段时间,日后deployApplications将不再支持修改副本数量
        unitResponseObject = replica(msg);
    } else
        unitResponseObject = deploy(msg);
    unitResponseObject.getContext().setPretty(true);
    return unitResponseObject;
}
Also used : 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