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