in hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java [832:978]
private static Map<String, String> getAuditParams(
ContainerCommandRequestProto msg, DispatcherContext dispatcherContext) {
Map<String, String> auditParams = new TreeMap<>();
Type cmdType = msg.getCmdType();
String containerID = String.valueOf(msg.getContainerID());
switch (cmdType) {
case CreateContainer:
auditParams.put(AUDIT_PARAM_CONTAINER_ID, containerID);
auditParams.put(AUDIT_PARAM_CONTAINER_TYPE,
msg.getCreateContainer().getContainerType().toString());
return auditParams;
case ReadContainer:
auditParams.put(AUDIT_PARAM_CONTAINER_ID, containerID);
return auditParams;
case UpdateContainer:
auditParams.put(AUDIT_PARAM_CONTAINER_ID, containerID);
auditParams.put(AUDIT_PARAM_FORCE_UPDATE,
String.valueOf(msg.getUpdateContainer().getForceUpdate()));
return auditParams;
case DeleteContainer:
auditParams.put(AUDIT_PARAM_CONTAINER_ID, containerID);
auditParams.put(AUDIT_PARAM_FORCE_DELETE,
String.valueOf(msg.getDeleteContainer().getForceDelete()));
return auditParams;
case ListContainer:
auditParams.put(AUDIT_PARAM_START_CONTAINER_ID, containerID);
auditParams.put(AUDIT_PARAM_COUNT,
String.valueOf(msg.getListContainer().getCount()));
return auditParams;
case PutBlock:
try {
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockData.getFromProtoBuf(msg.getPutBlock().getBlockData())
.toString());
} catch (IOException ex) {
if (LOG.isTraceEnabled()) {
LOG.trace("Encountered error parsing BlockData from protobuf: "
+ ex.getMessage());
}
return null;
}
return auditParams;
case GetBlock:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getGetBlock().getBlockID()).toString());
return auditParams;
case DeleteBlock:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getDeleteBlock().getBlockID())
.toString());
return auditParams;
case ListBlock:
auditParams.put(AUDIT_PARAM_START_LOCAL_ID,
String.valueOf(msg.getListBlock().getStartLocalID()));
auditParams.put(AUDIT_PARAM_COUNT, String.valueOf(msg.getListBlock().getCount()));
return auditParams;
case ReadChunk:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getReadChunk().getBlockID()).toString());
auditParams.put(AUDIT_PARAM_BLOCK_DATA_OFFSET,
String.valueOf(msg.getReadChunk().getChunkData().getOffset()));
auditParams.put(AUDIT_PARAM_BLOCK_DATA_SIZE,
String.valueOf(msg.getReadChunk().getChunkData().getLen()));
return auditParams;
case DeleteChunk:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getDeleteChunk().getBlockID())
.toString());
return auditParams;
case WriteChunk:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getWriteChunk().getBlockID())
.toString());
auditParams.put(AUDIT_PARAM_BLOCK_DATA_OFFSET,
String.valueOf(msg.getWriteChunk().getChunkData().getOffset()));
auditParams.put(AUDIT_PARAM_BLOCK_DATA_SIZE,
String.valueOf(msg.getWriteChunk().getChunkData().getLen()));
if (dispatcherContext != null && dispatcherContext.getStage() != null) {
auditParams.put(AUDIT_PARAM_BLOCK_DATA_STAGE, dispatcherContext.getStage().toString());
}
return auditParams;
case ListChunk:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getListChunk().getBlockID()).toString());
auditParams.put(AUDIT_PARAM_PREV_CHUNKNAME, msg.getListChunk().getPrevChunkName());
auditParams.put(AUDIT_PARAM_COUNT, String.valueOf(msg.getListChunk().getCount()));
return auditParams;
case CompactChunk: return null; //CompactChunk operation
case PutSmallFile:
try {
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockData.getFromProtoBuf(msg.getPutSmallFile()
.getBlock().getBlockData()).toString());
auditParams.put(AUDIT_PARAM_BLOCK_DATA_OFFSET,
String.valueOf(msg.getPutSmallFile().getChunkInfo().getOffset()));
auditParams.put(AUDIT_PARAM_BLOCK_DATA_SIZE,
String.valueOf(msg.getPutSmallFile().getChunkInfo().getLen()));
} catch (IOException ex) {
if (LOG.isTraceEnabled()) {
LOG.trace("Encountered error parsing BlockData from protobuf: "
+ ex.getMessage());
}
}
return auditParams;
case GetSmallFile:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getGetSmallFile().getBlock().getBlockID())
.toString());
return auditParams;
case CloseContainer:
auditParams.put(AUDIT_PARAM_CONTAINER_ID, containerID);
return auditParams;
case GetCommittedBlockLength:
auditParams.put(AUDIT_PARAM_BLOCK_DATA,
BlockID.getFromProtobuf(msg.getGetCommittedBlockLength().getBlockID())
.toString());
return auditParams;
case FinalizeBlock:
auditParams.put("blockData",
BlockID.getFromProtobuf(msg.getFinalizeBlock().getBlockID())
.toString());
return auditParams;
default :
LOG.debug("Invalid command type - {}", cmdType);
return null;
}
}