-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27448 Add an admin method to get replication enabled state #4855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ba40de1
61fb0d3
e2b4a50
2a04966
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,6 +271,15 @@ private void setPeerState(String peerId, boolean enabled) throws ReplicationExce | |
| desc.getSyncReplicationState())); | ||
| } | ||
|
|
||
| public boolean getPeerState(String peerId) throws ReplicationException { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better add a method to get the ReplicationPeerDescription? Anyway, not a big problem since this class is IA.Private. |
||
| ReplicationPeerDescription desc = peers.get(peerId); | ||
| if (desc != null) { | ||
| return desc.isEnabled(); | ||
| } else { | ||
| throw new ReplicationException("Replication Peer of " + peerId + " does not exist."); | ||
| } | ||
| } | ||
|
|
||
| public void enablePeer(String peerId) throws ReplicationException { | ||
| setPeerState(peerId, true); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hbase.replication; | ||
|
|
||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.testclassification.LargeTests; | ||
| import org.apache.hadoop.hbase.testclassification.ReplicationTests; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
|
|
||
| @Category({ ReplicationTests.class, LargeTests.class }) | ||
| public class TestGetReplicationPeerState extends TestReplicationBase { | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestGetReplicationPeerState.class); | ||
|
|
||
| @Test | ||
| public void testGetReplicationPeerState() throws Exception { | ||
|
||
|
|
||
| // Test disable replication peer | ||
| hbaseAdmin.disableReplicationPeer("2"); | ||
| assertFalse(hbaseAdmin.isReplicationPeerEnabled("2")); | ||
|
|
||
| // Test enable replication peer | ||
| hbaseAdmin.enableReplicationPeer("2"); | ||
| assertTrue(hbaseAdmin.isReplicationPeerEnabled("2")); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better put this method together with other replication related method :)