001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.replication.regionserver;
019
020import org.apache.hadoop.hbase.HBaseInterfaceAudience;
021import org.apache.hadoop.hbase.TableName;
022import org.apache.hadoop.hbase.client.AsyncConnection;
023import org.apache.yetus.audience.InterfaceAudience;
024import org.apache.yetus.audience.InterfaceStability;
025
026/**
027 * Implementations are installed on a Replication Sink called from inside
028 * ReplicationSink#replicateEntries to filter replicated WALEntries based off WALEntry attributes.
029 * Currently only table name and replication write time are exposed (WALEntry is a private, internal
030 * class so we cannot pass it here). To install, set
031 * <code>hbase.replication.sink.walentryfilter</code> to the name of the implementing class.
032 * Implementing class must have a no-param Constructor.
033 * <p>
034 * This filter is of limited use. It is better to filter on the replication source rather than here
035 * after the edits have been shipped on the replication sink. That said, applications such as the
036 * hbase-indexer want to filter out any edits that were made before replication was enabled.
037 * @see org.apache.hadoop.hbase.replication.WALEntryFilter for filtering on the replication
038 *      source-side.
039 */
040@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION)
041@InterfaceStability.Evolving
042public interface WALEntrySinkFilter {
043  /**
044   * Name of configuration to set with name of implementing WALEntrySinkFilter class.
045   */
046  public static final String WAL_ENTRY_FILTER_KEY = "hbase.replication.sink.walentrysinkfilter";
047
048  /**
049   * Called after Construction. Use passed Connection to keep any context the filter might need.
050   */
051  void init(AsyncConnection conn);
052
053  /**
054   * @param table     Table edit is destined for.
055   * @param writeTime Time at which the edit was created on the source.
056   * @return True if we are to filter out the edit.
057   */
058  boolean filter(TableName table, long writeTime);
059}