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.hadoop.hbase.HBaseInterfaceAudience;
021import org.apache.hadoop.hbase.wal.WAL.Entry;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * A Filter for WAL entries before being sent over to replication. Multiple filters might be chained
026 * together using {@link ChainWALEntryFilter}. Applied on the replication source side.
027 * <p>
028 * There is also a filter that can be installed on the sink end of a replication stream. See
029 * {@link org.apache.hadoop.hbase.replication.regionserver.WALEntrySinkFilter}. Certain use-cases
030 * may need such a facility but better to filter here on the source side rather than later, after
031 * the edit arrives at the sink.
032 * </p>
033 * @see org.apache.hadoop.hbase.replication.regionserver.WALEntrySinkFilter for filtering
034 *      replication on the sink-side.
035 */
036@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION)
037public interface WALEntryFilter {
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  Entry filter(Entry entry);
053}