Skip to content

Commit

Permalink
Add more verbose logging to SQLMetadataRuleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
drcrallen committed Oct 21, 2015
1 parent b7c68ec commit 1cad571
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions common/src/main/java/io/druid/audit/AuditInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ public int hashCode()
result = 31 * result + ip.hashCode();
return result;
}

@Override
public String toString()
{
return "AuditInfo{" +
"author='" + author + '\'' +
", comment='" + comment + '\'' +
", ip='" + ip + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -334,6 +335,15 @@ public List<Rule> getRulesWithDefault(final String dataSource)

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) {
try {
dbi.inTransaction(
Expand All @@ -348,7 +358,7 @@ public Void inTransaction(Handle handle, TransactionStatus transactionStatus) th
.key(dataSource)
.type("rules")
.auditInfo(auditInfo)
.payload(jsonMapper.writeValueAsString(newRules))
.payload(ruleString)
.auditTime(auditTime)
.build(),
handle
Expand Down

0 comments on commit 1cad571

Please sign in to comment.