-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19737: ABFS: [BugFix] Add metrics to identify improvements with read and write aggressiveness #8135
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
HADOOP-19737: ABFS: [BugFix] Add metrics to identify improvements with read and write aggressiveness #8135
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.fs.azurebfs; | ||
|
|
||
| import java.util.Random; | ||
|
|
||
| /** | ||
| * Provides a JVM-scoped identifier. | ||
| * | ||
| * <p>The identifier is generated once when the class is loaded and remains | ||
| * constant for the lifetime of the JVM. It is derived using a combination of | ||
| * the current system time and random entropy to reduce the likelihood of | ||
| * collisions across JVM instances.</p> | ||
| * | ||
| * <p>The identifier is intended for lightweight JVM-level identification, | ||
| * such as tagging metrics or log entries. It provides best-effort uniqueness | ||
| * and is not guaranteed to be globally unique.</p> | ||
| * | ||
| * <p>This class is utility-only and cannot be instantiated.</p> | ||
| */ | ||
| public final class JvmUniqueIdProvider { | ||
|
|
||
| /** Lower bound (inclusive) for the generated JVM identifier. */ | ||
| private static final int MIN_JVM_ID = 100_000; | ||
|
|
||
| /** Size of the identifier value range. */ | ||
| private static final int JVM_ID_RANGE = 900_000; | ||
|
|
||
| /** Upper bound for random entropy mixed into the identifier. */ | ||
| private static final int RANDOM_ENTROPY_BOUND = 1_000; | ||
|
|
||
| /** JVM-scoped identifier generated at class initialization time. */ | ||
| private static final int JVM_UNIQUE_ID; | ||
|
|
||
| static { | ||
| long time = System.currentTimeMillis(); | ||
| int random = new Random().nextInt(RANDOM_ENTROPY_BOUND); | ||
| JVM_UNIQUE_ID = (int) ((time + random) % JVM_ID_RANGE) + MIN_JVM_ID; | ||
| } | ||
|
|
||
| /** Prevents instantiation. */ | ||
| private JvmUniqueIdProvider() { | ||
| } | ||
|
|
||
| /** | ||
| * Returns the JVM-scoped identifier. | ||
| * | ||
| * @return an identifier that remains constant for the lifetime of the JVM | ||
| */ | ||
| public static int getJvmId() { | ||
| return JVM_UNIQUE_ID; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1338,7 +1338,11 @@ public AbfsRestOperation read(final String path, | |
| AbfsReadResourceUtilizationMetrics readResourceUtilizationMetrics = retrieveReadResourceUtilizationMetrics(); | ||
| // If metrics are available, record them in the tracing context for diagnostics or logging. | ||
| if (readResourceUtilizationMetrics != null) { | ||
| tracingContext.setResourceUtilizationMetricResults(readResourceUtilizationMetrics.toString()); | ||
| String readMetrics = readResourceUtilizationMetrics.toString(); | ||
|
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. With this logic, we can send same metrics data in two different read call, is this expected?
Contributor
Author
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. In toString() method, we are taking care of updateVersion and lastPushedVersion and pushing only if return updateVersion.get() > lastPushedVersion.get() to prevent same metric from getting pushed more than once, moreover markPushed is synchronized |
||
| tracingContext.setResourceUtilizationMetricResults(readMetrics); | ||
| if (!readMetrics.isEmpty()) { | ||
| readResourceUtilizationMetrics.markPushed(); | ||
| } | ||
| } | ||
| URL url = createRequestUrl(path, abfsUriQueryBuilder.toString()); | ||
| final AbfsRestOperation op = getAbfsRestOperation( | ||
|
|
||
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.
Add a unit test for this assertinf singleton behavior
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.
added