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

The following examples show how to use org.apache.hadoop.hbase.coprocessor.RegionObserver. These examples are extracted from open source projects. 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 Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 2
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 3
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 4
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 5
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 6
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 7
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 8
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 9
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 10
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 11
Source Project: atlas   Source File: HBaseAtlasCoprocessor.java    License: 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 12
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 14
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 15
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoked before a memstore flush
 * @throws IOException
 */
public void preFlush(FlushLifeCycleTracker tracker) throws IOException {
  execOperation(coprocEnvironments.isEmpty()? null: new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preFlush(this, tracker);
    }
  });
}
 
Example 16
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoked before in memory compaction.
 */
public void preMemStoreCompaction(HStore store) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preMemStoreCompaction(this, store);
    }
  });
}
 
Example 17
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoked before create StoreScanner for in memory compaction.
 */
public ScanInfo preMemStoreCompactionCompactScannerOpen(HStore store) throws IOException {
  CustomizedScanInfoBuilder builder = new CustomizedScanInfoBuilder(store.getScanInfo());
  execOperation(coprocEnvironments.isEmpty() ? null : new RegionObserverOperationWithoutResult() {
    @Override
    public void call(RegionObserver observer) throws IOException {
      observer.preMemStoreCompactionCompactScannerOpen(this, store, builder);
    }
  });
  return builder.build();
}
 
Example 18
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoked before compacting memstore.
 */
public InternalScanner preMemStoreCompactionCompact(HStore store, InternalScanner scanner)
    throws IOException {
  if (coprocEnvironments.isEmpty()) {
    return scanner;
  }
  return execOperationWithResult(new ObserverOperationWithResult<RegionObserver, InternalScanner>(
      regionObserverGetter, scanner) {
    @Override
    public InternalScanner call(RegionObserver observer) throws IOException {
      return observer.preMemStoreCompactionCompact(this, store, getResult());
    }
  });
}
 
Example 19
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 21
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 23
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 24
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 25
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 26
Source Project: hbase   Source File: TestAsyncTableScanException.java    License: 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);
}
 
Example 27
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 28
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 29
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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 30
Source Project: hbase   Source File: RegionCoprocessorHost.java    License: 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);
    }
  });
}