org.apache.hadoop.hbase.coprocessor.RegionObserver Java Examples

The following examples show how to use org.apache.hadoop.hbase.coprocessor.RegionObserver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @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 preAppendAfterRowLock(final Append append) throws IOException {
  boolean bypassable = true;
  Result defaultResult = null;
  if (this.coprocEnvironments.isEmpty()) {
    return defaultResult;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Result>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Result call(RegionObserver observer) throws IOException {
          return observer.preAppendAfterRowLock(this, append);
        }
      });
}
 
Example #2
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @param s the scanner
 * @param results the result set returned by the region server
 * @param limit the maximum number of results to return
 * @return 'has next' indication to client if bypassing default behavior, or null otherwise
 * @exception IOException Exception
 */
public Boolean preScannerNext(final InternalScanner s,
    final List<Result> results, final int limit) throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preScannerNext(this, s, results, limit, getResult());
        }
      });
}
 
Example #3
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked after a region is closed
 * @param abortRequested true if the server is aborting
 */
public void postClose(final boolean abortRequested) {
  try {
    execOperation(new RegionObserverOperationWithoutResult() {
      @Override
      public void call(RegionObserver observer) throws IOException {
        observer.postClose(this, abortRequested);
      }

      @Override
      public void postEnvCall() {
        shutdown(this.getEnvironment());
      }
    });
  } catch (IOException e) {
    LOG.warn(e.toString(), e);
  }
}
 
Example #4
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param put data to put if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 * otherwise
 */
public Boolean preCheckAndPut(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Put put)
    throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult,  bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndPut(this, row, family, qualifier,
              op, comparator, put, getResult());
        }
      });
}
 
Example #5
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked after a region open
 */
public void postOpen() {
  if (coprocEnvironments.isEmpty()) {
    return;
  }
  try {
    execOperation(new RegionObserverOperationWithoutResult() {
      @Override
      public void call(RegionObserver observer) throws IOException {
        observer.postOpen(this);
      }
    });
  } catch (IOException e) {
    LOG.warn(e.toString(), e);
  }
}
 
Example #6
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param filter filter
 * @param put data to put if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 * otherwise
 */
public Boolean preCheckAndPut(final byte [] row, final Filter filter, final Put put)
  throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
    new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
      defaultResult, bypassable) {
      @Override
      public Boolean call(RegionObserver observer) throws IOException {
        return observer.preCheckAndPut(this, row, filter, put, getResult());
      }
    });
}
 
Example #7
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param filter filter
 * @param put data to put if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 *   otherwise
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_BOOLEAN_RETURN_NULL",
  justification="Null is legit")
public Boolean preCheckAndPutAfterRowLock(
  final byte[] row, final Filter filter, final Put put) throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
    new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
      defaultResult, bypassable) {
      @Override
      public Boolean call(RegionObserver observer) throws IOException {
        return observer.preCheckAndPutAfterRowLock(this, row, filter, put, getResult());
      }
    });
}
 
Example #8
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param put data to put if check succeeds
 * @throws IOException e
 */
public boolean postCheckAndPut(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Put put,
    boolean result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, result) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.postCheckAndPut(this, row, family, qualifier,
              op, comparator, put, getResult());
        }
      });
}
 
Example #9
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param delete delete to commit if check succeeds
 * @return true or false to return to client if default processing should be bypassed,
 * or null otherwise
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_BOOLEAN_RETURN_NULL",
    justification="Null is legit")
public Boolean preCheckAndDeleteAfterRowLock(final byte[] row, final byte[] family,
    final byte[] qualifier, final CompareOperator op, final ByteArrayComparable comparator,
    final Delete delete) throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndDeleteAfterRowLock(this, row,
              family, qualifier, op, comparator, delete, getResult());
        }
      });
}
 
Example #10
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param delete delete to commit if check succeeds
 * @throws IOException e
 */
public boolean postCheckAndDelete(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Delete delete,
    boolean result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, result) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.postCheckAndDelete(this, row, family,
              qualifier, op, comparator, delete, getResult());
        }
      });
}
 
Example #11
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Called prior to opening store scanner for compaction.
 */
