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