-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-26913 Replication Observability Framework #4556
Merged
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a174f10
HBASE-26925 Create WAL event tracker table to track all the WAL events.
shahrs87 07a1995
HBASE-27085 Create REPLICATION_SINK_TRACKER table to persist marker r…
shahrs87 32e8a71
HBASE-27100 Add documentation for Replication Observability Framework…
shahrs87 c3c544d
Addressing spotless warnings
shahrs87 79853af
Addressing review comments
shahrs87 49b84d2
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 302cd4e
Review comments
shahrs87 039a66e
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 9030646
spotless warnings
shahrs87 7126cfb
Adding NoRegionWALEdit class
shahrs87 78ca6d8
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 ebcba5d
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 d497720
Add a randomly picked region info with replication marker edits
shahrs87 267497e
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 d8d5436
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 4e68e97
Apply spotless warnings
shahrs87 a03c09c
Apply spotbugs warnings
shahrs87 87c3549
Apply javac warnings
shahrs87 480a41d
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 ddc3b19
Merge branch 'master' of https://github.com/apache/hbase into HBASE-2…
shahrs87 ff375a1
HBASE-26913 Add code review comments.
shahrs87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...compat/src/main/java/org/apache/hadoop/hbase/namequeues/MetricsWALEventTrackerSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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.namequeues; | ||
|
||
import org.apache.hadoop.hbase.metrics.BaseSource; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
@InterfaceAudience.Private | ||
public interface MetricsWALEventTrackerSource extends BaseSource { | ||
/** | ||
* The name of the metrics | ||
*/ | ||
String METRICS_NAME = "WALEventTracker"; | ||
|
||
/** | ||
* The name of the metrics context that metrics will be under. | ||
*/ | ||
String METRICS_CONTEXT = "regionserver"; | ||
|
||
/** | ||
* Description | ||
*/ | ||
String METRICS_DESCRIPTION = "Metrics about HBase RegionServer WALEventTracker"; | ||
|
||
/** | ||
* The name of the metrics context that metrics will be under in jmx | ||
*/ | ||
String METRICS_JMX_CONTEXT = "RegionServer,sub=" + METRICS_NAME; | ||
|
||
String NUM_FAILED_PUTS = "numFailedPuts"; | ||
String NUM_FAILED_PUTS_DESC = "Number of put requests that failed"; | ||
|
||
String NUM_RECORDS_FAILED_PUTS = "numRecordsFailedPuts"; | ||
String NUM_RECORDS_FAILED_PUTS_DESC = "number of records in failed puts"; | ||
|
||
/* | ||
* Increment 2 counters, numFailedPuts and numRecordsFailedPuts | ||
*/ | ||
void incrFailedPuts(long numRecords); | ||
|
||
/* | ||
* Get the failed puts counter. | ||
*/ | ||
long getFailedPuts(); | ||
|
||
/* | ||
* Get the number of records in failed puts. | ||
*/ | ||
long getNumRecordsFailedPuts(); | ||
} |
59 changes: 59 additions & 0 deletions
59
...at/src/main/java/org/apache/hadoop/hbase/namequeues/MetricsWALEventTrackerSourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.namequeues; | ||
|
||
import org.apache.hadoop.hbase.metrics.BaseSourceImpl; | ||
import org.apache.hadoop.metrics2.lib.MutableFastCounter; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
@InterfaceAudience.Private | ||
public class MetricsWALEventTrackerSourceImpl extends BaseSourceImpl | ||
implements MetricsWALEventTrackerSource { | ||
|
||
private final MutableFastCounter numFailedPutsCount; | ||
private final MutableFastCounter numRecordsFailedPutsCount; | ||
|
||
public MetricsWALEventTrackerSourceImpl() { | ||
this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); | ||
} | ||
|
||
public MetricsWALEventTrackerSourceImpl(String metricsName, String metricsDescription, | ||
String metricsContext, String metricsJmxContext) { | ||
super(metricsName, metricsDescription, metricsContext, metricsJmxContext); | ||
numFailedPutsCount = | ||
this.getMetricsRegistry().newCounter(NUM_FAILED_PUTS, NUM_FAILED_PUTS_DESC, 0L); | ||
numRecordsFailedPutsCount = this.getMetricsRegistry().newCounter(NUM_RECORDS_FAILED_PUTS, | ||
NUM_RECORDS_FAILED_PUTS_DESC, 0L); | ||
} | ||
|
||
@Override | ||
public void incrFailedPuts(long numRecords) { | ||
numFailedPutsCount.incr(); | ||
numRecordsFailedPutsCount.incr(numRecords); | ||
} | ||
|
||
@Override | ||
public long getFailedPuts() { | ||
return numFailedPutsCount.value(); | ||
} | ||
|
||
@Override | ||
public long getNumRecordsFailedPuts() { | ||
return numRecordsFailedPutsCount.value(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...sources/META-INF/services/org.apache.hadoop.hbase.namequeues.MetricsWALEventTrackerSource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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. | ||
# | ||
org.apache.hadoop.hbase.namequeues.MetricsWALEventTrackerSourceImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...main/java/org/apache/hadoop/hbase/master/waleventtracker/WALEventTrackerTableCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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.master.waleventtracker; | ||
|
||
import static org.apache.hadoop.hbase.HConstants.NO_NONCE; | ||
import static org.apache.hadoop.hbase.namequeues.WALEventTrackerTableAccessor.WAL_EVENT_TRACKER_TABLE_NAME_STR; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.HConstants; | ||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; | ||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder; | ||
import org.apache.hadoop.hbase.master.MasterServices; | ||
import org.apache.hadoop.hbase.namequeues.WALEventTrackerTableAccessor; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* WALEventTracker Table creation to be used by HMaster | ||
*/ | ||
@InterfaceAudience.Private | ||
public final class WALEventTrackerTableCreator { | ||
private static final Logger LOG = LoggerFactory.getLogger(WALEventTrackerTableCreator.class); | ||
|
||
public static final String WAL_EVENT_TRACKER_ENABLED_KEY = | ||
"hbase.regionserver.wal.event.tracker.enabled"; | ||
public static final boolean WAL_EVENT_TRACKER_ENABLED_DEFAULT = false; | ||
|
||
/** The walEventTracker info family as a string */ | ||
private static final String WAL_EVENT_TRACKER_INFO_FAMILY_STR = "info"; | ||
|
||
/** The walEventTracker info family in array of bytes */ | ||
public static final byte[] WAL_EVENT_TRACKER_INFO_FAMILY = | ||
Bytes.toBytes(WAL_EVENT_TRACKER_INFO_FAMILY_STR); | ||
|
||
private static final long TTL = TimeUnit.DAYS.toSeconds(365); // 1 year in seconds | ||
|
||
private static final TableDescriptorBuilder TABLE_DESCRIPTOR_BUILDER = TableDescriptorBuilder | ||
.newBuilder(WALEventTrackerTableAccessor.WAL_EVENT_TRACKER_TABLE_NAME).setRegionReplication(1) | ||
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(WAL_EVENT_TRACKER_INFO_FAMILY) | ||
.setScope(HConstants.REPLICATION_SCOPE_LOCAL).setBlockCacheEnabled(false).setMaxVersions(1) | ||
.setTimeToLive((int) TTL).build()); | ||
|
||
/* Private default constructor */ | ||
private WALEventTrackerTableCreator() { | ||
} | ||
|
||
/* | ||
* We will create this table only if hbase.regionserver.wal.event.tracker.enabled is enabled and | ||
* table doesn't exists already. | ||
*/ | ||
public static void createIfNeededAndNotExists(Configuration conf, MasterServices masterServices) | ||
throws IOException { | ||
boolean walEventTrackerEnabled = | ||
conf.getBoolean(WAL_EVENT_TRACKER_ENABLED_KEY, WAL_EVENT_TRACKER_ENABLED_DEFAULT); | ||
if (!walEventTrackerEnabled) { | ||
LOG.info("wal event tracker requests logging to table " + WAL_EVENT_TRACKER_TABLE_NAME_STR | ||
+ " is disabled. Quitting."); | ||
return; | ||
} | ||
if ( | ||
!masterServices.getTableDescriptors() | ||
.exists(WALEventTrackerTableAccessor.WAL_EVENT_TRACKER_TABLE_NAME) | ||
) { | ||
LOG.info(WAL_EVENT_TRACKER_TABLE_NAME_STR + " table not found. Creating."); | ||
masterServices.createTable(TABLE_DESCRIPTOR_BUILDER.build(), null, 0L, NO_NONCE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 not adding more things to HConstants, please move then to a more specific location.
And why adding a deprecated field here? Just remove it?
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.
We are replacing
hbase.slowlog.systable.chore.duration
withhbase.regionserver.named.queue.chore.duration
. Since the old config property already exists, we will have to follow deprecation cycle.Sounds good.