[
https://issues.apache.org/jira/browse/KYLIN-4780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17302593#comment-17302593
]
ASF GitHub Bot commented on KYLIN-4780:
---------------------------------------
yanghua commented on a change in pull request #1596:
URL: https://github.com/apache/kylin/pull/1596#discussion_r595086240
##########
File path:
core-common/src/main/java/org/apache/kylin/common/notify/NotifyServiceBase.java
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.kylin.common.notify;
+
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.Pair;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+public abstract class NotifyServiceBase implements Callable<Boolean> {
+
+ private NotificationContext notificationContext;
+
+ private KylinConfig config;
+
+ /**
+ * Notification recipient,include email and dingTalk
+ */
+ private Map<String, List<String>> receivers;
+
+ /**
+ * state of job
+ */
+ private String state;
+
+ /**
+ * content of notification, include title and detail
+ */
+ private Pair<String[], Map<String, Object>> content;
+
+ /**
+ * only when send email and isHtmlMsg is false, subject and info will be
used
+ */
+ private String subject;
+
+ private String info;
Review comment:
IMO, the context object contains these fields, right? Let's reduce the
duplicated definition.
##########
File path:
core-common/src/main/java/org/apache/kylin/common/notify/util/NotificationConstants.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.kylin.common.notify.util;
+
+public class NotificationConstants {
+ public static final String NOTIFY_EMAIL_LIST = "notify_email_list";
+ public static final String NOTIFY_DINGTALK_LIST = "notify_dingtalk_list";
Review comment:
Can we use one constant(config option) to represent different services?
##########
File path:
core-common/src/main/java/org/apache/kylin/common/notify/NotifyServiceBase.java
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.kylin.common.notify;
+
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.Pair;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+public abstract class NotifyServiceBase implements Callable<Boolean> {
+
+ private NotificationContext notificationContext;
+
+ private KylinConfig config;
+
+ /**
+ * Notification recipient,include email and dingTalk
+ */
+ private Map<String, List<String>> receivers;
+
+ /**
+ * state of job
+ */
+ private String state;
+
+ /**
+ * content of notification, include title and detail
+ */
+ private Pair<String[], Map<String, Object>> content;
+
+ /**
+ * only when send email and isHtmlMsg is false, subject and info will be
used
+ */
+ private String subject;
+
+ private String info;
+
+ public abstract boolean sendNotification();
+
+ public NotifyServiceBase(NotificationContext notificationContext) {
+ this.notificationContext = notificationContext;
+ this.config = notificationContext.getConfig();
+ this.receivers = notificationContext.getReceivers();
+ this.state = notificationContext.getState();
+ this.content = notificationContext.getContent();
+ this.subject = notificationContext.getSubject();
Review comment:
If the fields exist in the context, we do not need to extract them into
this class.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Refactor AbstractExecutable to extract the notification relevant business
> logic into a single component
> -------------------------------------------------------------------------------------------------------
>
> Key: KYLIN-4780
> URL: https://issues.apache.org/jira/browse/KYLIN-4780
> Project: Kylin
> Issue Type: Improvement
> Components: Integration
> Reporter: vinoyang
> Assignee: chenjie
> Priority: Major
>
> Currently, Kylin supports mail service to know the change around the cube.
> However, there are some issues about the design, e.g.
> * AbstractExecutable contains an implementation of the mechanism of a
> notification listener, but only support mail service, it does not belong
> there;
> * The current implementation is hard to scale to other notification e.g.
> Ding Talk(which is a popular production supports by Alibaba)
> I propose to refactor the current implementation to extract the notification
> logic and redesign a new common notification/listener
--
This message was sent by Atlassian Jira
(v8.3.4#803005)