@Override public void start(CoprocessorEnvironment env) throws IOException { this.conf = env.getConfiguration(); authorizationEnabled = isAuthorizationSupported(conf); if (!authorizationEnabled) { LOG.warn("The VisibilityController has been loaded with authorization checks disabled."); } if (HFile.getFormatVersion(conf) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) { throw new RuntimeException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS + " is required to persist visibility labels. Consider setting " + HFile.FORMAT_VERSION_KEY + " accordingly."); } if (env instanceof RegionServerCoprocessorEnvironment) { throw new RuntimeException("Visibility controller should not be configured as " + "'hbase.coprocessor.regionserver.classes'."); } // Do not create for master CPs if (!(env instanceof MasterCoprocessorEnvironment)) { visibilityLabelService = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(this.conf); } }
@Override public void start(CoprocessorEnvironment env) throws IOException { this.conf = env.getConfiguration(); if (HFile.getFormatVersion(conf) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) { throw new RuntimeException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS + " is required to persist visibility labels. Consider setting " + HFile.FORMAT_VERSION_KEY + " accordingly."); } if (env instanceof RegionServerCoprocessorEnvironment) { throw new RuntimeException("Visibility controller should not be configured as " + "'hbase.coprocessor.regionserver.classes'."); } // Do not create for master CPs if (!(env instanceof MasterCoprocessorEnvironment)) { visibilityLabelService = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(this.conf); } Pair<List<String>, List<String>> superUsersAndGroups = VisibilityUtils.getSystemAndSuperUsers(this.conf); this.superUsers = superUsersAndGroups.getFirst(); this.superGroups = superUsersAndGroups.getSecond(); }
public void preStop(String message) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).preStopRegionServer(ctx); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } // invoke coprocessor stop method shutdown(env); } }
public boolean preMerge(final HRegion regionA, final HRegion regionB) throws IOException { boolean bypass = false; ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).preMerge(ctx, regionA, regionB); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
public void postMerge(final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).postMerge(ctx, regionA, regionB, mergedRegion); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public boolean preMergeCommit(final HRegion regionA, final HRegion regionB, final @MetaMutationAnnotation List<Mutation> metaEntries) throws IOException { boolean bypass = false; ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).preMergeCommit(ctx, regionA, regionB, metaEntries); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
public void postMergeCommit(final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).postMergeCommit(ctx, regionA, regionB, mergedRegion); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public void preRollBackMerge(final HRegion regionA, final HRegion regionB) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).preRollBackMerge(ctx, regionA, regionB); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public void postRollBackMerge(final HRegion regionA, final HRegion regionB) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).postRollBackMerge(ctx, regionA, regionB); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public void preStop(String message) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); Thread currentThread = Thread.currentThread(); ClassLoader cl = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(env.getClassLoader()); ((RegionServerObserver) env.getInstance()).preStopRegionServer(ctx); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } finally { currentThread.setContextClassLoader(cl); } if (ctx.shouldComplete()) { break; } } } }
public void preStop(String message) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preStopRegionServer(ctx); } @Override public void postEnvCall(RegionServerEnvironment env) { // invoke coprocessor stop method shutdown(env); } }); }
public boolean preMerge(final HRegion regionA, final HRegion regionB) throws IOException { return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preMerge(ctx, regionA, regionB); } }); }
public void postMerge(final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.postMerge(ctx, regionA, regionB, mergedRegion); } }); }
public boolean preMergeCommit(final HRegion regionA, final HRegion regionB, final @MetaMutationAnnotation List<Mutation> metaEntries) throws IOException { return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preMergeCommit(ctx, regionA, regionB, metaEntries); } }); }
public void postMergeCommit(final HRegion regionA, final HRegion regionB, final HRegion mergedRegion) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.postMergeCommit(ctx, regionA, regionB, mergedRegion); } }); }
public void preRollBackMerge(final HRegion regionA, final HRegion regionB) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preRollBackMerge(ctx, regionA, regionB); } }); }
public void postRollBackMerge(final HRegion regionA, final HRegion regionB) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.postRollBackMerge(ctx, regionA, regionB); } }); }
public void preRollWALWriterRequest() throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preRollWALWriterRequest(ctx); } }); }
public void postRollWALWriterRequest() throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.postRollWALWriterRequest(ctx); } }); }
public void preReplicateLogEntries(final List<WALEntry> entries, final CellScanner cells) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.preReplicateLogEntries(ctx, entries, cells); } }); }
public void postReplicateLogEntries(final List<WALEntry> entries, final CellScanner cells) throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { oserver.postReplicateLogEntries(ctx, entries, cells); } }); }
public ReplicationEndpoint postCreateReplicationEndPoint(final ReplicationEndpoint endpoint) throws IOException { return execOperationWithResult(endpoint, coprocessors.isEmpty() ? null : new CoprocessOperationWithResult<ReplicationEndpoint>() { @Override public void call(RegionServerObserver oserver, ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { setResult(oserver.postCreateReplicationEndPoint(ctx, getResult())); } }); }
@Test (timeout=180000) public void testCoprocessorLoading() throws Exception { MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost(); cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf); AccessController ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor( MyAccessController.class.getName()); MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment( MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0) .getRegionServerCoprocessorHost(); RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment( MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); }
@Override public synchronized void preMerge(ObserverContext<RegionServerCoprocessorEnvironment> ctx, Region regionA, Region regionB) throws IOException { triggered = true; notifyAll(); if (shouldFailMerge) { throw new IOException("fail merge"); } }
public void preStop(String message) throws IOException { ObserverContext<RegionServerCoprocessorEnvironment> ctx = null; for (RegionServerEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionServerObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); ((RegionServerObserver) env.getInstance()).preStopRegionServer(ctx); if (ctx.shouldComplete()) { break; } } } }