View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.replication;
20  
21  import java.util.List;
22  import java.util.SortedMap;
23  import java.util.SortedSet;
24  
25  import org.apache.hadoop.classification.InterfaceAudience;
26  import org.apache.zookeeper.KeeperException;
27  
28  /**
29   * This provides an interface for maintaining a region server's replication queues. These queues
30   * keep track of the HLogs that still need to be replicated to remote clusters.
31   */
32  @InterfaceAudience.Private
33  public interface ReplicationQueues {
34  
35    /**
36     * Initialize the region server replication queue interface.
37     * @param serverName The server name of the region server that owns the replication queues this
38     *          interface manages.
39     */
40    void init(String serverName) throws KeeperException;
41  
42    /**
43     * Remove a replication queue.
44     * @param queueId a String that identifies the queue.
45     */
46    void removeQueue(String queueId);
47  
48    /**
49     * Add a new HLog file to the given queue. If the queue does not exist it is created.
50     * @param queueId a String that identifies the queue.
51     * @param filename name of the HLog
52     * @throws KeeperException
53     */
54    void addLog(String queueId, String filename) throws KeeperException;
55  
56    /**
57     * Remove an HLog file from the given queue.
58     * @param queueId a String that identifies the queue.
59     * @param filename name of the HLog
60     */
61    void removeLog(String queueId, String filename);
62  
63    /**
64     * Set the current position for a specific HLog in a given queue.
65     * @param queueId a String that identifies the queue
66     * @param filename name of the HLog
67     * @param position the current position in the file
68     */
69    void setLogPosition(String queueId, String filename, long position);
70  
71    /**
72     * Get the current position for a specific HLog in a given queue.
73     * @param queueId a String that identifies the queue
74     * @param filename name of the HLog
75     * @return the current position in the file
76     */
77    long getLogPosition(String queueId, String filename) throws KeeperException;
78  
79    /**
80     * Remove all replication queues for this region server.
81     */
82    void removeAllQueues();
83  
84    /**
85     * Get a list of all HLogs in the given queue.
86     * @param queueId a String that identifies the queue
87     * @return a list of HLogs, null if this region server is dead and has no outstanding queues
88     */
89    List<String> getLogsInQueue(String queueId);
90  
91    /**
92     * Get a list of all queues for this region server.
93     * @return a list of queueIds, null if this region server is dead and has no outstanding queues
94     */
95    List<String> getAllQueues();
96  
97    /**
98     * Take ownership for the set of queues belonging to a dead region server.
99     * @param regionserver the id of the dead region server
100    * @return A SortedMap of the queues that have been claimed, including a SortedSet of HLogs in
101    *         each queue. Returns an empty map if no queues were failed-over.
102    */
103   SortedMap<String, SortedSet<String>> claimQueues(String regionserver);
104 
105   /**
106    * Get a list of all region servers that have outstanding replication queues. These servers could
107    * be alive, dead or from a previous run of the cluster.
108    * @return a list of server names
109    */
110   List<String> getListOfReplicators();
111 }