/** * @param info * @param logKey * @param logEdit * @return true if default behavior should be bypassed, false otherwise * @throws IOException */ public boolean preWALWrite(HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException { boolean bypass = false; ObserverContext<WALCoprocessorEnvironment> ctx = null; for (WALEnvironment env: coprocessors) { if (env.getInstance() instanceof org.apache.hadoop.hbase.coprocessor.WALObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); ((org.apache.hadoop.hbase.coprocessor.WALObserver)env.getInstance()). preWALWrite(ctx, info, logKey, logEdit); bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preAssign(final HRegionInfo regionInfo) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver) env.getInstance()).preAssign(ctx, regionInfo); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preBalance() throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preBalance(ctx); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preAddColumn(byte [] tableName, HColumnDescriptor column) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preAddColumn(ctx, tableName, column); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preDeleteColumn(final byte [] tableName, final byte [] c) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preDeleteColumn(ctx, tableName, c); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preMove(final HRegionInfo region, final ServerName srcServer, final ServerName destServer) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preMove( ctx, region, srcServer, destServer); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preUnassign(final HRegionInfo regionInfo, final boolean force) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preUnassign( ctx, regionInfo, force); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
boolean preModifyColumn(byte [] tableName, HColumnDescriptor descriptor) throws IOException { boolean bypass = false; ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preModifyColumn( ctx, tableName, descriptor); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param get the Get request * @return true or false to return to client if bypassing normal operation, * or null otherwise * @exception IOException Exception */ public Boolean preExists(final Get get) throws IOException { boolean bypass = false; boolean exists = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { exists = ((RegionObserver)env.getInstance()).preExists(ctx, get, exists); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass ? exists : null; }
/** * @param familyPaths pairs of { CF, file path } submitted for bulk load * @return true if the default operation should be bypassed * @throws IOException */ public boolean preBulkLoadHFile(List<Pair<byte[], String>> familyPaths) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).preBulkLoadHFile(ctx, familyPaths); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * Invoked before a memstore flush * @throws IOException */ public InternalScanner preFlush(Store store, InternalScanner scanner) throws IOException { ObserverContext<RegionCoprocessorEnvironment> ctx = null; boolean bypass = false; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { scanner = ((RegionObserver)env.getInstance()).preFlush( ctx, store, scanner); } catch (Throwable e) { handleCoprocessorThrowable(env,e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass ? null : scanner; }
/** * @param miniBatchOp * @return true if default processing should be bypassed * @throws IOException */ public boolean preBatchMutate( final MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver) env.getInstance()).preBatchMutate(ctx, miniBatchOp); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param s the scanner * @return true if default behavior should be bypassed, false otherwise * @exception IOException Exception */ public boolean preScannerClose(final InternalScanner s) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).preScannerClose(ctx, s); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param get the Get request * @return true if default processing should be bypassed * @exception IOException Exception */ public boolean preGet(final Get get, final List<KeyValue> results) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).preGet(ctx, get, results); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param row the row key * @param family the family * @param result the result set from the region * @return true if default processing should be bypassed * @exception IOException Exception */ public boolean preGetClosestRowBefore(final byte[] row, final byte[] family, final Result result) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).preGetClosestRowBefore(ctx, row, family, result); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param scan the Scan specification * @return scanner id to return to client if default operation should be * bypassed, false otherwise * @exception IOException Exception */ public RegionScanner preScannerOpen(Scan scan) throws IOException { boolean bypass = false; RegionScanner s = null; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { s = ((RegionObserver)env.getInstance()).preScannerOpen(ctx, scan, s); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass ? s : null; }
/** * Called prior to rewriting the store files selected for compaction * @param store the store being compacted * @param scanner the scanner used to read store data during compaction * @param request the compaction that will be executed * @throws IOException */ public InternalScanner preCompact(Store store, InternalScanner scanner, CompactionRequest request) throws IOException { ObserverContext<RegionCoprocessorEnvironment> ctx = null; boolean bypass = false; for (RegionEnvironment env : coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { scanner = ((RegionObserver) env.getInstance()).preCompact(ctx, store, scanner, request); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass ? null : scanner; }
/** * @param append append object * @return result to return to client if default operation should be * bypassed, null otherwise * @throws IOException if an error occurred on the coprocessor */ public Result preAppend(Append append) throws IOException { boolean bypass = false; Result result = null; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { result = ((RegionObserver)env.getInstance()).preAppend(ctx, append); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass ? result : null; }
/** * @param put The Put object * @param edit The WALEdit object. * @param writeToWAL true if the change should be written to the WAL * @return true if default processing should be bypassed * @exception IOException Exception */ public boolean prePut(Put put, WALEdit edit, final boolean writeToWAL) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).prePut(ctx, put, edit, writeToWAL); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }
/** * @param delete The Delete object * @param edit The WALEdit object. * @param writeToWAL true if the change should be written to the WAL * @return true if default processing should be bypassed * @exception IOException Exception */ public boolean preDelete(Delete delete, WALEdit edit, final boolean writeToWAL) throws IOException { boolean bypass = false; ObserverContext<RegionCoprocessorEnvironment> ctx = null; for (RegionEnvironment env: coprocessors) { if (env.getInstance() instanceof RegionObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((RegionObserver)env.getInstance()).preDelete(ctx, delete, edit, writeToWAL); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } bypass |= ctx.shouldBypass(); if (ctx.shouldComplete()) { break; } } } return bypass; }