hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [36/50] [abbrv] hbase git commit: HBASE-13711 Provide an API to set min and max versions in HColumnDescriptor (Stephen Yuan Jiang)
Date Thu, 21 May 2015 16:43:19 GMT
HBASE-13711 Provide an API to set min and max versions in HColumnDescriptor (Stephen Yuan Jiang)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/77d9719e
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/77d9719e
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/77d9719e

Branch: refs/heads/hbase-12439
Commit: 77d9719e2bd7db20b0ad3bafb255c9d797d2b49d
Parents: 88f19ab
Author: Nick Dimiduk <ndimiduk@apache.org>
Authored: Wed May 20 11:40:25 2015 -0700
Committer: Nick Dimiduk <ndimiduk@apache.org>
Committed: Wed May 20 11:40:25 2015 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/HColumnDescriptor.java  | 24 ++++++++++++++++++++
 .../chaos/actions/ChangeVersionsAction.java     |  3 +--
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/77d9719e/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
index 4091c11..2cb587b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java
@@ -505,6 +505,30 @@ public class HColumnDescriptor implements Comparable<HColumnDescriptor>
{
   }
 
   /**
+   * Set minimum and maximum versions to keep
+   *
+   * @param minVersions minimal number of versions
+   * @param maxVersions maximum number of versions
+   * @return this (for chained invocation)
+   */
+  public HColumnDescriptor setVersions(int minVersions, int maxVersions) {
+    if (minVersions <= 0) {
+      // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions".
+      // Until there is support, consider 0 or < 0 -- a configuration error.
+      throw new IllegalArgumentException("Minimum versions must be positive");
+    }
+
+    if (maxVersions < minVersions) {
+      throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions
+        + " and set MinVersion to " + minVersions
+        + ", as maximum versions must be >= minimum versions.");
+    }
+    setMinVersions(minVersions);
+    setMaxVersions(maxVersions);
+    return this;
+  }
+
+  /**
    * @return The storefile/hfile blocksize for this column family.
    */
   public synchronized int getBlocksize() {

http://git-wip-us.apache.org/repos/asf/hbase/blob/77d9719e/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeVersionsAction.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeVersionsAction.java
b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeVersionsAction.java
index 0faa8a3..16f1cb0 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeVersionsAction.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeVersionsAction.java
@@ -59,8 +59,7 @@ public class ChangeVersionsAction extends Action {
 
     int versions =  random.nextInt(3) + 1;
     for(HColumnDescriptor descriptor:columnDescriptors) {
-      descriptor.setMaxVersions(versions);
-      descriptor.setMinVersions(versions);
+      descriptor.setVersions(versions, versions);
     }
     LOG.debug("Performing action: Changing versions on " + tableName.getNameAsString());
     admin.modifyTable(tableName, tableDescriptor);


Mime
View raw message