Skip to content

Commit

Permalink
[improvement] enable alert config when service installed
Browse files Browse the repository at this point in the history
  • Loading branch information
datasophon committed Jul 27, 2023
1 parent ba2d1b4 commit 84e482a
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class ServiceCommandActor extends UntypedActor {

private static final String HTTPS = "https";

private static final String NODE = "NODE";

@Override
public void preRestart(Throwable reason, Option<Object> message) throws Exception {
logger.info("service command actor restart because {}", reason.getMessage());
Expand Down Expand Up @@ -130,7 +132,7 @@ public void onReceive(Object msg) throws Throwable {
String serviceName = command.getServiceName();
ClusterInfoEntity clusterInfo = clusterInfoService.getById(command.getClusterId());

if(command.getCommandType() == 4 && HDFS.equals(serviceName.toLowerCase())){
if (command.getCommandType() == 4 && HDFS.equals(serviceName.toLowerCase())) {
//update web ui
updateHDFSWebUi(clusterInfo.getId(), command.getServiceInstanceId());
}
Expand Down Expand Up @@ -167,13 +169,9 @@ public void onReceive(Object msg) throws Throwable {
prometheusConfigCommand.setClusterFrame(clusterInfo.getClusterFrame());
prometheusConfigCommand.setClusterId(clusterInfo.getId());
prometheusActor.tell(prometheusConfigCommand, getSelf());
enableAlertConfig(NODE, clusterInfo.getId());
}
ClusterAlertQuotaService alertQuotaService =
SpringTool.getApplicationContext().getBean(ClusterAlertQuotaService.class);
List<ClusterAlertQuota> list = alertQuotaService.listAlertQuotaByServiceName(serviceName);
List<Integer> ids = list.stream().map(e -> e.getId()).collect(Collectors.toList());
String alertQuotaIds = StringUtils.join(ids, ",");
alertQuotaService.start(clusterInfo.getId(), alertQuotaIds);
enableAlertConfig(serviceName, clusterInfo.getId());
}
List<ClusterServiceCommandHostEntity> list =
commandHostService.findFailedCommandHost(message.getCommandId());
Expand All @@ -194,6 +192,15 @@ public void onReceive(Object msg) throws Throwable {
}
}

private void enableAlertConfig(String serviceName, Integer clusterId) {
ClusterAlertQuotaService alertQuotaService =
SpringTool.getApplicationContext().getBean(ClusterAlertQuotaService.class);
List<ClusterAlertQuota> list = alertQuotaService.listAlertQuotaByServiceName(serviceName);
List<Integer> ids = list.stream().map(e -> e.getId()).collect(Collectors.toList());
String alertQuotaIds = StringUtils.join(ids, ",");
alertQuotaService.start(clusterId, alertQuotaIds);
}

private void updateHDFSWebUi(Integer clusterId, Integer serviceInstanceId) {
Map<String, String> variables = GlobalVariables.get(clusterId);
if (variables.containsKey(ENABLE_HDFS_KERBEROS)) {
Expand Down

0 comments on commit 84e482a

Please sign in to comment.