|
|
@ -30,6 +30,7 @@ import org.apache.dolphinscheduler.common.thread.Stopper; |
|
|
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.AlertDao; |
|
|
|
import org.apache.dolphinscheduler.dao.AlertDao; |
|
|
|
import org.apache.dolphinscheduler.dao.DaoFactory; |
|
|
|
import org.apache.dolphinscheduler.dao.DaoFactory; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.PluginDao; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Alert; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Alert; |
|
|
|
import org.apache.dolphinscheduler.remote.NettyRemotingServer; |
|
|
|
import org.apache.dolphinscheduler.remote.NettyRemotingServer; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandType; |
|
|
|
import org.apache.dolphinscheduler.remote.command.CommandType; |
|
|
@ -47,7 +48,14 @@ import com.google.common.collect.ImmutableList; |
|
|
|
* alert of start |
|
|
|
* alert of start |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class AlertServer { |
|
|
|
public class AlertServer { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(AlertServer.class); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(AlertServer.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Plugin Dao |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private PluginDao pluginDao = DaoFactory.getDaoInstance(PluginDao.class); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Alert Dao |
|
|
|
* Alert Dao |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -55,8 +63,6 @@ public class AlertServer { |
|
|
|
|
|
|
|
|
|
|
|
private AlertSender alertSender; |
|
|
|
private AlertSender alertSender; |
|
|
|
|
|
|
|
|
|
|
|
private static AlertServer instance; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AlertPluginManager alertPluginManager; |
|
|
|
private AlertPluginManager alertPluginManager; |
|
|
|
|
|
|
|
|
|
|
|
private DolphinPluginManagerConfig alertPluginManagerConfig; |
|
|
|
private DolphinPluginManagerConfig alertPluginManagerConfig; |
|
|
@ -78,13 +84,19 @@ public class AlertServer { |
|
|
|
|
|
|
|
|
|
|
|
public static final AlertServer getInstance() { |
|
|
|
public static final AlertServer getInstance() { |
|
|
|
return AlertServerHolder.INSTANCE; |
|
|
|
return AlertServerHolder.INSTANCE; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AlertServer() { |
|
|
|
private AlertServer() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkTable() { |
|
|
|
|
|
|
|
if (!pluginDao.checkPluginDefineTableExist()) { |
|
|
|
|
|
|
|
logger.error("Plugin Define Table t_ds_plugin_define Not Exist . Please Create it First !"); |
|
|
|
|
|
|
|
System.exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initPlugin() { |
|
|
|
private void initPlugin() { |
|
|
|
alertPluginManager = new AlertPluginManager(); |
|
|
|
alertPluginManager = new AlertPluginManager(); |
|
|
|
alertPluginManagerConfig = new DolphinPluginManagerConfig(); |
|
|
|
alertPluginManagerConfig = new DolphinPluginManagerConfig(); |
|
|
@ -101,7 +113,7 @@ public class AlertServer { |
|
|
|
try { |
|
|
|
try { |
|
|
|
alertPluginLoader.loadPlugins(); |
|
|
|
alertPluginLoader.loadPlugins(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException("load Alert Plugin Failed !", e); |
|
|
|
throw new RuntimeException("Load Alert Plugin Failed !", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -128,7 +140,7 @@ public class AlertServer { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (alertPluginManager == null || alertPluginManager.getAlertChannelMap().size() == 0) { |
|
|
|
if (alertPluginManager == null || alertPluginManager.getAlertChannelMap().size() == 0) { |
|
|
|
logger.warn("No Alert Plugin . Can not send alert info. "); |
|
|
|
logger.warn("No Alert Plugin . Cannot send alert info. "); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
List<Alert> alerts = alertDao.listWaitExecutionAlert(); |
|
|
|
List<Alert> alerts = alertDao.listWaitExecutionAlert(); |
|
|
|
alertSender = new AlertSender(alerts, alertDao, alertPluginManager); |
|
|
|
alertSender = new AlertSender(alerts, alertDao, alertPluginManager); |
|
|
@ -142,6 +154,7 @@ public class AlertServer { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void start() { |
|
|
|
public void start() { |
|
|
|
PropertyUtils.loadPropertyFile(ALERT_PROPERTIES_PATH); |
|
|
|
PropertyUtils.loadPropertyFile(ALERT_PROPERTIES_PATH); |
|
|
|
|
|
|
|
checkTable(); |
|
|
|
initPlugin(); |
|
|
|
initPlugin(); |
|
|
|
initRemoteServer(); |
|
|
|
initRemoteServer(); |
|
|
|
logger.info("alert server ready start "); |
|
|
|
logger.info("alert server ready start "); |
|
|
|