use of com.szmirren.vxApi.core.enums.HTTPStatusCodeMsgEnum in project VX-API-Gateway by EliMirren.
the class ClientVerticle method deployAPP.
/**
* 启动应用
*
* @param rct
*/
public void deployAPP(RoutingContext rct) {
String name = rct.request().getParam("name");
LOG.info("执行启动应用-->" + name + "...");
HttpServerResponse response = rct.response().putHeader(CONTENT_TYPE, CONTENT_VALUE_JSON_UTF8);
if (StrUtil.isNullOrEmpty(name)) {
response.end(ResultFormat.formatAsZero(HTTPStatusCodeMsgEnum.C1404));
} else {
vertx.eventBus().<JsonObject>send(thisVertxName + VxApiEventBusAddressConstant.GET_APP, name, body -> {
if (body.succeeded()) {
if (body.result().body().isEmpty()) {
response.end(ResultFormat.formatAsZero(HTTPStatusCodeMsgEnum.C1404));
} else {
JsonObject app = new JsonObject(body.result().body().getString("content"));
JsonObject config = new JsonObject();
config.put("app", app);
config.put("appName", name);
vertx.eventBus().<String>send(thisVertxName + VxApiEventBusAddressConstant.DEPLOY_APP_DEPLOY, config, deploy -> {
if (deploy.succeeded()) {
LOG.info("启动应用-->" + name + ":成功!");
response.end(ResultFormat.formatAsOne(HTTPStatusCodeMsgEnum.C200));
if (vertx.isClustered()) {
vertx.eventBus().publish(VxApiEventBusAddressConstant.DEPLOY_APP_DEPLOY, config.copy().put("thisVertxName", thisVertxName));
LOG.info("广播告诉集群环境中启动应用:" + name);
}
} else {
LOG.error("启动应用-->" + name + " 失败:" + deploy.cause());
HTTPStatusCodeMsgEnum msgCode = HTTPStatusCodeMsgEnum.C500;
if (deploy.cause() != null && deploy.cause() instanceof ReplyException) {
ReplyException cause = (ReplyException) deploy.cause();
if (cause.failureCode() == 1111) {
msgCode = HTTPStatusCodeMsgEnum.C1111;
}
}
response.end(ResultFormat.formatAsZero(msgCode));
}
});
}
} else {
LOG.error("启动应用-->" + name + " 失败:" + body.cause());
System.out.println("启动应用-->" + name + " 失败:" + body.cause());
response.end(ResultFormat.formatAsZero(HTTPStatusCodeMsgEnum.C500));
}
});
}
}
Aggregations