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