1 /*
2 * Copyright 2010 The Apache Software Foundation
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 package org.apache.hadoop.hbase.replication.regionserver;
21
22 import java.io.IOException;
23 import java.util.concurrent.atomic.AtomicBoolean;
24
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 public interface ReplicationSourceInterface {
34
35 /**
36 * Initializer for the source
37 * @param conf the configuration to use
38 * @param fs the file system to use
39 * @param manager the manager to use
40 * @param stopper the stopper object for this region server
41 * @param replicating the status of the replication on this cluster
42 * @param peerClusterId the id of the peer cluster
43 * @throws IOException
44 */
45 public void init(final Configuration conf,
46 final FileSystem fs,
47 final ReplicationSourceManager manager,
48 final Stoppable stopper,
49 final AtomicBoolean replicating,
50 final String peerClusterId) throws IOException;
51
52 /**
53 * Add a log to the list of logs to replicate
54 * @param log path to the log to replicate
55 */
56 public void enqueueLog(Path log);
57
58 /**
59 * Get the current log that's replicated
60 * @return the current log
61 */
62 public Path getCurrentPath();
63
64 /**
65 * Start the replication
66 */
67 public void startup();
68
69 /**
70 * End the replication
71 * @param reason why it's terminating
72 */
73 public void terminate(String reason);
74
75 /**
76 * End the replication
77 * @param reason why it's terminating
78 * @param cause the error that's causing it
79 */
80 public void terminate(String reason, Exception cause);
81
82 /**
83 * Get the id that the source is replicating to
84 *
85 * @return peer cluster id
86 */
87 public String getPeerClusterZnode();
88
89 /**
90 * Get the id that the source is replicating to.
91 *
92 * @return peer cluster id
93 */
94 public String getPeerClusterId();
95
96 /**
97 * Set if this source is enabled or disabled
98 * @param status the new status
99 */
100 public void setSourceEnabled(boolean status);
101 }