001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.replication; 019 020import java.util.List; 021import java.util.Map; 022import java.util.Set; 023 024import org.apache.hadoop.conf.Configuration; 025import org.apache.hadoop.hbase.HBaseInterfaceAudience; 026import org.apache.hadoop.hbase.TableName; 027import org.apache.yetus.audience.InterfaceAudience; 028 029/** 030 * ReplicationPeer manages enabled / disabled state for the peer. 031 */ 032@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION) 033public interface ReplicationPeer { 034 035 /** 036 * State of the peer, whether it is enabled or not 037 */ 038 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION) 039 enum PeerState { 040 ENABLED, 041 DISABLED 042 } 043 044 /** 045 * Get the identifier of this peer 046 * @return string representation of the id 047 */ 048 String getId(); 049 050 /** 051 * Returns the state of the peer by reading local cache. 052 * @return the enabled state 053 */ 054 PeerState getPeerState(); 055 056 /** 057 * Test whether the peer is enabled. 058 * @return {@code true} if enabled, otherwise {@code false}. 059 */ 060 default boolean isPeerEnabled() { 061 return getPeerState() == PeerState.ENABLED; 062 } 063 064 /** 065 * Get the peer config object 066 * @return the ReplicationPeerConfig for this peer 067 */ 068 ReplicationPeerConfig getPeerConfig(); 069 070 /** 071 * Get the configuration object required to communicate with this peer 072 * @return configuration object 073 */ 074 Configuration getConfiguration(); 075 076 /** 077 * Get replicable (table, cf-list) map of this peer 078 * @return the replicable (table, cf-list) map 079 */ 080 Map<TableName, List<String>> getTableCFs(); 081 082 /** 083 * Get replicable namespace set of this peer 084 * @return the replicable namespaces set 085 */ 086 Set<String> getNamespaces(); 087 088 /** 089 * Get the per node bandwidth upper limit for this peer 090 * @return the bandwidth upper limit 091 */ 092 long getPeerBandwidth(); 093 094 /** 095 * Register a peer config listener to catch the peer config change event. 096 * @param listener listener to catch the peer config change event. 097 */ 098 void registerPeerConfigListener(ReplicationPeerConfigListener listener); 099 100 /** 101 * @deprecated since 2.1.0 and will be removed in 4.0.0. Use 102 * {@link #registerPeerConfigListener(ReplicationPeerConfigListener)} instead. 103 * @see #registerPeerConfigListener(ReplicationPeerConfigListener) 104 * @see <a href="https://issues.apache.org/jira/browse/HBASE-10573">HBASE-19573</a> 105 */ 106 @Deprecated 107 default void trackPeerConfigChanges(ReplicationPeerConfigListener listener) { 108 registerPeerConfigListener(listener); 109 } 110}