Search in sources :

Example 1 with AlarmRuleParameter

use of com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter in project otter by alibaba.

the class AlarmRuleServiceImpl method modelToDo.

private AlarmRuleDO modelToDo(AlarmRule alarmRule) {
    AlarmRuleDO alarmRuleDo = new AlarmRuleDO();
    alarmRuleDo.setId(alarmRule.getId());
    alarmRuleDo.setMatchValue(alarmRule.getMatchValue());
    alarmRuleDo.setMonitorName(alarmRule.getMonitorName());
    alarmRuleDo.setReceiverKey(alarmRule.getReceiverKey());
    alarmRuleDo.setPipelineId(alarmRule.getPipelineId());
    alarmRuleDo.setStatus(alarmRule.getStatus());
    alarmRuleDo.setDescription(alarmRule.getDescription());
    alarmRuleDo.setGmtCreate(alarmRule.getGmtCreate());
    alarmRuleDo.setGmtModified(alarmRule.getGmtModified());
    AlarmRuleParameter alarmRuleParameter = new AlarmRuleParameter();
    alarmRuleParameter.setIntervalTime(alarmRule.getIntervalTime());
    if (alarmRule.getPauseTime() != null) {
        SimpleDateFormat format = new SimpleDateFormat(TIMESTAMP_FORMAT);
        alarmRuleParameter.setPauseTime(format.format(alarmRule.getPauseTime()));
    }
    alarmRuleParameter.setAutoRecovery(alarmRule.getAutoRecovery());
    alarmRuleParameter.setRecoveryThresold(alarmRule.getRecoveryThresold());
    alarmRuleDo.setAlarmRuleParameter(alarmRuleParameter);
    return alarmRuleDo;
}
Also used : AlarmRuleDO(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleDO) AlarmRuleParameter(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with AlarmRuleParameter

use of com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter in project otter by alibaba.

the class AlarmRuleServiceImpl method switchAlarmRuleStatus.

private void switchAlarmRuleStatus(Long alarmRuleId, AlarmRuleStatus alarmRuleStatus, String pauseTime) {
    AlarmRuleDO alarmRuleDo = alarmRuleDao.findById(alarmRuleId);
    if (null == alarmRuleDo) {
        String exceptionCause = "query alarmRule:" + alarmRuleId + " return null.";
        logger.error("ERROR ## " + exceptionCause);
        throw new ManagerException(exceptionCause);
    }
    alarmRuleDo.setStatus(alarmRuleStatus);
    if (alarmRuleDo.getAlarmRuleParameter() != null) {
        alarmRuleDo.getAlarmRuleParameter().setPauseTime(pauseTime);
    } else if (StringUtils.isNotEmpty(pauseTime)) {
        alarmRuleDo.setAlarmRuleParameter(new AlarmRuleParameter());
        alarmRuleDo.getAlarmRuleParameter().setPauseTime(pauseTime);
    }
    alarmRuleDao.update(alarmRuleDo);
}
Also used : AlarmRuleDO(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleDO) AlarmRuleParameter(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Aggregations

AlarmRuleDO (com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleDO)2 AlarmRuleParameter (com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter)2 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 SimpleDateFormat (java.text.SimpleDateFormat)1