in spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/service/JobSyncService.java [172:211]
public boolean syncAppGroup(DefaultAcsClient client) throws IOException, ClientException {
if (StringUtils.isEmpty(properties.getAppName())) {
logger.error("please set {}.appName", SchedulerxProperties.CONFIG_PREFIX);
throw new IOException(String.format("please set %s.appName", SchedulerxProperties.CONFIG_PREFIX));
}
if (StringUtils.isEmpty(properties.getAppKey())) {
logger.error("please set {}.appKey", SchedulerxProperties.CONFIG_PREFIX);
throw new IOException(String.format("please set %s.appKey", SchedulerxProperties.CONFIG_PREFIX));
}
if (StringUtils.isEmpty(properties.getGroupId())) {
logger.error("please set {}.groupId", SchedulerxProperties.CONFIG_PREFIX);
throw new IOException(String.format("please set %s.groupId", SchedulerxProperties.CONFIG_PREFIX));
}
CreateAppGroupRequest request = new CreateAppGroupRequest();
request.setNamespace(properties.getNamespace());
request.setNamespaceSource(getNamespaceSource());
request.setAppName(properties.getAppName());
request.setGroupId(properties.getGroupId());
request.setAppKey(properties.getAppKey());
if (StringUtils.isNotEmpty(properties.getAlarmChannel())) {
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setSendChannel(properties.getAlarmChannel());
request.setMonitorConfigJson(JsonUtil.toJson(monitorConfig));
}
if (!properties.getAlarmUsers().isEmpty()) {
List<ContactInfo> contactInfos = new ArrayList(properties.getAlarmUsers().values());
request.setMonitorContactsJson(JsonUtil.toJson(contactInfos));
}
CreateAppGroupResponse response = client.getAcsResponse(request);
if (response.getSuccess()) {
logger.info(JsonUtil.toJson(response));
return true;
}
else {
throw new IOException(response.getMessage());
}
}