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