Browse Source

Merge remote-tracking branch 'upstream/dev' into spilit

pull/3/MERGE
lenboo 4 years ago
parent
commit
52beecb4d7
  1. 23
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
  2. 24
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java
  3. 9
      dolphinscheduler-dist/src/main/assembly/dolphinscheduler-binary.xml
  4. 8
      dolphinscheduler-dist/src/main/assembly/dolphinscheduler-nginx.xml
  5. 4
      dolphinscheduler-server/src/main/resources/worker.properties
  6. 2
      dolphinscheduler-ui/src/js/conf/login/App.vue

23
dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java

@ -23,9 +23,7 @@ import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.commons.codec.binary.StringUtils; import org.apache.commons.codec.binary.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
@ -71,11 +69,6 @@ public class FeiShuSender {
} }
private static RequestConfig getProxyConfig(String proxy, int port) {
HttpHost httpProxy = new HttpHost(proxy, port);
return RequestConfig.custom().setProxy(httpProxy).build();
}
private static String textToJsonString(AlertData alertData) { private static String textToJsonString(AlertData alertData) {
Map<String, Object> items = new HashMap<>(2); Map<String, Object> items = new HashMap<>(2);
@ -88,7 +81,7 @@ public class FeiShuSender {
return JSONUtils.toJsonString(items); return JSONUtils.toJsonString(items);
} }
private static AlertResult checkSendFeiShuSendMsgResult(String result) { public static AlertResult checkSendFeiShuSendMsgResult(String result) {
AlertResult alertResult = new AlertResult(); AlertResult alertResult = new AlertResult();
alertResult.setStatus("false"); alertResult.setStatus("false");
@ -116,12 +109,10 @@ public class FeiShuSender {
public static String formatContent(AlertData alertData) { public static String formatContent(AlertData alertData) {
if (alertData.getContent() != null) { if (alertData.getContent() != null) {
List<Map> list;
try { List<Map> list = JSONUtils.toList(alertData.getContent(), Map.class);
list = JSONUtils.toList(alertData.getContent(), Map.class); if (list.isEmpty()) {
} catch (Exception e) { return alertData.getTitle() + alertData.getContent();
logger.error("json format exception", e);
return null;
} }
StringBuilder contents = new StringBuilder(100); StringBuilder contents = new StringBuilder(100);
@ -170,7 +161,7 @@ public class FeiShuSender {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) { if (statusCode != HttpStatus.SC_OK) {
logger.error("send feishu message error, return http status code: " + statusCode); logger.error("send feishu message error, return http status code: {} ", statusCode);
} }
String resp; String resp;
try { try {
@ -180,7 +171,7 @@ public class FeiShuSender {
} finally { } finally {
response.close(); response.close();
} }
logger.info("Ding Talk send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp); logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp);
return resp; return resp;
} finally { } finally {
httpClient.close(); httpClient.close();

24
dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java

@ -72,4 +72,28 @@ public class FeiShuSenderTest {
alertData.setContent(alertMsg); alertData.setContent(alertMsg);
Assert.assertNotNull(FeiShuSender.formatContent(alertData)); Assert.assertNotNull(FeiShuSender.formatContent(alertData));
} }
@Test
public void testSendWithFormatException() {
AlertData alertData = new AlertData();
alertData.setTitle("feishu test title");
alertData.setContent("feishu test content");
FeiShuSender feiShuSender = new FeiShuSender(feiShuConfig);
String alertResult = feiShuSender.formatContent(alertData);
Assert.assertEquals(alertResult, alertData.getTitle() + alertData.getContent());
}
@Test
public void testCheckSendFeiShuSendMsgResult() {
FeiShuSender feiShuSender = new FeiShuSender(feiShuConfig);
AlertResult alertResult = feiShuSender.checkSendFeiShuSendMsgResult("");
Assert.assertFalse(Boolean.valueOf(alertResult.getStatus()));
AlertResult alertResult2 = feiShuSender.checkSendFeiShuSendMsgResult("123");
Assert.assertEquals("send fei shu msg fail",alertResult2.getMessage());
String response = "{\"StatusCode\":\"0\",\"extra\":\"extra\",\"StatusMessage\":\"StatusMessage\"}";
AlertResult alertResult3 = feiShuSender.checkSendFeiShuSendMsgResult(response);
Assert.assertTrue(Boolean.valueOf(alertResult3.getStatus()));
}
} }

9
dolphinscheduler-dist/src/main/assembly/dolphinscheduler-binary.xml vendored

@ -151,6 +151,15 @@
<outputDirectory>.</outputDirectory> <outputDirectory>.</outputDirectory>
</fileSet> </fileSet>
<!--alert plugin-->
<fileSet>
<directory>${basedir}/../dolphinscheduler-dist/target/dolphinscheduler-dist-${project.version}</directory>
<includes>
<include>**/*.*</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet> <fileSet>
<directory>${basedir}/../dolphinscheduler-ui/dist</directory> <directory>${basedir}/../dolphinscheduler-ui/dist</directory>
<includes> <includes>

8
dolphinscheduler-dist/src/main/assembly/dolphinscheduler-nginx.xml vendored

@ -150,6 +150,14 @@
</includes> </includes>
<outputDirectory>.</outputDirectory> <outputDirectory>.</outputDirectory>
</fileSet> </fileSet>
<!--alert plugin-->
<fileSet>
<directory>${basedir}/../dolphinscheduler-dist/target/dolphinscheduler-dist-${project.version}</directory>
<includes>
<include>**/*.*</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet> <fileSet>
<directory>${basedir}/../dolphinscheduler-ui/dist</directory> <directory>${basedir}/../dolphinscheduler-ui/dist</directory>

4
dolphinscheduler-server/src/main/resources/worker.properties

@ -28,13 +28,13 @@
#worker.reserved.memory=0.3 #worker.reserved.memory=0.3
# worker listener port # worker listener port
#worker.listen.port: 1234 #worker.listen.port=1234
# default worker group # default worker group
#worker.groups=default #worker.groups=default
# default worker weight # default worker weight
#work.weight=100 #worker.weight=100
# alert server listener host # alert server listener host
alert.listen.host=localhost alert.listen.host=localhost

2
dolphinscheduler-ui/src/js/conf/login/App.vue

@ -31,7 +31,7 @@
@keyup.enter.native="_ok"> @keyup.enter.native="_ok">
</el-input> </el-input>
</div> </div>
<p class="error" v-if="isUserPassword"> <p class="error" v-if="isUserName">
{{userNameText}} {{userNameText}}
</p> </p>
</div> </div>

Loading…
Cancel
Save