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);
}
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异常");
}
}
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);
}
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);
}
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;
}
Aggregations