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 org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * Perform read/write to the replication peer storage.
025 */
026@InterfaceAudience.Private
027public interface ReplicationPeerStorage {
028
029  /**
030   * Add a replication peer.
031   * @throws ReplicationException if there are errors accessing the storage service.
032   */
033  void addPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled,
034    SyncReplicationState syncReplicationState) throws ReplicationException;
035
036  /**
037   * Remove a replication peer.
038   * @throws ReplicationException if there are errors accessing the storage service.
039   */
040  void removePeer(String peerId) throws ReplicationException;
041
042  /**
043   * Set the state of peer, {@code true} to {@code ENABLED}, otherwise to {@code DISABLED}.
044   * @throws ReplicationException if there are errors accessing the storage service.
045   */
046  void setPeerState(String peerId, boolean enabled) throws ReplicationException;
047
048  /**
049   * Update the config a replication peer.
050   * @throws ReplicationException if there are errors accessing the storage service.
051   */
052  void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig)
053    throws ReplicationException;
054
055  /**
056   * Return the peer ids of all replication peers.
057   * @throws ReplicationException if there are errors accessing the storage service.
058   */
059  List<String> listPeerIds() throws ReplicationException;
060
061  /**
062   * Test whether a replication peer is enabled.
063   * @throws ReplicationException if there are errors accessing the storage service.
064   */
065  boolean isPeerEnabled(String peerId) throws ReplicationException;
066
067  /**
068   * Get the peer config of a replication peer.
069   * @throws ReplicationException if there are errors accessing the storage service.
070   */
071  ReplicationPeerConfig getPeerConfig(String peerId) throws ReplicationException;
072
073  /**
074   * Set the new sync replication state that we are going to transit to.
075   * @throws ReplicationException if there are errors accessing the storage service.
076   */
077  void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state)
078    throws ReplicationException;
079
080  /**
081   * Overwrite the sync replication state with the new sync replication state which is set with the
082   * {@link #setPeerNewSyncReplicationState(String, SyncReplicationState)} method above, and clear
083   * the new sync replication state.
084   * @throws ReplicationException if there are errors accessing the storage service.
085   */
086  void transitPeerSyncReplicationState(String peerId) throws ReplicationException;
087
088  /**
089   * Get the sync replication state.
090   * @throws ReplicationException if there are errors accessing the storage service.
091   */
092  SyncReplicationState getPeerSyncReplicationState(String peerId) throws ReplicationException;
093
094  /**
095   * Get the new sync replication state. Will return {@link SyncReplicationState#NONE} if we are not
096   * in a transition.
097   * @throws ReplicationException if there are errors accessing the storage service.
098   */
099  SyncReplicationState getPeerNewSyncReplicationState(String peerId) throws ReplicationException;
100}