public ScanInfo preCompactScannerOpen(HStore store, ScanType scanType,
    CompactionLifeCycleTracker tracker, CompactionRequest request, User user) throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return store.getScanInfo();
  }
  CustomizedScanInfoBuilder builder = new CustomizedScanInfoBuilder(store.getScanInfo());
  execOperation(new RegionObserverOperationWithoutResult(user) {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preCompactScannerOpen(this, store, scanType, builder, tracker, request);
    }
  });
  return builder.build();
}
 
Example #12
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked before a region is closed
 * @param abortRequested true if the server is aborting
 */
public void preClose(final boolean abortRequested) throws IOException {
  execOperation(new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preClose(this, abortRequested);
    }
  });
}
 
Example #13
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param familyPaths pairs of { CF, file path } submitted for bulk load
 * @param map Map of CF to List of file paths for the final loaded files
 * @throws IOException
 */
public void postBulkLoadHFile(final List<Pair<byte[], String>> familyPaths,
    Map<byte[], List<Path>> map) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return;
  }
  execOperation(coprocEnvironments.isEmpty()? null:
      new RegionObserverOperationWithoutResult() {
        @Override
        public void call(RegionObserver observer) throws IOException {
          observer.postBulkLoadHFile(this, familyPaths, map);
        }
      });
}
 
Example #14
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param get the Get request
 * @param results What to return if return is true/'bypass'.
 * @return true if default processing should be bypassed.
 * @exception IOException Exception
 */
public boolean preGet(final Get get, final List<Cell> results) throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return false;
  }
  boolean bypassable = true;
  return execOperation(new RegionObserverOperationWithoutResult(bypassable) {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preGetOp(this, get, results);
    }
  });
}
 
Example #15
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
public void postCloseRegionOperation(final Operation op) throws IOException {
  execOperation(coprocEnvironments.isEmpty()? null:
      new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postCloseRegionOperation(this, op);
    }
  });
}
 
Example #16
Source File: TestBulkLoadReplication.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<RegionObserver> getRegionObserver() {
  return Optional.of(new RegionObserver() {

    @Override
    public void postBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
      List<Pair<byte[], String>> stagingFamilyPaths, Map<byte[], List<Path>> finalPaths)
        throws IOException {
      BULK_LOAD_LATCH.countDown();
      BULK_LOADS_COUNT.incrementAndGet();
      LOG.debug("Another file bulk loaded. Total for {}: {}", clusterName,
        bulkLoadCounts.addAndGet(1));
    }
  });
}
 
Example #17
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Called after the store compaction has completed.
 * @param store the store being compacted
 * @param resultFile the new store file written during compaction
 * @param tracker used to track the life cycle of a compaction
 * @param request the compaction request
 * @param user the user
 * @throws IOException
 */
public void postCompact(final HStore store, final HStoreFile resultFile,
    final CompactionLifeCycleTracker tracker, final CompactionRequest request, final User user)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty()? null: new RegionObserverOperationWithoutResult(user) {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postCompact(this, store, resultFile, tracker, request);
    }
  });
}
 
Example #18
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
public void postCommitStoreFile(final byte[] family, Path srcPath, Path dstPath) throws IOException {
  execOperation(coprocEnvironments.isEmpty()? null:
      new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postCommitStoreFile(this, family, srcPath, dstPath);
    }
  });
}
 
Example #19
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked after in memory compaction.
 */
public void postMemStoreCompaction(HStore store) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postMemStoreCompaction(this, store);
    }
  });
}
 
Example #20
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param info the RegionInfo for this region
 * @param edits the file of recovered edits
 */
public void preReplayWALs(final RegionInfo info, final Path edits) throws IOException {
  execOperation(coprocEnvironments.isEmpty()? null:
      new RegionObserverOperationWithoutResult(true) {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preReplayWALs(this, info, edits);
    }
  });
}
 
Example #21
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param get the Get request
 * @param results the result set
 * @exception IOException Exception
 */
public void postGet(final Get get, final List<Cell> results)
    throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return;
  }
  execOperation(new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postGetOp(this, get, results);
    }
  });
}
 
Example #22
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Called before open store scanner for user scan.
 */
public ScanInfo preStoreScannerOpen(HStore store, Scan scan) throws IOException {
  if (coprocEnvironments.isEmpty()) return store.getScanInfo();
  CustomizedScanInfoBuilder builder = new CustomizedScanInfoBuilder(store.getScanInfo(), scan);
  execOperation(new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preStoreScannerOpen(this, store, builder);
    }
  });
  return builder.build();
}
 
