hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1355826 - in /hbase/branches/0.94: security/src/main/java/org/apache/hadoop/hbase/security/access/ security/src/test/java/org/apache/hadoop/hbase/security/access/ src/main/java/org/apache/hadoop/hbase/coprocessor/ src/main/java/org/apache/...
Date Sat, 30 Jun 2012 21:26:28 GMT
Author: apurtell
Date: Sat Jun 30 21:26:26 2012
New Revision: 1355826

URL: http://svn.apache.org/viewvc?rev=1355826&view=rev
Log:
HBASE-6292. Compact can skip the security access control (ShiXing)

Modified:
    hbase/branches/0.94/security/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
    hbase/branches/0.94/security/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionObserver.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionRequestor.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java

Modified: hbase/branches/0.94/security/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/security/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/security/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
(original)
+++ hbase/branches/0.94/security/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
Sat Jun 30 21:26:26 2012
@@ -55,6 +55,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.InternalScanner;
 import org.apache.hadoop.hbase.regionserver.RegionScanner;
 import org.apache.hadoop.hbase.regionserver.Store;
+import org.apache.hadoop.hbase.regionserver.StoreFile;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.security.AccessDeniedException;
 import org.apache.hadoop.hbase.security.User;
@@ -742,6 +743,12 @@ public class AccessController extends Ba
   }
 
   @Override
+  public void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment>
e,
+      final Store store, final List<StoreFile> candidates) throws IOException {
+    requirePermission(getTableName(e.getEnvironment()), null, null, Action.ADMIN);
+  }
+
+  @Override
   public void preGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment>
c,
       final byte [] row, final byte [] family, final Result result)
       throws IOException {

Modified: hbase/branches/0.94/security/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/security/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/security/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
(original)
+++ hbase/branches/0.94/security/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
Sat Jun 30 21:26:26 2012
@@ -474,6 +474,19 @@ public class TestAccessController {
     verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE);
   }
 
+  @Test
+  public void testPreCompactSelection() throws Exception {
+    PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
+      public Object run() throws Exception {
+        ACCESS_CONTROLLER.preCompactSelection(ObserverContext.createAndPrepare(RCP_ENV, null),
null, null);
+        return null;
+      }
+    };
+
+    verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER);
+    verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE);
+  }
+
   private void verifyRead(PrivilegedExceptionAction action) throws Exception {
     verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_RW, USER_RO);
     verifyDenied(action, USER_NONE, USER_CREATE);

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionObserver.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionObserver.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionObserver.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionObserver.java
Sat Jun 30 21:26:26 2012
@@ -88,7 +88,7 @@ public abstract class BaseRegionObserver
 
   @Override
   public void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment>
c,
-      final Store store, final List<StoreFile> candidates) { }
+      final Store store, final List<StoreFile> candidates) throws IOException { }
 
   @Override
   public void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment>
c,

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
Sat Jun 30 21:26:26 2012
@@ -81,9 +81,10 @@ public interface RegionObserver extends 
    * @param c the environment provided by the region server
    * @param store the store where compaction is being requested
    * @param candidates the store files currently available for compaction
+   * @throws IOException if an error occurred on the coprocessor
    */
   void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
