Browse Source
* #3299 Json string parsing problem caused by non-standard json format. * #3299 Json string parsing problem caused by non-standard json format. * #3299 Json string parsing problem caused by non-standard json format. fix code style * #3299 Json string parsing problem caused by non-standard json format. fix code style * Optimize alarm information * fix code style * add license * fix code smell * Update dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java Co-authored-by: Yichao Yang <1048262223@qq.com> * fix code smell * fix code smell * 修改ut 和replace问题。 * 修改ut Co-authored-by: wangjianda <Felix@thinkingdata.com> Co-authored-by: Yichao Yang <1048262223@qq.com>pull/3/MERGE
felix.wang
4 years ago
committed by
GitHub
8 changed files with 625 additions and 237 deletions
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.common.enums; |
||||||
|
|
||||||
|
public enum AlertEvent { |
||||||
|
|
||||||
|
SERVER_DOWN,TIME_OUT |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.common.enums; |
||||||
|
|
||||||
|
public enum AlertWarnLevel { |
||||||
|
|
||||||
|
MIDDLE,SERIOUS |
||||||
|
} |
@ -0,0 +1,236 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.dao.entity; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.enums.AlertEvent; |
||||||
|
import org.apache.dolphinscheduler.common.enums.AlertWarnLevel; |
||||||
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
||||||
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; |
||||||
|
import org.apache.dolphinscheduler.common.enums.Flag; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude; |
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude.Include; |
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
|
||||||
|
@JsonInclude(Include.NON_NULL) |
||||||
|
public class ProcessAlertContent implements Serializable { |
||||||
|
@JsonProperty("processId") |
||||||
|
private int processId; |
||||||
|
@JsonProperty("processName") |
||||||
|
private String processName; |
||||||
|
@JsonProperty("processType") |
||||||
|
private CommandType processType; |
||||||
|
@JsonProperty("processState") |
||||||
|
private ExecutionStatus processState; |
||||||
|
@JsonProperty("recovery") |
||||||
|
private Flag recovery; |
||||||
|
@JsonProperty("runTimes") |
||||||
|
private int runTimes; |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
@JsonProperty("processStartTime") |
||||||
|
private Date processStartTime; |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
@JsonProperty("processEndTime") |
||||||
|
private Date processEndTime; |
||||||
|
@JsonProperty("processHost") |
||||||
|
private String processHost; |
||||||
|
@JsonProperty("taskId") |
||||||
|
private int taskId; |
||||||
|
@JsonProperty("taskName") |
||||||
|
private String taskName; |
||||||
|
@JsonProperty("event") |
||||||
|
private AlertEvent event; |
||||||
|
@JsonProperty("warnLevel") |
||||||
|
private AlertWarnLevel warnLevel; |
||||||
|
@JsonProperty("taskType") |
||||||
|
private String taskType; |
||||||
|
@JsonProperty("retryTimes") |
||||||
|
private int retryTimes; |
||||||
|
@JsonProperty("taskState") |
||||||
|
private ExecutionStatus taskState; |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
@JsonProperty("taskStartTime") |
||||||
|
private Date taskStartTime; |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
@JsonProperty("taskEndTime") |
||||||
|
private Date taskEndTime; |
||||||
|
@JsonProperty("taskHost") |
||||||
|
private String taskHost; |
||||||
|
@JsonProperty("logPath") |
||||||
|
private String logPath; |
||||||
|
|
||||||
|
private ProcessAlertContent(Builder builder) { |
||||||
|
this.processId = builder.processId; |
||||||
|
this.processName = builder.processName; |
||||||
|
this.processType = builder.processType; |
||||||
|
this.recovery = builder.recovery; |
||||||
|
this.processState = builder.processState; |
||||||
|
this.runTimes = builder.runTimes; |
||||||
|
this.processStartTime = builder.processStartTime; |
||||||
|
this.processEndTime = builder.processEndTime; |
||||||
|
this.processHost = builder.processHost; |
||||||
|
this.taskId = builder.taskId; |
||||||
|
this.taskName = builder.taskName; |
||||||
|
this.event = builder.event; |
||||||
|
this.warnLevel = builder.warnLevel; |
||||||
|
this.taskType = builder.taskType; |
||||||
|
this.taskState = builder.taskState; |
||||||
|
this.taskStartTime = builder.taskStartTime; |
||||||
|
this.taskEndTime = builder.taskEndTime; |
||||||
|
this.taskHost = builder.taskHost; |
||||||
|
this.logPath = builder.logPath; |
||||||
|
this.retryTimes = builder.retryTimes; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static Builder newBuilder() { |
||||||
|
return new Builder(); |
||||||
|
} |
||||||
|
|
||||||
|
public static class Builder { |
||||||
|
|
||||||
|
private int processId; |
||||||
|
private String processName; |
||||||
|
private CommandType processType; |
||||||
|
private Flag recovery; |
||||||
|
private ExecutionStatus processState; |
||||||
|
private int runTimes; |
||||||
|
private Date processStartTime; |
||||||
|
private Date processEndTime; |
||||||
|
private String processHost; |
||||||
|
private int taskId; |
||||||
|
private String taskName; |
||||||
|
private AlertEvent event; |
||||||
|
private AlertWarnLevel warnLevel; |
||||||
|
private String taskType; |
||||||
|
private int retryTimes; |
||||||
|
private ExecutionStatus taskState; |
||||||
|
private Date taskStartTime; |
||||||
|
private Date taskEndTime; |
||||||
|
private String taskHost; |
||||||
|
private String logPath; |
||||||
|
|
||||||
|
public Builder processId(int processId) { |
||||||
|
this.processId = processId; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processName(String processName) { |
||||||
|
this.processName = processName; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processType(CommandType processType) { |
||||||
|
this.processType = processType; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder recovery(Flag recovery) { |
||||||
|
this.recovery = recovery; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processState(ExecutionStatus processState) { |
||||||
|
this.processState = processState; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder runTimes(int runTimes) { |
||||||
|
this.runTimes = runTimes; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processStartTime(Date processStartTime) { |
||||||
|
this.processStartTime = processStartTime; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processEndTime(Date processEndTime) { |
||||||
|
this.processEndTime = processEndTime; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder processHost(String processHost) { |
||||||
|
this.processHost = processHost; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskId(int taskId) { |
||||||
|
this.taskId = taskId; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskName(String taskName) { |
||||||
|
this.taskName = taskName; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder event(AlertEvent event) { |
||||||
|
this.event = event; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder warningLevel(AlertWarnLevel warnLevel) { |
||||||
|
this.warnLevel = warnLevel; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskType(String taskType) { |
||||||
|
this.taskType = taskType; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder retryTimes(int retryTimes) { |
||||||
|
this.retryTimes = retryTimes; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskState(ExecutionStatus taskState) { |
||||||
|
this.taskState = taskState; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskStartTime(Date taskStartTime) { |
||||||
|
this.taskStartTime = taskStartTime; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskEndTime(Date taskEndTime) { |
||||||
|
this.taskEndTime = taskEndTime; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder taskHost(String taskHost) { |
||||||
|
this.taskHost = taskHost; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder logPath(String logPath) { |
||||||
|
this.logPath = logPath; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public ProcessAlertContent build() { |
||||||
|
return new ProcessAlertContent(this); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.dao.entity; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.enums.AlertEvent; |
||||||
|
import org.apache.dolphinscheduler.common.enums.AlertWarnLevel; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
|
||||||
|
public class ServerAlertContent { |
||||||
|
|
||||||
|
/** |
||||||
|
* server type :master or worker |
||||||
|
*/ |
||||||
|
@JsonProperty("type") |
||||||
|
final String type; |
||||||
|
@JsonProperty("host") |
||||||
|
final String host; |
||||||
|
@JsonProperty("event") |
||||||
|
final AlertEvent event; |
||||||
|
@JsonProperty("warningLevel") |
||||||
|
final AlertWarnLevel warningLevel; |
||||||
|
|
||||||
|
private ServerAlertContent(Builder builder) { |
||||||
|
this.type = builder.type; |
||||||
|
this.host = builder.host; |
||||||
|
this.event = builder.event; |
||||||
|
this.warningLevel = builder.warningLevel; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static Builder newBuilder() { |
||||||
|
return new Builder(); |
||||||
|
} |
||||||
|
|
||||||
|
public static class Builder { |
||||||
|
private String type; |
||||||
|
|
||||||
|
private String host; |
||||||
|
|
||||||
|
private AlertEvent event; |
||||||
|
|
||||||
|
private AlertWarnLevel warningLevel; |
||||||
|
|
||||||
|
public Builder type(String type) { |
||||||
|
this.type = type; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder host(String host) { |
||||||
|
this.host = host; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder event(AlertEvent event) { |
||||||
|
this.event = event; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder warningLevel(AlertWarnLevel warningLevel) { |
||||||
|
this.warningLevel = warningLevel; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public ServerAlertContent build() { |
||||||
|
return new ServerAlertContent(this); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue