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.regionserver;
20  
21  import java.io.IOException;
22  import java.util.List;
23  import java.util.UUID;
24  
25  import org.apache.hadoop.hbase.classification.InterfaceAudience;
26  import org.apache.hadoop.conf.Configuration;
27  import org.apache.hadoop.fs.FileSystem;
28  import org.apache.hadoop.fs.Path;
29  import org.apache.hadoop.hbase.Stoppable;
30  import org.apache.hadoop.hbase.TableName;
31  import org.apache.hadoop.hbase.replication.ReplicationEndpoint;
32  import org.apache.hadoop.hbase.replication.ReplicationException;
33  import org.apache.hadoop.hbase.replication.ReplicationPeers;
34  import org.apache.hadoop.hbase.replication.ReplicationQueues;
35  
36  /**
37   * Interface that defines a replication source
38   */
39  @InterfaceAudience.Private
40  public interface ReplicationSourceInterface {
41  
42    /**
43     * Initializer for the source
44     * @param conf the configuration to use
45     * @param fs the file system to use
46     * @param manager the manager to use
47     * @param replicationQueues
48     * @param replicationPeers
49     * @param stopper the stopper object for this region server
50     * @param peerClusterZnode
51     * @param clusterId
52     * @throws IOException
53     */
54    public void init(final Configuration conf, final FileSystem fs,
55        final ReplicationSourceManager manager, final ReplicationQueues replicationQueues,
56        final ReplicationPeers replicationPeers, final Stoppable stopper,
57        final String peerClusterZnode, final UUID clusterId, ReplicationEndpoint replicationEndpoint,
58        final MetricsSource metrics) throws IOException;
59  
60    /**
61     * Add a log to the list of logs to replicate
62     * @param log path to the log to replicate
63     */
64    void enqueueLog(Path log);
65  
66    /**
67     * Get the current log that's replicated
68     * @return the current log
69     */
70    Path getCurrentPath();
71  
72    /**
73     * Start the replication
74     */
75    void startup();
76  
77    /**
78     * End the replication
79     * @param reason why it's terminating
80     */
81    void terminate(String reason);
82  
83    /**
84     * End the replication
85     * @param reason why it's terminating
86     * @param cause the error that's causing it
87     */
88    void terminate(String reason, Exception cause);
89  
90    /**
91     * Get the id that the source is replicating to
92     *
93     * @return peer cluster id
94     */
95    String getPeerClusterZnode();
96  
97    /**
98     * Get the id that the source is replicating to.
99     *
100    * @return peer cluster id
101    */
102   String getPeerClusterId();
103 
104   /**
105    * Get a string representation of the current statistics
106    * for this source
107    * @return printable stats
108    */
109   String getStats();
110 
111   /**
112    * Add hfile names to the queue to be replicated.
113    * @param tableName Name of the table these files belongs to
114    * @param family Name of the family these files belong to
115    * @param files files whose names needs to be added to the queue to be replicated
116    * @throws ReplicationException If failed to add hfile references
117    */
118   void addHFileRefs(TableName tableName, byte[] family, List<String> files)
119       throws ReplicationException;
120 
121 }