提交 a53bbbbc 编写于 作者: Y yong.you

modify the cat init error

上级 11e1eb81
......@@ -13,6 +13,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.unidal.lookup.annotation.Inject;
import com.dianping.cat.Cat;
import com.dianping.cat.configuration.ServerConfigManager;
public class FileSystemManager implements Initializable {
......@@ -116,7 +117,8 @@ public class FileSystemManager implements Initializable {
m_config = getHdfsConfiguration();
SecurityUtil.login(m_config, "dfs.cat.keytab.file", "dfs.cat.kerberos.principal");
} catch (IOException e) {
throw new InitializationException("init FileSystemManager fail", e);
Cat.logError(e);
//throw new InitializationException("init FileSystemManager fail", e);
}
} else {
m_config = new Configuration();
......
......@@ -53,7 +53,6 @@ public class ThresholdRuleManager implements Initializable {
private ThresholdRule addExceptionRule(AlarmRule rule, ThresholdTemplate template) {
String domain = rule.getDomain();
ThresholdRule thresholdRule = new ThresholdRule(rule.getId(), domain, template);
ArrayList<ThresholdRule> rules = m_exceptionRules.get(domain);
if (rules == null) {
......@@ -70,7 +69,6 @@ public class ThresholdRuleManager implements Initializable {
private ThresholdRule addServiceRule(AlarmRule rule, ThresholdTemplate template) {
String domain = rule.getDomain();
ThresholdRule thresholdRule = new ThresholdRule(rule.getId(), domain, template);
ArrayList<ThresholdRule> rules = m_serviceRules.get(domain);
if (rules == null) {
......
......@@ -7,8 +7,6 @@ import java.util.Map;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.unidal.lookup.annotation.Inject;
......@@ -36,27 +34,33 @@ public class MailSMSImpl implements MailSMS, Initializable, LogEnabled {
private SMSService m_smsService;
private boolean m_initialize = false;;
@Override
public void enableLogging(Logger logger) {
m_logger = logger;
}
@Override
public void initialize() throws InitializationException {
public void initialize() {
if (m_serverConfig.isJobMachine() && !m_serverConfig.isLocalMode()) {
try {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring/remoteService.xml");
m_mailService = (MailService) ctx.getBean("mailService");
m_smsService = (SMSService) ctx.getBean("smsService");
} catch (BeansException e) {
throw new RuntimeException(e);
m_initialize = true;
} catch (Exception e) {
Cat.logError(e);
}
}
}
@Override
public boolean sendEmail(String title, String content, List<String> emails) {
if (!m_initialize) {
initialize();
}
boolean sendResult = false;
if (m_serverConfig.isJobMachine()) {
......@@ -81,6 +85,9 @@ public class MailSMSImpl implements MailSMS, Initializable, LogEnabled {
@Override
public boolean sendSMS(String content, List<String> phones) {
if (!m_initialize) {
initialize();
}
boolean sendResult = false;
if (m_serverConfig.isJobMachine()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册