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;
019
020import org.apache.yetus.audience.InterfaceAudience;
021import org.apache.hadoop.hbase.HBaseInterfaceAudience;
022import org.apache.hadoop.hbase.wal.WAL.Entry;
023
024/**
025 * A Filter for WAL entries before being sent over to replication. Multiple
026 * filters might be chained together using {@link ChainWALEntryFilter}.
027 * Applied on the replication source side.
028 * <p>There is also a filter that can be installed on the sink end of a replication stream.
029 * See {@link org.apache.hadoop.hbase.replication.regionserver.WALEntrySinkFilter}. Certain
030 * use-cases may need such a facility but better to filter here on the source side rather
031 * than later, after the edit arrives at the sink.</p>
032 * @see org.apache.hadoop.hbase.replication.regionserver.WALEntrySinkFilter for filtering
033 * replication on the sink-side.
034 */
035@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION)
036public interface WALEntryFilter {
037
038  /**
039   * <p>
040   * Applies the filter, possibly returning a different Entry instance. If null is returned, the
041   * entry will be skipped.
042   * </p>
043   * <p>
044   * Notice that you are free to modify the cell list of the give entry, but do not change the
045   * content of the cell, it may be used by others at the same time(and usually you can not modify a
046   * cell unless you cast it to the implementation class, which is not a good idea).
047   * </p>
048   * @param entry Entry to filter
049   * @return a (possibly modified) Entry to use. Returning null or an entry with no cells will cause
050   *         the entry to be skipped for replication.
051   */
052  public Entry filter(Entry entry);
053}