Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.utils.BaseMetricsSource;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.metrics2.MetricsCollector;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.MetricsSource;
import org.apache.hadoop.metrics2.MetricsSystem;
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
Expand All @@ -40,7 +40,7 @@
*/
@InterfaceAudience.Private
@Metrics(about = "Storage Container Client Metrics", context = "dfs")
public class XceiverClientMetrics implements MetricsSource {
public class XceiverClientMetrics extends BaseMetricsSource {
public static final String SOURCE_NAME = XceiverClientMetrics.class
.getSimpleName();

Expand All @@ -52,10 +52,6 @@ public class XceiverClientMetrics implements MetricsSource {
private EnumMap<ContainerProtos.Type, MutableCounterLong> opsArray;
private EnumMap<ContainerProtos.Type, PerformanceMetrics> containerOpsLatency;

// TODO: https://issues.apache.org/jira/browse/HDDS-13555
@SuppressWarnings("PMD.SingularField")
private MetricsRegistry registry;

public XceiverClientMetrics() {
init();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.hdds.utils;

import org.apache.hadoop.metrics2.MetricsSource;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;

/**
* Base class for metrics sources that use MetricsRegistry.
* Eliminates the need for each metrics class to declare its own registry field.
*/
public abstract class BaseMetricsSource implements MetricsSource {

/**
* MetricsRegistry for creating and managing metrics.
* Protected so subclasses can access it directly.
*/
@SuppressWarnings("PMD.SingularField")
protected MetricsRegistry registry;
Comment on lines +33 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes checkstyle and findbugs failure.

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/BaseMetricsSource.java
 34: Variable 'registry' must be private and have accessor methods.
M D UuF: Unused public or protected field: org.apache.hadoop.hdds.utils.BaseMetricsSource.registry  In BaseMetricsSource.java

Also, please try not to add suppression in new code.

}

Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public class ContainerMetrics implements Closeable {
private final EnumMap<ContainerProtos.Type, MutableRate> opsLatency;
private final EnumMap<ContainerProtos.Type, MutableQuantiles[]> opsLatQuantiles;

// TODO: https://issues.apache.org/jira/browse/HDDS-13555
// MetricsRegistry must be kept as instance field to prevent GC and ensure metrics work correctly
@SuppressWarnings("PMD.SingularField")
private MetricsRegistry registry;
private final MetricsRegistry registry;

public ContainerMetrics(int[] intervals) {
final int len = intervals.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.hadoop.metrics2.MetricsSource;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.ozone.OzoneConsts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -61,8 +60,6 @@ public final class DatanodeQueueMetrics implements MetricsSource {
public static final String PIPELINE_ACTION_QUEUE_PREFIX =
"PipelineActionQueue";

private MetricsRegistry registry;

private DatanodeStateMachine datanodeStateMachine;
private static DatanodeQueueMetrics instance;

Expand All @@ -73,7 +70,6 @@ public final class DatanodeQueueMetrics implements MetricsSource {
private Map<InetSocketAddress, MetricsInfo> pipelineActionQueueMap;

public DatanodeQueueMetrics(DatanodeStateMachine datanodeStateMachine) {
this.registry = new MetricsRegistry(METRICS_SOURCE_NAME);
this.datanodeStateMachine = datanodeStateMachine;

initializeQueues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class CSMMetrics {
private final EnumMap<Type, MutableRate> opsLatencyMs;
private final EnumMap<Type, MutableRate> opsQueueingDelay;

// TODO: https://issues.apache.org/jira/browse/HDDS-13555
// MetricsRegistry must be kept as instance field to prevent GC and ensure metrics work correctly
@SuppressWarnings("PMD.SingularField")
private MetricsRegistry registry;
private final MetricsRegistry registry;

// Failure Metrics
private @Metric MutableCounterLong numWriteStateMachineFails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.OzoneConsts;
Expand All @@ -40,7 +39,6 @@ public final class SCMPerformanceMetrics implements MetricsSource {
private static final String SOURCE_NAME =
SCMPerformanceMetrics.class.getSimpleName();

private MetricsRegistry registry;
private static SCMPerformanceMetrics instance;

@Metric(about = "Number of failed deleteKeys")
Expand All @@ -61,7 +59,6 @@ public final class SCMPerformanceMetrics implements MetricsSource {
private MutableCounterLong deleteKeyBlocksFailure;

public SCMPerformanceMetrics() {
this.registry = new MetricsRegistry(SOURCE_NAME);
}

public static SCMPerformanceMetrics create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.Interns;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.OzoneConsts;
Expand Down Expand Up @@ -158,8 +157,6 @@ public final class ReplicationManagerMetrics implements MetricsSource {
" reaching the cluster inflight replication limit.")
private MutableCounterLong pendingReplicationLimitReachedTotal;

private MetricsRegistry registry;

private final ReplicationManager replicationManager;

//EC Metrics
Expand Down Expand Up @@ -225,7 +222,6 @@ public final class ReplicationManagerMetrics implements MetricsSource {
private MutableCounterLong replicateContainerCmdsDeferredTotal;

public ReplicationManagerMetrics(ReplicationManager manager) {
this.registry = new MetricsRegistry(METRICS_SOURCE_NAME);
this.replicationManager = manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.Interns;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.ozone.OzoneConsts;

Expand Down Expand Up @@ -60,13 +59,10 @@ public final class NodeDecommissionMetrics implements MetricsSource {
@Metric("Number of containers sufficiently replicated in tracked nodes.")
private MutableGaugeLong containersSufficientlyReplicatedTotal;

private MetricsRegistry registry;

private Map<String, ContainerStateInWorkflow> metricsByHost;

/** Private constructor. */
private NodeDecommissionMetrics() {
this.registry = new MetricsRegistry(METRICS_SOURCE_NAME);
metricsByHost = new HashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.Interns;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.OzoneConsts;
Expand All @@ -45,7 +44,6 @@ public final class SCMPipelineMetrics implements MetricsSource {
private static final String SOURCE_NAME =
SCMPipelineMetrics.class.getSimpleName();

private MetricsRegistry registry;
private static SCMPipelineMetrics instance;

private @Metric MutableCounterLong numPipelineAllocated;
Expand All @@ -61,7 +59,6 @@ public final class SCMPipelineMetrics implements MetricsSource {

/** Private constructor. */
private SCMPipelineMetrics() {
this.registry = new MetricsRegistry(SOURCE_NAME);
numBlocksAllocated = new ConcurrentHashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COMPOSE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export COMPOSE_DIR

export SECURITY_ENABLED=true
export COMPOSE_FILE=docker-compose.yaml:s3-haproxy.yaml
export OM_SERVICE_ID="omservice"
export SCM=scm1.org

Expand All @@ -38,7 +39,7 @@ execute_command_in_container kms hadoop key create ${OZONE_BUCKET_KEY_NAME}
## Exclude virtual-host tests. This is tested separately as it requires additional config.
exclude="--exclude virtual-host"
for bucket in encrypted; do
execute_robot_test recon -v BUCKET:${bucket} -N s3-${bucket} ${exclude} s3
execute_robot_test ${SCM} -v BUCKET:${bucket} -N s3-${bucket} ${exclude} s3
# some tests are independent of the bucket type, only need to be run once
## Exclude virtual-host.robot
exclude="--exclude virtual-host --exclude no-bucket-type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.ozone.OzoneConsts;

Expand All @@ -36,7 +35,6 @@ public final class DeletingServiceMetrics {

public static final String METRICS_SOURCE_NAME =
DeletingServiceMetrics.class.getSimpleName();
private MetricsRegistry registry;

/*
* Total directory deletion metrics across all iterations of DirectoryDeletingService since last restart.
Expand Down Expand Up @@ -122,7 +120,6 @@ public final class DeletingServiceMetrics {
private MutableGaugeLong lastAOSPurgeTransactionId;

private DeletingServiceMetrics() {
this.registry = new MetricsRegistry(METRICS_SOURCE_NAME);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.ozone.OzoneConsts;

Expand All @@ -32,7 +31,6 @@ public class OmSnapshotInternalMetrics {

public static final String METRICS_SOURCE_NAME =
OmSnapshotInternalMetrics.class.getSimpleName();
private MetricsRegistry registry;

/*
* Total internal snapshot deletion operation metrics since last restart.
Expand All @@ -52,7 +50,6 @@ public class OmSnapshotInternalMetrics {
private MutableCounterLong numSnapshotMoveTableKeysFails;

public OmSnapshotInternalMetrics() {
this.registry = new MetricsRegistry(METRICS_SOURCE_NAME);
}

public static OmSnapshotInternalMetrics create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public final class S3GatewayMetrics implements Closeable, MetricsSource {
public static final String SOURCE_NAME =
S3GatewayMetrics.class.getSimpleName();

// TODO: https://issues.apache.org/jira/browse/HDDS-13555
@SuppressWarnings("PMD.SingularField")
private MetricsRegistry registry;
private static S3GatewayMetrics instance;

// BucketEndpoint
Expand Down Expand Up @@ -286,7 +283,7 @@ public final class S3GatewayMetrics implements Closeable, MetricsSource {
* Private constructor.
*/
private S3GatewayMetrics(OzoneConfiguration conf) {
this.registry = new MetricsRegistry(SOURCE_NAME);
MetricsRegistry registry = new MetricsRegistry(SOURCE_NAME);
int[] intervals = conf.getInts(S3GatewayConfigKeys
.OZONE_S3G_METRICS_PERCENTILES_INTERVALS_SECONDS_KEY);
performanceMetrics = PerformanceMetrics.initializeMetrics(
Expand Down