Add more verbose logging to SQLMetadataRuleManager

This commit is contained in:
Charles Allen 2015-10-21 16:11:40 -07:00
parent b7c68ec449
commit 1cad571354
2 changed files with 21 additions and 1 deletions

View File

@ -89,4 +89,14 @@ public class AuditInfo
result = 31 * result + ip.hashCode(); result = 31 * result + ip.hashCode();
return result; return result;
} }
@Override
public String toString()
{
return "AuditInfo{" +
"author='" + author + '\'' +
", comment='" + comment + '\'' +
", ip='" + ip + '\'' +
'}';
}
} }

View File

@ -18,6 +18,7 @@
package io.druid.metadata; package io.druid.metadata;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -334,6 +335,15 @@ public class SQLMetadataRuleManager implements MetadataRuleManager
public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo) public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
{ {
final String ruleString;
try {
ruleString = jsonMapper.writeValueAsString(newRules);
log.info("Updating [%s] with rules [%s] as per [%s]", dataSource, ruleString, auditInfo);
}
catch (JsonProcessingException e) {
log.error(e, "Unable to write rules as string for [%s]", dataSource);
return false;
}
synchronized (lock) { synchronized (lock) {
try { try {
dbi.inTransaction( dbi.inTransaction(
@ -348,7 +358,7 @@ public class SQLMetadataRuleManager implements MetadataRuleManager
.key(dataSource) .key(dataSource)
.type("rules") .type("rules")
.auditInfo(auditInfo) .auditInfo(auditInfo)
.payload(jsonMapper.writeValueAsString(newRules)) .payload(ruleString)
.auditTime(auditTime) .auditTime(auditTime)
.build(), .build(),
handle handle