Issue #2359 add ability to ignore messages based on threads, ie ignore
shef Change-Id: I51d4b29e7accb3ce5bd90c7478c7f143bd76bb48 Former-commit-id:00a1b179a5
[formerlydb842ce2e6
] [formerly4a4f50155c
] [formerlyed1b94ea07
[formerly4a4f50155c
[formerly 4a9f2db86a148b58610680dbd2230b286d89e361]]] Former-commit-id:ed1b94ea07
Former-commit-id: fd493067b795f91fd360af45d144c60e8d2248cb [formerly3b0ed49de4
] Former-commit-id:c836673ac6
This commit is contained in:
parent
873a26a6a7
commit
a190895819
6 changed files with 62 additions and 14 deletions
|
@ -1,11 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<logSrvConfig>
|
<logSrvConfig>
|
||||||
<clusterName>ec-redbaron</clusterName>
|
<clusterName>ec-oma</clusterName>
|
||||||
<databaseDir>/awips2/edex/data/utility/nate</databaseDir>
|
<databaseDir>/awips2/edex/data/utility/nate</databaseDir>
|
||||||
<fromAddress>Nathan.Jensen@raytheon.com</fromAddress>
|
<fromAddress>Nathan.Jensen@raytheon.com</fromAddress>
|
||||||
<smtpHost>mk2-msg10.raymail.ray.com</smtpHost>
|
<smtpHost>mk2-msg10.raymail.ray.com</smtpHost>
|
||||||
<smtpPort>143</smtpPort>
|
<smtpPort>143</smtpPort>
|
||||||
<toAddress>awipsctl@list.app.ray.com, awipstest@list.app.ray.com, david_j_hladky@raytheon.com</toAddress>
|
<toAddress>awipsctl@list.app.ray.com, awipstest@list.app.ray.com, david_j_hladky@raytheon.com</toAddress>
|
||||||
<!-- >toAddress>Nathan.Jensen@raytheon.com</toAddress-->
|
<!-- >toAddress>Nathan.Jensen@raytheon.com</toAddress-->
|
||||||
<timeToSend>01:30</timeToSend>
|
<timeToSend>00:45</timeToSend>
|
||||||
|
<ignoreThreads>shefThreadPool</ignoreThreads>
|
||||||
</logSrvConfig>
|
</logSrvConfig>
|
|
@ -73,7 +73,7 @@ public class LogService {
|
||||||
LogSrvConfig config = (LogSrvConfig) m.unmarshal(new File(
|
LogSrvConfig config = (LogSrvConfig) m.unmarshal(new File(
|
||||||
SERVICE_CONFIG));
|
SERVICE_CONFIG));
|
||||||
config.validate();
|
config.validate();
|
||||||
DerbyDao.setConfig(config);
|
DerbyDao.getInstance().setConfig(config);
|
||||||
logger.info("Logging events from " + config.getClusterName());
|
logger.info("Logging events from " + config.getClusterName());
|
||||||
|
|
||||||
logger.info("Starting socket listener");
|
logger.info("Starting socket listener");
|
||||||
|
|
|
@ -68,6 +68,9 @@ public class LogSrvConfig {
|
||||||
@XmlElement
|
@XmlElement
|
||||||
private String timeToSend;
|
private String timeToSend;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
private String ignoreThreads;
|
||||||
|
|
||||||
public String getFromAddress() {
|
public String getFromAddress() {
|
||||||
return fromAddress;
|
return fromAddress;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +127,14 @@ public class LogSrvConfig {
|
||||||
this.databaseDir = databaseDir;
|
this.databaseDir = databaseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIgnoreThreads() {
|
||||||
|
return ignoreThreads;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreThreads(String ignoreThreads) {
|
||||||
|
this.ignoreThreads = ignoreThreads;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates that the config has every value set.
|
* Validates that the config has every value set.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -45,14 +45,46 @@ import com.raytheon.uf.logsrv.StoredMsg;
|
||||||
|
|
||||||
public class DerbyAppender extends AppenderBase<ILoggingEvent> {
|
public class DerbyAppender extends AppenderBase<ILoggingEvent> {
|
||||||
|
|
||||||
|
private DerbyDao dao;
|
||||||
|
|
||||||
|
private String[] ignoreThreads;
|
||||||
|
|
||||||
|
public DerbyAppender() {
|
||||||
|
super();
|
||||||
|
dao = DerbyDao.getInstance();
|
||||||
|
String ignore = dao.getConfig().getIgnoreThreads();
|
||||||
|
if (ignore != null) {
|
||||||
|
ignoreThreads = ignore.split(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void append(ILoggingEvent eventObject) {
|
protected void append(ILoggingEvent eventObject) {
|
||||||
|
if (shouldStoreMsg(eventObject)) {
|
||||||
StoredMsg msg = new StoredMsg(eventObject);
|
StoredMsg msg = new StoredMsg(eventObject);
|
||||||
try {
|
try {
|
||||||
DerbyDao.getInstance().insert(msg);
|
dao.insert(msg);
|
||||||
} catch (LogServiceException e) {
|
} catch (LogServiceException e) {
|
||||||
LogService.getLogger().error(
|
LogService.getLogger().error(
|
||||||
"Error inserting message into derby database", e);
|
"Error inserting message into derby database", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether or not the appender should store the logging event
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean shouldStoreMsg(ILoggingEvent event) {
|
||||||
|
if (ignoreThreads != null) {
|
||||||
|
for (String ignore : ignoreThreads) {
|
||||||
|
if (event.getThreadName().startsWith(ignore)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class DerbyDao {
|
||||||
|
|
||||||
private static DerbyDao instance = new DerbyDao();
|
private static DerbyDao instance = new DerbyDao();
|
||||||
|
|
||||||
private static LogSrvConfig config;
|
private LogSrvConfig config;
|
||||||
|
|
||||||
private DerbyDao() {
|
private DerbyDao() {
|
||||||
|
|
||||||
|
@ -104,10 +104,14 @@ public class DerbyDao {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setConfig(LogSrvConfig cfg) {
|
public void setConfig(LogSrvConfig cfg) {
|
||||||
config = cfg;
|
config = cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogSrvConfig getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a connection to derby
|
* Creates a connection to derby
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class TestReportOutputter {
|
||||||
LogSrvConfig config = (LogSrvConfig) m
|
LogSrvConfig config = (LogSrvConfig) m
|
||||||
.unmarshal(new File("config.xml"));
|
.unmarshal(new File("config.xml"));
|
||||||
config.validate();
|
config.validate();
|
||||||
DerbyDao.setConfig(config);
|
DerbyDao.getInstance().setConfig(config);
|
||||||
LogReportContainer container = DerbyDao.getInstance().buildReport();
|
LogReportContainer container = DerbyDao.getInstance().buildReport();
|
||||||
String report = HtmlGenerator.generateHtml(container);
|
String report = HtmlGenerator.generateHtml(container);
|
||||||
ReportEmailer.email(report, config);
|
ReportEmailer.email(report, config);
|
||||||
|
|
Loading…
Add table
Reference in a new issue