Skip to content

Commit

Permalink
[Cherry-pick-2.0.2[Feature-7460][]Feature-7451][Fix-7392] (#7483)
Browse files Browse the repository at this point in the history
* remove date+1 when the data is supplemented (#7452)

* resolve conflict

* [Fix-7392][dolphinscheduler-datasource] Add hive datasource failed (#7393)

* fix bug_7392

* fix bug_7392

* fix bug_7392

Co-authored-by: SbloodyS <[email protected]>

* cherry-pick-2.0.2

Co-authored-by: SbloodyS <[email protected]>
  • Loading branch information
SbloodyS and SbloodyS authored Dec 20, 2021
1 parent 60001f8 commit 0b6f3fb
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ public List<PluginParams> params() {
.build())
.build();

RadioParam sendType = RadioParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SEND_TYPE)
.addParamsOptions(new ParamsOptions(WeChatType.APP.getDescp(), WeChatType.APP.getDescp(), false))
.addParamsOptions(new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
.setValue(WeChatType.APP.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();

RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();

return Arrays.asList(corpIdParam, secretParam, usersParam, userSendMsgParam, agentIdParam, showType);
return Arrays.asList(corpIdParam, secretParam, usersParam, userSendMsgParam, agentIdParam, sendType, showType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public final class WeChatAlertConstants {

static final String WE_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}";

static final String WE_CHAT_APP_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token" +
"={token}";

static final String WE_CHAT_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";

private WeChatAlertConstants() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public final class WeChatAlertParamsConstants {
static final String NAME_ENTERPRISE_WE_CHAT_USERS = "users";


static final String NAME_ENTERPRISE_WE_CHAT_SEND_TYPE = "sendType";

static final String ENTERPRISE_WE_CHAT_SEND_TYPE = "send.type";


private WeChatAlertParamsConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public final class WeChatSender {
private final String weChatUserSendMsg;
private final String weChatTokenUrlReplace;
private final String weChatToken;
private final String sendType;
private final String showType;

WeChatSender(Map<String, String> config) {
Expand All @@ -62,6 +63,7 @@ public final class WeChatSender {
String weChatSecret = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET);
String weChatTokenUrl = WeChatAlertConstants.WE_CHAT_TOKEN_URL;
weChatUserSendMsg = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG);
sendType = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE);
showType = config.get(AlertConstants.NAME_SHOW_TYPE);
requireNonNull(showType, AlertConstants.NAME_SHOW_TYPE + MUST_NOT_NULL);
weChatTokenUrlReplace = weChatTokenUrl
Expand Down Expand Up @@ -247,7 +249,12 @@ public AlertResult sendEnterpriseWeChat(String title, String content) {
alertResult.setStatus(ALERT_STATUS);
return alertResult;
}
String enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
String enterpriseWeChatPushUrlReplace = "";
if (sendType.equals(WeChatType.APP.getDescp())) {
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
} else if (sendType.equals(WeChatType.APPCHAT.getDescp())) {
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
}

try {
return checkWeChatSendMsgResult(post(enterpriseWeChatPushUrlReplace, msg));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.plugin.alert.wechat;

public enum WeChatType {
APP(1, "应用"),
APPCHAT(2, "群聊"),
;

private final int code;
private final String descp;

WeChatType(int code, String descp) {
this.code = code;
this.descp = descp;
}

public int getCode() {
return code;
}

public String getDescp() {
return descp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testGetParams() {
WeChatAlertChannelFactory weChatAlertChannelFactory = new WeChatAlertChannelFactory();
List<PluginParams> params = weChatAlertChannelFactory.params();
JSONUtils.toJsonString(params);
Assert.assertEquals(6, params.size());
Assert.assertEquals(7, params.size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE;

import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient;
import org.apache.dolphinscheduler.plugin.datasource.api.provider.JdbcDataSourceProvider;
Expand Down Expand Up @@ -90,7 +91,8 @@ protected void checkEnv(BaseConnectionParam baseConnectionParam) {

private void checkKerberosEnv() {
String krb5File = PropertyUtils.getString(JAVA_SECURITY_KRB5_CONF_PATH);
if (StringUtils.isNotBlank(krb5File)) {
Boolean kerberosStartupState = PropertyUtils.getBoolean(HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false);
if (kerberosStartupState && StringUtils.isNotBlank(krb5File)) {
System.setProperty(JAVA_SECURITY_KRB5_CONF, krb5File);
try {
Config.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,6 @@ private void preBuildBusinessParams() {
// replace variable TIME with $[YYYYmmddd...] in shell file when history run job and batch complement job
if (taskExecutionContext.getScheduleTime() != null) {
Date date = taskExecutionContext.getScheduleTime();
if (CommandType.COMPLEMENT_DATA.getCode() == taskExecutionContext.getCmdTypeIfComplement()) {
date = DateUtils.add(taskExecutionContext.getScheduleTime(), DAY_OF_MONTH, 1);
}
String dateTime = DateUtils.format(date, Constants.PARAMETER_FORMAT_TIME);
Property p = new Property();
p.setValue(dateTime);
Expand Down

0 comments on commit 0b6f3fb

Please sign in to comment.