001/*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019package org.apache.hadoop.hbase.replication;
020
021import java.util.List;
022import java.util.Set;
023
024import org.apache.yetus.audience.InterfaceAudience;
025import org.apache.zookeeper.KeeperException;
026
027/**
028 * This provides an interface for clients of replication to view replication queues. These queues
029 * keep track of the sources(WALs/HFile references) that still need to be replicated to remote
030 * clusters.
031 */
032@InterfaceAudience.Private
033public interface ReplicationQueuesClient {
034
035  /**
036   * Initialize the replication queue client interface.
037   */
038  public void init() throws ReplicationException;
039
040  /**
041   * Get a list of all region servers that have outstanding replication queues. These servers could
042   * be alive, dead or from a previous run of the cluster.
043   * @return a list of server names
044   * @throws KeeperException zookeeper exception
045   */
046  List<String> getListOfReplicators() throws KeeperException;
047
048  /**
049   * Get a list of all WALs in the given queue on the given region server.
050   * @param serverName the server name of the region server that owns the queue
051   * @param queueId a String that identifies the queue
052   * @return a list of WALs, null if this region server is dead and has no outstanding queues
053   * @throws KeeperException zookeeper exception
054   */
055  List<String> getLogsInQueue(String serverName, String queueId) throws KeeperException;
056
057  /**
058   * Get a list of all queues for the specified region server.
059   * @param serverName the server name of the region server that owns the set of queues
060   * @return a list of queueIds, null if this region server is not a replicator.
061   */
062  List<String> getAllQueues(String serverName) throws KeeperException;
063
064  /**
065   * Load all wals in all replication queues from ZK. This method guarantees to return a
066   * snapshot which contains all WALs in the zookeeper at the start of this call even there
067   * is concurrent queue failover. However, some newly created WALs during the call may
068   * not be included.
069   */
070   Set<String> getAllWALs() throws KeeperException;
071
072  /**
073   * Get the change version number of replication hfile references node. This can be used as
074   * optimistic locking to get a consistent snapshot of the replication queues of hfile references.
075   * @return change version number of hfile references node
076   */
077  int getHFileRefsNodeChangeVersion() throws KeeperException;
078
079  /**
080   * Get list of all peers from hfile reference queue.
081   * @return a list of peer ids
082   * @throws KeeperException zookeeper exception
083   */
084  List<String> getAllPeersFromHFileRefsQueue() throws KeeperException;
085
086  /**
087   * Get a list of all hfile references in the given peer.
088   * @param peerId a String that identifies the peer
089   * @return a list of hfile references, null if not found any
090   * @throws KeeperException zookeeper exception
091   */
092  List<String> getReplicableHFiles(String peerId) throws KeeperException;
093}