jojochuang commented on code in PR #5920:
URL: https://github.com/apache/ozone/pull/5920#discussion_r1449506257
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -3187,14 +3192,96 @@ public ServiceInfoEx getServiceInfo() throws
IOException {
}
@Override
- public void transferLeadership(String newLeaderId)
+ public ListOpenFilesResult listOpenFiles(String path,
+ int maxKeys,
+ String contToken)
throws IOException {
- final UserGroupInformation ugi = getRemoteUser();
- if (!isAdmin(ugi)) {
- throw new OMException(
- "Only Ozone admins are allowed to transfer raft leadership.",
- PERMISSION_DENIED);
+
+ metrics.incNumListOpenFiles();
+ checkAdminUserPrivilege("list open files.");
+
+ // Using final to make sure they are assigned once and only once in
+ // every branch.
+ final String dbOpenKeyPrefix, dbContTokenPrefix;
+ final String volumeName, bucketName;
+ final BucketLayout bucketLayout;
+
+ // Process path prefix
+ if (path == null || path.isEmpty() || path.equals(OM_KEY_PREFIX)) {
+ // path is root
+ dbOpenKeyPrefix = "";
+ volumeName = "";
+ bucketName = "";
+ // default to FSO's OpenFileTable. TODO: client option to pass
OBS/LEGACY?
+ bucketLayout = BucketLayout.FILE_SYSTEM_OPTIMIZED;
+ } else {
+ // path is bucket or key prefix, break it down to volume, bucket, prefix
+ StringTokenizer tokenizer = new StringTokenizer(path, OM_KEY_PREFIX);
+ // Validate path to avoid NoSuchElementException
+ if (tokenizer.countTokens() < 2) {
+ metrics.incNumListOpenFilesFails();
+ throw new OMException("Invalid path: " + path + ". " +
+ "Only root level or bucket level path is supported at this time",
+ INVALID_PATH);
+ }
+
+ volumeName = tokenizer.nextToken();
+ bucketName = tokenizer.nextToken();
+
+ OmBucketInfo bucketInfo;
+ try {
+ // as expected, getBucketInfo throws if volume or bucket does not exist
+ bucketInfo = getBucketInfo(volumeName, bucketName);
+ } catch (Exception ex) {
+ metrics.incNumListOpenFilesFails();
+ throw ex;
Review Comment:
consider wrapping it in an OMException.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]