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; 023import org.apache.hadoop.conf.Configuration; 024import org.apache.hadoop.hbase.HBaseInterfaceAudience; 025import org.apache.hadoop.hbase.TableName; 026import org.apache.yetus.audience.InterfaceAudience; 027 028/** 029 * ReplicationPeer manages enabled / disabled state for the peer. 030 */ 031@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION) 032public interface ReplicationPeer { 033 034 /** 035 * State of the peer, whether it is enabled or not 036 */ 037 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION) 038 enum PeerState { 039 ENABLED, 040 DISABLED 041 } 042 043 /** 044 * Get the identifier of this peer 045 * @return string representation of the id 046 */ 047 String getId(); 048 049 /** 050 * Returns the state of the peer by reading local cache. 051 * @return the enabled state 052 */ 053 PeerState getPeerState(); 054 055 /** 056 * Test whether the peer is enabled. 057 * @return {@code true} if enabled, otherwise {@code false}. 058 */ 059 default boolean isPeerEnabled() { 060 return getPeerState() == PeerState.ENABLED; 061 } 062 063 /** 064 * Get the peer config object 065 * @return the ReplicationPeerConfig for this peer 066 */ 067 ReplicationPeerConfig getPeerConfig(); 068 069 /** 070 * Get the configuration object required to communicate with this peer 071 * @return configuration object 072 */ 073 Configuration getConfiguration(); 074 075 /** 076 * Get replicable (table, cf-list) map of this peer 077 * @return the replicable (table, cf-list) map 078 */ 079 Map<TableName, List<String>> getTableCFs(); 080 081 /** 082 * Get replicable namespace set of this peer 083 * @return the replicable namespaces set 084 */ 085 Set<String> getNamespaces(); 086 087 /** 088 * Get the per node bandwidth upper limit for this peer 089 * @return the bandwidth upper limit 090 */ 091 long getPeerBandwidth(); 092 093 /** 094 * Register a peer config listener to catch the peer config change event. 095 * @param listener listener to catch the peer config change event. 096 */ 097 void registerPeerConfigListener(ReplicationPeerConfigListener listener); 098 099 /** 100 * @deprecated since 2.1.0 and will be removed in 4.0.0. Use 101 * {@link #registerPeerConfigListener(ReplicationPeerConfigListener)} instead. 102 * @see #registerPeerConfigListener(ReplicationPeerConfigListener) 103 * @see <a href="https://issues.apache.org/jira/browse/HBASE-10573">HBASE-19573</a> 104 */ 105 @Deprecated 106 default void trackPeerConfigChanges(ReplicationPeerConfigListener listener) { 107 registerPeerConfigListener(listener); 108 } 109}