Example #23
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param put The Put object
 * @param edit The WALEdit object.
 * @param durability The durability used
 * @return true if default processing should be bypassed
 * @exception IOException Exception
 */
public boolean prePut(final Put put, final WALEdit edit, final Durability durability)
    throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return false;
  }
  boolean bypassable = true;
  return execOperation(new RegionObserverOperationWithoutResult(bypassable) {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.prePut(this, put, edit, durability);
    }
  });
}
 
Example #24
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param put The Put object
 * @param edit The WALEdit object.
 * @param durability The durability used
 * @exception IOException Exception
 */
public void postPut(final Put put, final WALEdit edit, final Durability durability)
    throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return;
  }
  execOperation(new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.postPut(this, put, edit, durability);
    }
  });
}
 
Example #25
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param delete The Delete object
 * @param edit The WALEdit object.
 * @param durability The durability used
 * @return true if default processing should be bypassed
 * @exception IOException Exception
 */
public boolean preDelete(final Delete delete, final WALEdit edit, final Durability durability)
    throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return false;
  }
  boolean bypassable = true;
  return execOperation(new RegionObserverOperationWithoutResult(bypassable) {
    @Override
    public void call(RegionObserver observer) throws IOException {
       observer.preDelete(this, delete, edit, durability);
    }
  });
}
 
Example #26
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param s the scanner
 * @param results the result set returned by the region server
 * @param limit the maximum number of results to return
 * @param hasMore
 * @return 'has more' indication to give to client
 * @exception IOException Exception
 */
public boolean postScannerNext(final InternalScanner s,
    final List<Result> results, final int limit, boolean hasMore)
    throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return hasMore;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, hasMore) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.postScannerNext(this, s, results, limit, getResult());
        }
      });
}
 
Example #27
Source File: HBaseAtlasCoprocessor.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void init(){
    if(LOG.isDebugEnabled()) {
        LOG.debug("==> HBaseAtlasCoprocessor.init()");
    }

    try {
        atlasPluginClassLoader = AtlasPluginClassLoader.getInstance(ATLAS_PLUGIN_TYPE, this.getClass());

        @SuppressWarnings("unchecked")
        Class<?> cls = Class.forName(ATLAS_HBASE_HOOK_IMPL_CLASSNAME, true, atlasPluginClassLoader);

        activatePluginClassLoader();

        impl                     = cls.newInstance();
        implMasterObserver       = (MasterObserver)impl;
        implRegionObserver       = (RegionObserver)impl;
        implRegionServerObserver = (RegionServerObserver)impl;
        implMasterCoprocessor 	 = (MasterCoprocessor)impl;

    } catch (Exception e) {
        // check what need to be done
        LOG.error("Error Enabling RangerHbasePlugin", e);
    } finally {
        deactivatePluginClassLoader();
    }

    if(LOG.isDebugEnabled()) {
        LOG.debug("<== HBaseAtlasCoprocessor.init()");
    }
}
 
Example #28
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param increment increment object
 * @param result the result returned by postIncrement
 * @throws IOException if an error occurred on the coprocessor
 */
public Result postIncrement(final Increment increment, Result result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Result>(regionObserverGetter, result) {
        @Override
        public Result call(RegionObserver observer) throws IOException {
          return observer.postIncrement(this, increment, getResult());
        }
      });
}
 
Example #29
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param row row to check
 * @param filter filter
 * @param delete delete to commit if check succeeds
 * @throws IOException e
 */
public boolean postCheckAndDelete(final byte [] row, final Filter filter, final Delete delete,
  boolean result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
    new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, result) {
      @Override
      public Boolean call(RegionObserver observer) throws IOException {
        return observer.postCheckAndDelete(this, row, filter, delete, getResult());
      }
    });
}
 
Example #30
Source File: TestAsyncTableScanException.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> c,
    InternalScanner s, List<Result> result, int limit, boolean hasNext) throws IOException {
  REQ_COUNT.incrementAndGet();
  if ((ERROR_AT == REQ_COUNT.get()) || ERROR) {
    if (DO_NOT_RETRY) {
      throw new DoNotRetryIOException("Injected exception");
    } else {
      throw new IOException("Injected exception");
    }
  }
  return RegionObserver.super.postScannerNext(c, s, result, limit, hasNext);
}