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 @@ -20,6 +20,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
Expand All @@ -36,6 +37,7 @@
import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.test.GenericTestUtils;
Expand All @@ -48,6 +50,8 @@
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -525,4 +529,42 @@ public void testDeleteToTrashOrSkipTrash() throws Exception {
}
}

@Test
public void testShQuota() throws IOException {
ObjectStore objectStore = cluster.getClient().getObjectStore();
try {
// Test --quota option.

String[] args =
new String[] {"volume", "create", "vol1", "--quota", "100BYTES"};
execute(ozoneShell, args);
assertEquals(100, objectStore.getVolume("vol1").getQuotaInBytes());
out.reset();

args =
new String[] {"bucket", "create", "vol1/buck1", "--quota", "10BYTES"};
execute(ozoneShell, args);
assertEquals(10,
objectStore.getVolume("vol1").getBucket("buck1").getQuotaInBytes());

// Test --space-quota option.

args = new String[] {"volume", "create", "vol2", "--space-quota",
"100BYTES"};
execute(ozoneShell, args);
assertEquals(100, objectStore.getVolume("vol2").getQuotaInBytes());
out.reset();

args = new String[] {"bucket", "create", "vol2/buck2", "--space-quota",
"10BYTES"};
execute(ozoneShell, args);
assertEquals(10,
objectStore.getVolume("vol2").getBucket("buck2").getQuotaInBytes());
} finally {
objectStore.getVolume("vol1").deleteBucket("buck1");
objectStore.deleteVolume("vol1");
objectStore.getVolume("vol2").deleteBucket("buck2");
objectStore.deleteVolume("vol2");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ public class SetSpaceQuotaOptions {

@CommandLine.Option(names = {"--space-quota"},
description = "The maximum space quota can be used (eg. 1GB)")

private String quotaInBytes;

@CommandLine.Option(names = {"--count-quota"},
description = "For volume this parameter represents the number of " +
"buckets, and for buckets represents the number of keys (eg. 5)")
private long quotaInCounts;

// Hidden option, added for backward compatibility.
@CommandLine.Option(names = {"--quota"}, hidden = true,
description = "Deprecated use --space-quota")
private String quotaInBytesDep;

public String getQuotaInBytes() {
return quotaInBytes;
return quotaInBytes != null ? quotaInBytes : quotaInBytesDep;
}

public long getQuotaInCounts() {
Expand Down