Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand All @@ -52,6 +53,7 @@
* This test class ensures the audit log behave exactly the same as we expected, including the
* number, sequence and content of the audit logs.
*/
@Ignore
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class})
public class IoTDBAuditLogBasicIT {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,16 @@

package org.apache.iotdb.confignode.audit;

import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.commons.audit.AbstractAuditLogger;
import org.apache.iotdb.commons.audit.IAuditEntity;
import org.apache.iotdb.confignode.client.async.AsyncDataNodeHeartbeatClientPool;
import org.apache.iotdb.confignode.client.async.handlers.audit.DataNodeWriteAuditLogHandler;
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
import org.apache.iotdb.confignode.manager.ConfigManager;
import org.apache.iotdb.confignode.manager.IManager;
import org.apache.iotdb.mpp.rpc.thrift.TAuditLogReq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.function.Supplier;

public class CNAuditLogger extends AbstractAuditLogger {
Expand All @@ -50,45 +42,5 @@ public CNAuditLogger(ConfigManager configManager) {
}

@Override
public void log(IAuditEntity auditLogFields, Supplier<String> log) {
if (!IS_AUDIT_LOG_ENABLED) {
return;
}
if (noNeedInsertAuditLog(auditLogFields)) {
return;
}
// find database "__audit"'s data_region
List<TRegionReplicaSet> auditReplicaSets =
configManager
.getPartitionManager()
.getAllReplicaSets("root.__audit", TConsensusGroupType.DataRegion);
if (auditReplicaSets.isEmpty()) {
logger.warn("Database {} does not exist.", "root.__audit");
return;
}
TConsensusGroupId regionId = auditReplicaSets.get(0).getRegionId();
// use ConfigManager.getLoadManager().getLoadCache().getRegionLeaderMap() to get regionLeaderId
TDataNodeLocation regionLeader = configManager.getRegionLeaderLocation(regionId);
TAuditLogReq req =
new TAuditLogReq(
auditLogFields.getUsername(),
auditLogFields.getUserId(),
auditLogFields.getCliHostname(),
auditLogFields.getAuditEventType().toString(),
auditLogFields.getAuditLogOperation().toString(),
auditLogFields.getPrivilegeTypeString(),
auditLogFields.getResult(),
auditLogFields.getDatabase(),
auditLogFields.getSqlString(),
log.get(),
CONF.getConfigNodeId());
// refer the implementation of HeartbeatService.pingRegisteredDataNode(). By appending a new
// writeAudtiLog() interface in AsyncDataNodeHeartbeatClientPool, the main thread is not
// required to wait until the write audit log request to be complete.
AsyncDataNodeHeartbeatClientPool.getInstance()
.writeAuditLog(
regionLeader.getInternalEndPoint(),
req,
new DataNodeWriteAuditLogHandler(regionLeader.getDataNodeId()));
}
public void log(IAuditEntity auditLogFields, Supplier<String> log) {}
}
Loading