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 @@ -158,7 +158,6 @@ public void testNSSummaryCLIOBS() throws UnsupportedEncodingException {
String path = "/" + volumeName + "/" + bucketOBS;
executeAdminCommands(path);
// Should throw warning, since bucket is in OBS bucket layout.
assertThat(getOutContentString()).contains("[Warning] Namespace CLI is not designed for OBS bucket layout.");
assertThat(getOutContentString()).contains("Put more files into it to visualize DU");
assertThat(getOutContentString()).contains("Put more files into it to visualize file size distribution");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.makeHttpCall;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printEmptyPathRequest;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printBucketReminder;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printNewLines;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printPathNotFound;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printSpaces;
Expand Down Expand Up @@ -79,10 +78,6 @@ public Void call() throws Exception {
} else if ("TYPE_NOT_APPLICABLE".equals(distResponse.path("status").asText())) {
printTypeNA("File Size Distribution");
} else {
if (parent.isNotValidBucketOrOBSBucket(path)) {
printBucketReminder();
}

printWithUnderline("File Size Distribution", true);
JsonNode fileSizeDist = distResponse.path("dist");
double sum = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,15 @@
*/
package org.apache.hadoop.ozone.admin.nssummary;

import org.apache.hadoop.fs.ozone.OzoneClientUtils;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.ozone.admin.OzoneAdmin;
import org.apache.hadoop.hdds.cli.AdminSubcommand;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.server.http.HttpConfig;
import org.apache.hadoop.ozone.OFSPath;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.om.OmConfig;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;

import java.io.IOException;
import java.util.HashSet;

import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_ADDRESS_DEFAULT;
import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_ADDRESS_KEY;
import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HTTPS_ADDRESS_DEFAULT;
Expand Down Expand Up @@ -66,53 +55,6 @@ public class NSSummaryAdmin implements AdminSubcommand {
@CommandLine.ParentCommand
private OzoneAdmin parent;

private boolean isObjectStoreBucket(OzoneBucket bucket, ObjectStore objectStore) {
boolean enableFileSystemPaths = getOzoneConfig()
.getBoolean(OmConfig.Keys.ENABLE_FILESYSTEM_PATHS,
OmConfig.Defaults.ENABLE_FILESYSTEM_PATHS);
try {
// Resolve the bucket layout in case this is a Link Bucket.
BucketLayout resolvedBucketLayout =
OzoneClientUtils.resolveLinkBucketLayout(bucket, objectStore,
new HashSet<>());
return resolvedBucketLayout.isObjectStore(enableFileSystemPaths);
} catch (IOException e) {
System.out.println(
"Bucket layout couldn't be resolved. Exception thrown: " + e);
return false;
}
}

/**
* Checks if bucket is OBS bucket or if bucket is part of the path.
* Return false if path is root, just a volume or invalid.
* Returns false if bucket is part of path but not a OBS bucket.
* @param path
* @return true if bucket is OBS bucket or not part of provided path.
*/
public boolean isNotValidBucketOrOBSBucket(String path) {
OFSPath ofsPath = new OFSPath(path,
OzoneConfiguration.of(getOzoneConfig()));
try (OzoneClient ozoneClient = OzoneClientFactory.getRpcClient(getOzoneConfig())) {
ObjectStore objectStore = ozoneClient.getObjectStore();
// Return false if path is root "/" or
// contains just the volume and no bucket like "/volume"
if (ofsPath.getVolumeName().isEmpty() ||
ofsPath.getBucketName().isEmpty()) {
return false;
}
// Checks if the bucket is part of the path.
OzoneBucket bucket = objectStore.getVolume(ofsPath.getVolumeName())
.getBucket(ofsPath.getBucketName());
return isObjectStoreBucket(bucket, objectStore);
} catch (IOException e) {
System.out.println(
"Bucket layout couldn't be verified for path: " + ofsPath +
". Exception: " + e);
}
return true;
}

/**
* e.g. Input: "0.0.0.0:9891" -> Output: "0.0.0.0"
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,6 @@ public static void printWithUnderline(String str, boolean newLine) {
}
}

public static void printBucketReminder() {
printNewLines(1);
System.out.println(
"[Warning] Namespace CLI is not designed for OBS bucket layout.\n" +
"Bucket being accessed must be of type FILE_SYSTEM_OPTIMIZED " +
"bucket layout or \nLEGACY bucket layout with " +
"'ozone.om.enable.filesystem.paths' set to true.");
printNewLines(1);
}

public static String parseInputPath(String path) {
if (!path.startsWith("ofs://")) {
return path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.makeHttpCall;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printEmptyPathRequest;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printBucketReminder;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printKVSeparator;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printNewLines;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printPathNotFound;
Expand Down Expand Up @@ -80,10 +79,6 @@ public Void call() throws Exception {
} else if ("TYPE_NOT_APPLICABLE".equals(quotaResponse.path("status").asText())) {
printTypeNA("Quota");
} else {
if (parent.isNotValidBucketOrOBSBucket(path)) {
printBucketReminder();
}

printWithUnderline("Quota", true);

long quotaAllowed = quotaResponse.get("allowed").asLong();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.makeHttpCall;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.parseInputPath;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printEmptyPathRequest;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printBucketReminder;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printKVSeparator;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printNewLines;
import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printPathNotFound;
Expand Down Expand Up @@ -76,10 +75,6 @@ public Void call() throws Exception {
if ("PATH_NOT_FOUND".equals(summaryResponse.path("status").asText())) {
printPathNotFound();
} else {
if (parent.isNotValidBucketOrOBSBucket(path)) {
printBucketReminder();
}

printWithUnderline("Entity Type", false);
printKVSeparator();
System.out.println(summaryResponse.get("type"));
Expand Down