diff --git a/common/src/main/java/io/druid/audit/AuditInfo.java b/common/src/main/java/io/druid/audit/AuditInfo.java index c4ede95e9ab..e2f35695663 100644 --- a/common/src/main/java/io/druid/audit/AuditInfo.java +++ b/common/src/main/java/io/druid/audit/AuditInfo.java @@ -89,4 +89,14 @@ public class AuditInfo result = 31 * result + ip.hashCode(); return result; } + + @Override + public String toString() + { + return "AuditInfo{" + + "author='" + author + '\'' + + ", comment='" + comment + '\'' + + ", ip='" + ip + '\'' + + '}'; + } } diff --git a/server/src/main/java/io/druid/metadata/SQLMetadataRuleManager.java b/server/src/main/java/io/druid/metadata/SQLMetadataRuleManager.java index b17b5ae870b..a2ae0689c1e 100644 --- a/server/src/main/java/io/druid/metadata/SQLMetadataRuleManager.java +++ b/server/src/main/java/io/druid/metadata/SQLMetadataRuleManager.java @@ -18,6 +18,7 @@ package io.druid.metadata; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Supplier; @@ -334,6 +335,15 @@ public class SQLMetadataRuleManager implements MetadataRuleManager public boolean overrideRule(final String dataSource, final List 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) { try { dbi.inTransaction( @@ -348,7 +358,7 @@ public class SQLMetadataRuleManager implements MetadataRuleManager .key(dataSource) .type("rules") .auditInfo(auditInfo) - .payload(jsonMapper.writeValueAsString(newRules)) + .payload(ruleString) .auditTime(auditTime) .build(), handle