-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-21406 "status 'replication'" should not show SINK if the cluste… #1761
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
54444c7
28562e0
64a3888
6645ae4
5b9f46c
d19ea42
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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| public class MetricsSink { | ||
|
|
||
| private long lastTimestampForAge = System.currentTimeMillis(); | ||
| private long startTimestamp = System.currentTimeMillis(); | ||
| private final MetricsReplicationSinkSource mss; | ||
|
|
||
| public MetricsSink() { | ||
|
|
@@ -98,4 +99,21 @@ public long getAgeOfLastAppliedOp() { | |
| public long getTimestampOfLastAppliedOp() { | ||
| return this.lastTimestampForAge; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the time stamp from when the Sink was initialized. | ||
| * @return startTimestamp | ||
| */ | ||
| public long getStartTimestamp() { | ||
| return startTimestamp; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the total number of OPs delivered to target by this sink. | ||
|
||
| * @return totalAplliedOps | ||
| */ | ||
| public long getAppliedOps() { | ||
| return this.mss.getSinkAppliedOps(); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,15 @@ public class TestReplicationStatus extends TestReplicationBase { | |
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestReplicationStatus.class); | ||
|
|
||
| private void insertRowsOnSource() throws IOException { | ||
| final byte[] qualName = Bytes.toBytes("q"); | ||
| for (int i = 0; i < NB_ROWS_IN_BATCH; i++) { | ||
| Put p = new Put(Bytes.toBytes("row" + i)); | ||
| p.addColumn(famName, qualName, Bytes.toBytes("val" + i)); | ||
| htable1.put(p); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test for HBASE-9531. | ||
| * <p/> | ||
|
|
@@ -70,12 +79,7 @@ public void testReplicationStatus() throws Exception { | |
| Admin hbaseAdmin = UTIL1.getAdmin(); | ||
| // disable peer <= WHY? I DON'T GET THIS DISABLE BUT TEST FAILS W/O IT. | ||
| hbaseAdmin.disableReplicationPeer(PEER_ID2); | ||
| final byte[] qualName = Bytes.toBytes("q"); | ||
| for (int i = 0; i < NB_ROWS_IN_BATCH; i++) { | ||
| Put p = new Put(Bytes.toBytes("row" + i)); | ||
| p.addColumn(famName, qualName, Bytes.toBytes("val" + i)); | ||
| htable1.put(p); | ||
| } | ||
| insertRowsOnSource(); | ||
| LOG.info("AFTER PUTS"); | ||
| // TODO: Change this wait to a barrier. I tried waiting on replication stats to | ||
| // change but sleeping in main thread seems to mess up background replication. | ||
|
|
@@ -120,6 +124,28 @@ public void testReplicationStatus() throws Exception { | |
| assertEquals(PEER_ID2, rLoadSourceList.get(0).getPeerID()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testReplicationStatusSink() throws Exception { | ||
| try (Admin hbaseAdmin = UTIL2.getConnection().getAdmin()) { | ||
| ServerName server = UTIL2.getHBaseCluster().getRegionServer(0).getServerName(); | ||
| ReplicationLoadSink loadSink = getLatestSinkMetric(hbaseAdmin, server); | ||
| //First checks if status of timestamp of last applied op is same as RS start, since no edits | ||
| //were replicated yet | ||
| assertEquals(loadSink.getTimestampStarted(), loadSink.getTimestampsOfLastAppliedOp()); | ||
| //now insert some rows on source, so that it gets delivered to target | ||
| insertRowsOnSource(); | ||
| Thread.sleep(10000); | ||
|
||
| loadSink = getLatestSinkMetric(hbaseAdmin, server); | ||
| assertTrue(loadSink.getTimestampsOfLastAppliedOp()>loadSink.getTimestampStarted()); | ||
| } | ||
| } | ||
|
|
||
| private ReplicationLoadSink getLatestSinkMetric(Admin admin, ServerName server) | ||
| throws IOException { | ||
| ClusterMetrics metrics = admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); | ||
| ServerMetrics sm = metrics.getLiveServerMetrics().get(server); | ||
| return sm.getReplicationLoadSink(); | ||
| } | ||
| /** | ||
| * Wait until Master shows metrics counts for ReplicationLoadSourceList that are | ||
| * greater than <code>greaterThan</code> for <code>serverName</code> before | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.