use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.
the class DashboardController method domainProcessCount.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/domainProcessCount")
public SuccessResponseEntity domainProcessCount(@RequestParam(required = false) String zkClusterKey) throws SaturnJobConsoleException {
if (StringUtils.isNotBlank(zkClusterKey)) {
ZkCluster zkCluster = checkAndGetZkCluster(zkClusterKey);
SaturnStatistics ss = dashboardService.allProcessAndErrorCountOfTheDay(zkCluster.getZkAddr());
return ss == null ? new SuccessResponseEntity() : new SuccessResponseEntity(ss.getResult());
}
return new SuccessResponseEntity(dashboardService.allProcessAndErrorCountOfTheDayByAllZkCluster());
}
use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.
the class MarathonController method addContainer.
@PostMapping(value = "/container")
@ResponseBody
public SuccessResponseEntity addContainer(@AuditParam("namespace") @PathVariable String namespace, AddContainerModel addContainerModel, HttpServletRequest request) throws SaturnJobConsoleException {
if (addContainerModel.getContainerToken() == null) {
throw new SaturnJobConsoleException("Please input container token");
}
marathonService.checkContainerTokenNotNull(namespace, addContainerModel.getContainerToken());
marathonService.saveOrUpdateContainerTokenIfNecessary(namespace, addContainerModel.getContainerToken());
ContainerConfig containerConfig = new ContainerConfig();
containerConfig.setTaskId(addContainerModel.getTaskId());
containerConfig.setCmd(addContainerModel.getCmd());
containerConfig.setCpus(addContainerModel.getCpus());
containerConfig.setMem(addContainerModel.getMem());
containerConfig.setInstances(addContainerModel.getInstances());
containerConfig.setConstraints(addContainerModel.getConstraints());
containerConfig.setEnv(addContainerModel.getEnv());
containerConfig.setPrivileged(addContainerModel.getPrivileged() == null ? false : addContainerModel.getPrivileged());
containerConfig.setForcePullImage(addContainerModel.getForcePullImage() == null ? true : addContainerModel.getForcePullImage());
containerConfig.setParameters(addContainerModel.getParameters());
containerConfig.setVolumes(addContainerModel.getVolumes());
containerConfig.setImage(addContainerModel.getImage());
containerConfig.setCreateTime(System.currentTimeMillis());
String imageNew = "";
String vipSaturnDcosRegistryUri = SaturnEnvProperties.VIP_SATURN_DCOS_REGISTRY_URI;
if (vipSaturnDcosRegistryUri == null || vipSaturnDcosRegistryUri.trim().length() == 0) {
throw new SaturnJobConsoleException("VIP_SATURN_DCOS_REGISTRY_URI is not configured");
} else {
if (vipSaturnDcosRegistryUri.startsWith("http://")) {
String tmp = vipSaturnDcosRegistryUri.substring("http://".length());
while (tmp.endsWith("/")) {
tmp = tmp.substring(0, tmp.length() - 1);
}
imageNew = tmp + "/" + addContainerModel.getImage();
} else if (vipSaturnDcosRegistryUri.startsWith("https://")) {
String tmp = vipSaturnDcosRegistryUri.substring("https://".length());
while (tmp.endsWith("/")) {
tmp = tmp.substring(0, tmp.length() - 1);
}
imageNew = tmp + "/" + addContainerModel.getImage();
}
}
containerConfig.setImage(imageNew);
if (containerConfig.getEnv() == null) {
containerConfig.setEnv(new HashMap<String, String>());
}
if (!containerConfig.getEnv().containsKey(SaturnEnvProperties.NAME_VIP_SATURN_ZK_CONNECTION)) {
containerConfig.getEnv().put(SaturnEnvProperties.NAME_VIP_SATURN_ZK_CONNECTION, getCurrentZkAddr(request.getSession()));
}
marathonService.addContainer(namespace, containerConfig);
return new SuccessResponseEntity();
}
use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.
the class UtilsController method getZkClusterKeys.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/zkClusterKeys")
public SuccessResponseEntity getZkClusterKeys() {
Collection<ZkCluster> zkClusters = registryCenterService.getZkClusterList();
List<String> zkClusterKeys = Lists.newArrayList();
for (ZkCluster zkCluster : zkClusters) {
zkClusterKeys.add(zkCluster.getZkClusterKey());
}
return new SuccessResponseEntity(zkClusterKeys);
}
use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.
the class ConsoleConfigController method updateConfig.
/**
* 更新配置项。
*
* @param key 配置key
* @param value 配置值
*/
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/update")
public SuccessResponseEntity updateConfig(@AuditParam(value = "key") @RequestParam String key, @AuditParam(value = "value") @RequestParam String value) throws SaturnJobConsoleException {
assertIsPermitted(PermissionKeys.systemConfig);
// 不能更新EXECUTOR_CONFIGS
if (SystemConfigProperties.EXECUTOR_CONFIGS.equals(key)) {
throw new SaturnJobConsoleException(String.format("配置项不能为%s", key));
}
SystemConfig systemConfig = new SystemConfig();
systemConfig.setProperty(key);
systemConfig.setValue(value);
systemConfigService.updateConfig(systemConfig);
return new SuccessResponseEntity();
}
use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.
the class AuthorizationController method updateUserRole.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/updateUserRole")
public SuccessResponseEntity updateUserRole(@AuditParam("preUserName") @RequestParam String preUserName, @AuditParam("preRoleKey") @RequestParam String preRoleKey, @AuditParam("preNamespace") @RequestParam String preNamespace, @AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, @AuditParam("needApproval") @RequestParam Boolean needApproval, HttpSession httpSession) throws SaturnJobConsoleException {
assertIsSystemAdmin();
String currentLoginUserName = getCurrentLoginUserName();
Date now = new Date();
UserRole pre = new UserRole();
pre.setUserName(preUserName);
pre.setRoleKey(preRoleKey);
pre.setNamespace(preNamespace);
pre.setLastUpdateTime(now);
pre.setLastUpdatedBy(currentLoginUserName);
UserRole cur = new UserRole();
cur.setUserName(userName);
cur.setRoleKey(roleKey);
cur.setNamespace(namespace);
cur.setNeedApproval(needApproval);
cur.setCreatedBy(currentLoginUserName);
cur.setCreateTime(now);
cur.setLastUpdatedBy(currentLoginUserName);
cur.setLastUpdateTime(now);
cur.setIsDeleted(false);
authorizationService.updateUserRole(pre, cur);
return new SuccessResponseEntity();
}
Aggregations