Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -333,6 +333,7 @@ private OzoneConsts() {
public static final String UNDELETED_KEYS_LIST = "unDeletedKeysList";
public static final String SOURCE_VOLUME = "sourceVolume";
public static final String SOURCE_BUCKET = "sourceBucket";
public static final String BUCKET_LAYOUT = "bucketLayout";



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public Map<String, String> toAuditMap() {
Map<String, String> auditMap = new LinkedHashMap<>();
auditMap.put(OzoneConsts.VOLUME, this.volumeName);
auditMap.put(OzoneConsts.BUCKET, this.bucketName);
auditMap.put(OzoneConsts.BUCKET_LAYOUT, String.valueOf(this.bucketLayout));
auditMap.put(OzoneConsts.GDPR_FLAG,
this.metadata.get(OzoneConsts.GDPR_FLAG));
auditMap.put(OzoneConsts.ACLS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,8 @@ public OmKeyInfo lookupKey(OmKeyArgs args) throws IOException {
}

boolean auditSuccess = true;
Map<String, String> auditMap = bucket.audit(args.toAuditMap());
Map<String, String> auditMap =
bucket.auditWithBucketLayout(args.toAuditMap(), this);

args = bucket.update(args);

Expand Down Expand Up @@ -2677,7 +2678,7 @@ public List<OmKeyInfo> listKeys(String volumeName, String bucketName,
}

boolean auditSuccess = true;
Map<String, String> auditMap = bucket.audit();
Map<String, String> auditMap = bucket.auditWithBucketLayout(this);
auditMap.put(OzoneConsts.START_KEY, startKey);
auditMap.put(OzoneConsts.MAX_KEYS, String.valueOf(maxKeys));
auditMap.put(OzoneConsts.KEY_PREFIX, keyPrefix);
Expand Down Expand Up @@ -2928,7 +2929,7 @@ public OmMultipartUploadListParts listParts(final String volumeName,

ResolvedBucket bucket = resolveBucketLink(Pair.of(volumeName, bucketName));

Map<String, String> auditMap = bucket.audit();
Map<String, String> auditMap = bucket.auditWithBucketLayout(this);
auditMap.put(OzoneConsts.KEY, keyName);
auditMap.put(OzoneConsts.UPLOAD_ID, uploadID);
auditMap.put(OzoneConsts.PART_NUMBER_MARKER,
Expand Down Expand Up @@ -2957,7 +2958,7 @@ public OmMultipartUploadList listMultipartUploads(String volumeName,

ResolvedBucket bucket = resolveBucketLink(Pair.of(volumeName, bucketName));

Map<String, String> auditMap = bucket.audit();
Map<String, String> auditMap = bucket.auditWithBucketLayout(this);
auditMap.put(OzoneConsts.PREFIX, prefix);

metrics.incNumListMultipartUploads();
Expand All @@ -2983,7 +2984,8 @@ public OzoneFileStatus getFileStatus(OmKeyArgs args) throws IOException {
ResolvedBucket bucket = resolveBucketLink(args);

boolean auditSuccess = true;
Map<String, String> auditMap = bucket.audit(args.toAuditMap());
Map<String, String> auditMap =
bucket.auditWithBucketLayout(args.toAuditMap(), this);

args = bucket.update(args);

Expand Down Expand Up @@ -3021,7 +3023,8 @@ public OmKeyInfo lookupFile(OmKeyArgs args) throws IOException {
}

boolean auditSuccess = true;
Map<String, String> auditMap = bucket.audit(args.toAuditMap());
Map<String, String> auditMap =
bucket.auditWithBucketLayout(args.toAuditMap(), this);

args = bucket.update(args);

Expand Down Expand Up @@ -3054,7 +3057,8 @@ public List<OzoneFileStatus> listStatus(OmKeyArgs args, boolean recursive,
}

boolean auditSuccess = true;
Map<String, String> auditMap = bucket.audit(args.toAuditMap());
Map<String, String> auditMap =
bucket.auditWithBucketLayout(args.toAuditMap(), this);

args = bucket.update(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
Expand All @@ -36,6 +39,8 @@ public class ResolvedBucket {

private final Pair<String, String> requested;
private final Pair<String, String> resolved;
private static final Logger LOG =
LoggerFactory.getLogger(ResolvedBucket.class);

public ResolvedBucket(Pair<String, String> requested,
Pair<String, String> resolved) {
Expand Down Expand Up @@ -93,6 +98,10 @@ public Map<String, String> audit() {
return audit(new LinkedHashMap<>());
}

public Map<String, String> auditWithBucketLayout(OzoneManager ozoneManager) {
return auditWithBucketLayout(new LinkedHashMap<>(), ozoneManager);
}

/**
* Adds audit information about the bucket (and if it's a link, then the
* real bucket, too) to {@code auditMap}.
Expand All @@ -108,4 +117,25 @@ public Map<String, String> audit(Map<String, String> auditMap) {
return auditMap;
}

/**
* Adds audit information about the bucket and its bucket layout (and if it's
* a link, then the real bucket, too) to {@code auditMap}.
*
* @return the same map for convenience
*/
public Map<String, String> auditWithBucketLayout(Map<String, String> auditMap,
OzoneManager om) {
audit(auditMap);
try {
// Add BucketLayout to auditMap from the resolved Bucket.
auditMap.put(OzoneConsts.BUCKET_LAYOUT, String.valueOf(
om.getBucketInfo(realVolume(), realBucket()).getBucketLayout()
Comment thread
adoroszlai marked this conversation as resolved.
Outdated
));
} catch (IOException ioe) {
LOG.error("Failed to get bucket layout for Volume: {}, Bucket: {}",
realVolume(), realBucket(), ioe);
}
return auditMap;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected KeyArgs resolveBucketLink(
Map<String, String> auditMap) throws IOException {
ResolvedBucket bucket = ozoneManager.resolveBucketLink(keyArgs, this);
keyArgs = bucket.update(keyArgs);
bucket.audit(auditMap);
bucket.auditWithBucketLayout(auditMap, ozoneManager);
return keyArgs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
try {
ResolvedBucket bucket = ozoneManager.resolveBucketLink(
Pair.of(volumeName, bucketName), this);
bucket.audit(auditMap);
bucket.auditWithBucketLayout(auditMap, ozoneManager);
volumeName = bucket.realVolume();
bucketName = bucket.realBucket();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
try {
ResolvedBucket bucket = ozoneManager.resolveBucketLink(
Pair.of(volumeName, bucketName), this);
bucket.audit(auditMap);
bucket.auditWithBucketLayout(auditMap, ozoneManager);
volumeName = bucket.realVolume();
bucketName = bucket.realBucket();
acquiredLock =
Expand Down