-      final Store store, final List<StoreFile> candidates);
+      final Store store, final List<StoreFile> candidates) throws IOException;
 
   /**
    * Called after the {@link StoreFile}s to compact have been selected from the

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
Sat Jun 30 21:26:26 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import java.io.IOException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.PriorityBlockingQueue;
 import java.util.concurrent.RejectedExecutionException;
@@ -166,19 +167,19 @@ public class CompactSplitThread implemen
   }
 
   public synchronized void requestCompaction(final HRegion r,
-      final String why) {
+      final String why) throws IOException {
     for(Store s : r.getStores().values()) {
       requestCompaction(r, s, why, Store.NO_PRIORITY);
     }
   }
 
   public synchronized void requestCompaction(final HRegion r, final Store s,
-      final String why) {
+      final String why) throws IOException {
     requestCompaction(r, s, why, Store.NO_PRIORITY);
   }
 
   public synchronized void requestCompaction(final HRegion r, final String why,
-      int p) {
+      int p) throws IOException {
     for(Store s : r.getStores().values()) {
       requestCompaction(r, s, why, p);
     }
@@ -191,7 +192,7 @@ public class CompactSplitThread implemen
    * @param priority override the default priority (NO_PRIORITY == decide)
    */
   public synchronized void requestCompaction(final HRegion r, final Store s,
-      final String why, int priority) {
+      final String why, int priority) throws IOException {
     if (this.server.isStopped()) {
       return;
     }

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionRequestor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionRequestor.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionRequestor.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionRequestor.java
Sat Jun 30 21:26:26 2012
@@ -19,34 +19,40 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import java.io.IOException;
+
 public interface CompactionRequestor {
   /**
    * @param r Region to compact
    * @param why Why compaction was requested -- used in debug messages
+   * @throws IOException
    */
-  public void requestCompaction(final HRegion r, final String why);
+  public void requestCompaction(final HRegion r, final String why) throws IOException;
 
   /**
    * @param r Region to compact
    * @param s Store within region to compact
    * @param why Why compaction was requested -- used in debug messages
+   * @throws IOException
    */
-  public void requestCompaction(final HRegion r, final Store s, final String why);
+  public void requestCompaction(final HRegion r, final Store s, final String why) throws
IOException;
 
   /**
    * @param r Region to compact
    * @param why Why compaction was requested -- used in debug messages
    * @param pri Priority of this compaction. minHeap. <=0 is critical
+   * @throws IOException
    */
-  public void requestCompaction(final HRegion r, final String why, int pri);
+  public void requestCompaction(final HRegion r, final String why, int pri) throws IOException;
 
   /**
    * @param r Region to compact
    * @param s Store within region to compact
    * @param why Why compaction was requested -- used in debug messages
    * @param pri Priority of this compaction. minHeap. <=0 is critical
+   * @throws IOException
    */
   public void requestCompaction(final HRegion r, final Store s,
-      final String why, int pri);
+      final String why, int pri) throws IOException;
 
 }

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
Sat Jun 30 21:26:26 2012
@@ -360,7 +360,13 @@ class MemStoreFlusher extends HasThread 
           LOG.warn("Region " + region.getRegionNameAsString() + " has too many " +
             "store files; delaying flush up to " + this.blockingWaitTime + "ms");
           if (!this.server.compactSplitThread.requestSplit(region)) {
-            this.server.compactSplitThread.requestCompaction(region, getName());
+            try {
+              this.server.compactSplitThread.requestCompaction(region, getName());
+            }  catch (IOException e) {
+              LOG.error("Cache flush failed" +
+                (region != null ? (" for region " + Bytes.toStringBinary(region.getRegionName()))
: ""),
+                RemoteExceptionHandler.checkIOException(e));
+            }
           }
         }
 

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
Sat Jun 30 21:26:26 2012
@@ -309,15 +309,21 @@ public class RegionCoprocessorHost
    * @param store The store where compaction is being requested
    * @param candidates The currently available store files
    * @return If {@code true}, skip the normal selection process and use the current list
+   * @throws IOException
    */
-  public boolean preCompactSelection(Store store, List<StoreFile> candidates) {
+  public boolean preCompactSelection(Store store, List<StoreFile> candidates) throws
IOException {
     ObserverContext<RegionCoprocessorEnvironment> ctx = null;
     boolean bypass = false;
     for (RegionEnvironment env: coprocessors) {
       if (env.getInstance() instanceof RegionObserver) {
         ctx = ObserverContext.createAndPrepare(env, ctx);
-        ((RegionObserver)env.getInstance()).preCompactSelection(
-            ctx, store, candidates);
+        try {
+          ((RegionObserver)env.getInstance()).preCompactSelection(
+              ctx, store, candidates);
+        } catch (Throwable e) {
+          handleCoprocessorThrowable(env,e);
+
+        }
         bypass |= ctx.shouldBypass();
         if (ctx.shouldComplete()) {
           break;

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=1355826&r1=1355825&r2=1355826&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Sat
Jun 30 21:26:26 2012
@@ -1207,11 +1207,11 @@ public class Store extends SchemaConfigu
     return ret;
   }
 
-  public CompactionRequest requestCompaction() {
+  public CompactionRequest requestCompaction() throws IOException {
     return requestCompaction(NO_PRIORITY);
   }
 
-  public CompactionRequest requestCompaction(int priority) {
+  public CompactionRequest requestCompaction(int priority) throws IOException {
     // don't even select for compaction if writes are disabled
     if (!this.region.areWritesEnabled()) {
       return null;
@@ -1275,9 +1275,6 @@ public class Store extends SchemaConfigu
         int pri = getCompactPriority(priority);
         ret = new CompactionRequest(region, this, filesToCompact, isMajor, pri);
       }
-    } catch (IOException ex) {
-      LOG.error("Compaction Request failed for region " + region + ", store "
-          + this, RemoteExceptionHandler.checkIOException(ex));
     } finally {
       this.lock.readLock().unlock();
     }



Mime
View raw message