use of com.ctrip.framework.apollo.portal.entity.vo.EnvironmentInfo in project apollo by ctripcorp.
the class SystemInfoController method checkHealth.
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@GetMapping(value = "/health")
public Health checkHealth(@RequestParam String instanceId) {
List<Env> allEnvs = portalSettings.getAllEnvs();
ServiceDTO service = null;
for (final Env env : allEnvs) {
EnvironmentInfo envInfo = adaptEnv2EnvironmentInfo(env);
if (envInfo.getAdminServices() != null) {
for (final ServiceDTO s : envInfo.getAdminServices()) {
if (instanceId.equals(s.getInstanceId())) {
service = s;
break;
}
}
}
if (envInfo.getConfigServices() != null) {
for (final ServiceDTO s : envInfo.getConfigServices()) {
if (instanceId.equals(s.getInstanceId())) {
service = s;
break;
}
}
}
}
if (service == null) {
throw new IllegalArgumentException("No such instance of instanceId: " + instanceId);
}
return restTemplate.getForObject(service.getHomepageUrl() + "/health", Health.class);
}
use of com.ctrip.framework.apollo.portal.entity.vo.EnvironmentInfo in project apollo by ctripcorp.
the class SystemInfoController method getSystemInfo.
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@GetMapping
public SystemInfo getSystemInfo() {
SystemInfo systemInfo = new SystemInfo();
String version = Apollo.VERSION;
if (isValidVersion(version)) {
systemInfo.setVersion(version);
}
List<Env> allEnvList = portalSettings.getAllEnvs();
for (Env env : allEnvList) {
EnvironmentInfo environmentInfo = adaptEnv2EnvironmentInfo(env);
systemInfo.addEnvironment(environmentInfo);
}
return systemInfo;
}
use of com.ctrip.framework.apollo.portal.entity.vo.EnvironmentInfo in project apollo by ctripcorp.
the class SystemInfoController method adaptEnv2EnvironmentInfo.
private EnvironmentInfo adaptEnv2EnvironmentInfo(final Env env) {
EnvironmentInfo environmentInfo = new EnvironmentInfo();
String metaServerAddresses = portalMetaDomainService.getMetaServerAddress(env);
environmentInfo.setEnv(env);
environmentInfo.setActive(portalSettings.isEnvActive(env));
environmentInfo.setMetaServerAddress(metaServerAddresses);
String selectedMetaServerAddress = portalMetaDomainService.getDomain(env);
try {
environmentInfo.setConfigServices(getServerAddress(selectedMetaServerAddress, CONFIG_SERVICE_URL_PATH));
environmentInfo.setAdminServices(getServerAddress(selectedMetaServerAddress, ADMIN_SERVICE_URL_PATH));
} catch (Throwable ex) {
String errorMessage = "Loading config/admin services from meta server: " + selectedMetaServerAddress + " failed!";
logger.error(errorMessage, ex);
environmentInfo.setErrorMessage(errorMessage + " Exception: " + ex.getMessage());
}
return environmentInfo;
}
Aggregations