Search in sources :

Example 1 with ObserverContext

use of org.apache.hadoop.hbase.coprocessor.ObserverContext in project hbase by apache.

the class SecureBulkLoadManager method prepareBulkLoad.

public String prepareBulkLoad(final Region region, final PrepareBulkLoadRequest request) throws IOException {
    List<BulkLoadObserver> bulkLoadObservers = getBulkLoadObservers(region);
    if (bulkLoadObservers != null && bulkLoadObservers.size() != 0) {
        ObserverContext<RegionCoprocessorEnvironment> ctx = new ObserverContext<>(getActiveUser());
        ctx.prepare((RegionCoprocessorEnvironment) region.getCoprocessorHost().findCoprocessorEnvironment(BulkLoadObserver.class).get(0));
        for (BulkLoadObserver bulkLoadObserver : bulkLoadObservers) {
            bulkLoadObserver.prePrepareBulkLoad(ctx, request);
        }
    }
    String bulkToken = createStagingDir(baseStagingDir, getActiveUser(), region.getTableDesc().getTableName()).toString();
    return bulkToken;
}
Also used : BulkLoadObserver(org.apache.hadoop.hbase.coprocessor.BulkLoadObserver) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) ObserverContext(org.apache.hadoop.hbase.coprocessor.ObserverContext)

Example 2 with ObserverContext

use of org.apache.hadoop.hbase.coprocessor.ObserverContext in project hbase by apache.

the class SecureBulkLoadManager method cleanupBulkLoad.

public void cleanupBulkLoad(final Region region, final CleanupBulkLoadRequest request) throws IOException {
    List<BulkLoadObserver> bulkLoadObservers = getBulkLoadObservers(region);
    if (bulkLoadObservers != null && bulkLoadObservers.size() != 0) {
        ObserverContext<RegionCoprocessorEnvironment> ctx = new ObserverContext<>(getActiveUser());
        ctx.prepare((RegionCoprocessorEnvironment) region.getCoprocessorHost().findCoprocessorEnvironment(BulkLoadObserver.class).get(0));
        for (BulkLoadObserver bulkLoadObserver : bulkLoadObservers) {
            bulkLoadObserver.preCleanupBulkLoad(ctx, request);
        }
    }
    fs.delete(new Path(request.getBulkToken()), true);
}
Also used : Path(org.apache.hadoop.fs.Path) BulkLoadObserver(org.apache.hadoop.hbase.coprocessor.BulkLoadObserver) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) ObserverContext(org.apache.hadoop.hbase.coprocessor.ObserverContext)

Aggregations

BulkLoadObserver (org.apache.hadoop.hbase.coprocessor.BulkLoadObserver)2 ObserverContext (org.apache.hadoop.hbase.coprocessor.ObserverContext)2 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)2 Path (org.apache.hadoop.fs.Path)1