-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-26913 Replication Observability Framework (#4862)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
- Loading branch information
Showing
39 changed files
with
1,971 additions
and
82 deletions.
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(); | ||
} |
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 |
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(); | ||
} | ||
} |
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.