Skip to content

Hadoop 18325 temp #4651

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

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
98d2901
Metric
anmolasrani123 May 12, 2022
16612d3
Metric changes
anmolasrani123 May 16, 2022
fb2295e
Metric changes
anmolasrani123 May 20, 2022
986d2e6
Metrics
anmolasrani123 May 27, 2022
23d9b47
Added final metrics
anmolasrani123 Jun 6, 2022
d57a746
Checkstyle fixes
anmolasrani123 Jun 7, 2022
4476d33
Added new params to metrics
anmolasrani123 Jun 14, 2022
d7b6be8
Incorrect total requests fix
anmolasrani123 Jun 21, 2022
324d2c0
Adding thread safety for metrics update
anmolasrani123 Jun 23, 2022
b9273d3
Made the metric enablement configurable
anmolasrani123 Jul 5, 2022
5fc1417
Removed hardcoded value for maxIoRetries
anmolasrani123 Jul 6, 2022
b185269
Fix null pointer exceptions
anmolasrani123 Jul 7, 2022
ef9691a
Fix for acronyms
anmolasrani123 Jul 8, 2022
3bddb11
Fix for spacing issues
anmolasrani123 Jul 11, 2022
4afba69
Added documentation for configs
anmolasrani123 Jul 12, 2022
0edb368
Update variable name
anmolasrani123 Jul 12, 2022
791b84e
Added config for URI
anmolasrani123 Jul 12, 2022
f6bad55
Test for max retries
anmolasrani123 Jul 13, 2022
9230bd8
Add test case for retry
anmolasrani123 Jul 13, 2022
e1c4c61
Refactored the test class
anmolasrani123 Jul 14, 2022
07aa9af
Merge branch 'metrics' of https://github.com/anmolanmol1234/hadoop in…
anmolasrani123 Jul 14, 2022
7686cce
Added comments
anmolasrani123 Jul 14, 2022
f9de500
Merge branch 'metrics' of https://github.com/anmolanmol1234/hadoop in…
anmolasrani123 Jul 14, 2022
f66bfe3
Back to previous configs
anmolasrani123 Jul 14, 2022
d0c0f68
remove test case
anmolasrani123 Jul 14, 2022
637060f
remove test case
anmolasrani123 Jul 14, 2022
a477400
remove test case
anmolasrani123 Jul 14, 2022
0f44a9b
Fix for checkstyle errors
anmolasrani123 Jul 15, 2022
312853c
Checkstyle error fixes
anmolasrani123 Jul 18, 2022
bca9c4e
Spotbugs fixes
anmolasrani123 Jul 18, 2022
4e99643
Merge branch 'apache:trunk' into HADOOP-18325
anmolanmol1234 Jul 25, 2022
a5ca55f
Added metrics for input stream
anmolasrani123 Jul 26, 2022
1d99d7b
Fix for input stream metrics
anmolasrani123 Jul 26, 2022
3b5ba52
Fix for input stream metrics
anmolasrani123 Jul 26, 2022
139b528
variable name fix
anmolasrani123 Jul 26, 2022
4e9cd93
Added changes for first read and second read
anmolasrani123 Jul 28, 2022
137f337
Merge branch 'apache:trunk' into HADOOP-18325_temp
anmolanmol1234 Jul 28, 2022
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 @@ -112,6 +112,11 @@ public class AbfsConfiguration{
DefaultValue = DEFAULT_READ_SMALL_FILES_COMPLETELY)
private boolean readSmallFilesCompletely;

@BooleanConfigurationValidatorAnnotation(
ConfigurationKey = AZURE_ENABLE_METRIC_COLLECTION,
DefaultValue = DEFAULT_AZURE_ENABLE_METRIC_COLLECTION)
private boolean enableMetricCollection;

@BooleanConfigurationValidatorAnnotation(
ConfigurationKey = AZURE_READ_OPTIMIZE_FOOTER_READ,
DefaultValue = DEFAULT_OPTIMIZE_FOOTER_READ)
Expand Down Expand Up @@ -689,6 +694,10 @@ public String getAppendBlobDirs() {
return this.azureAppendBlobDirs;
}

public boolean isMetricCollectionEnabled() {
return enableMetricCollection;
}

public String getAzureInfiniteLeaseDirs() {
return this.azureInfiniteLeaseDirs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import java.net.URI;
import java.util.Map;
import java.util.UUID;

import java.util.List;
import java.util.ArrayList;
import org.apache.hadoop.classification.VisibleForTesting;

import org.apache.hadoop.fs.azurebfs.services.AbfsCounters;
Expand All @@ -33,9 +34,10 @@
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.metrics2.lib.MutableMetric;

import org.apache.hadoop.fs.azurebfs.services.AbfsReadFooterMetrics;
import static org.apache.hadoop.fs.azurebfs.AbfsStatistic.*;
import static org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.iostatisticsStore;
import java.util.concurrent.atomic.AtomicReference;

/**
* Instrumentation of Abfs counters.
Expand Down Expand Up @@ -63,6 +65,10 @@ public class AbfsCountersImpl implements AbfsCounters {

private final IOStatisticsStore ioStatisticsStore;

private AtomicReference<AbfsDriverMetrics> abfsDriverMetrics = null;

private List<AbfsReadFooterMetrics> readFooterMetricsList;

private static final AbfsStatistic[] STATISTIC_LIST = {
CALL_CREATE,
CALL_OPEN,
Expand Down Expand Up @@ -121,6 +127,8 @@ public AbfsCountersImpl(URI uri) {
ioStatisticsStoreBuilder.withDurationTracking(durationStats.getStatName());
}
ioStatisticsStore = ioStatisticsStoreBuilder.build();
abfsDriverMetrics = new AtomicReference<>(new AbfsDriverMetrics());
readFooterMetricsList = new ArrayList<>();
}

/**
Expand Down Expand Up @@ -188,6 +196,14 @@ private MetricsRegistry getRegistry() {
return registry;
}

public AbfsDriverMetrics getAbfsDriverMetrics() {
return abfsDriverMetrics.get();
}

public List<AbfsReadFooterMetrics> getAbfsReadFooterMetrics() {
return readFooterMetricsList;
}

/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/**
* 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.fs.azurebfs;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.Map;
import java.util.ArrayList;
import java.util.Arrays;

public class AbfsDriverMetrics {

private AtomicLong numberOfRequestsSucceeded;

private AtomicLong minBackoff;

private AtomicLong maxBackoff;

private AtomicLong totalRequests;

private AtomicLong totalBackoff;

private String retryCount;

private AtomicLong numberOfIOPSThrottledRequests;

private AtomicLong numberOfBandwidthThrottledRequests;

private AtomicLong numberOfOtherThrottledRequests;

private AtomicLong numberOfNetworkFailedRequests;

private AtomicLong maxRetryCount;

private AtomicLong totalNumberOfRequests;

private AtomicLong numberOfRequestsSucceededWithoutRetrying;

private AtomicLong numberOfRequestsFailed;

private final Map<String, AbfsDriverMetrics> metricsMap
= new ConcurrentHashMap<>();

public AbfsDriverMetrics() {
initializeMap();
this.numberOfIOPSThrottledRequests = new AtomicLong();
this.numberOfBandwidthThrottledRequests = new AtomicLong();
this.numberOfOtherThrottledRequests = new AtomicLong();
this.totalNumberOfRequests = new AtomicLong();
this.maxRetryCount = new AtomicLong();
this.numberOfRequestsSucceededWithoutRetrying = new AtomicLong();
this.numberOfRequestsFailed = new AtomicLong();
this.numberOfNetworkFailedRequests = new AtomicLong();
}

public AbfsDriverMetrics(String retryCount) {
this.retryCount = retryCount;
this.numberOfRequestsSucceeded = new AtomicLong();
this.minBackoff = new AtomicLong(Long.MAX_VALUE);
this.maxBackoff = new AtomicLong();
this.totalRequests = new AtomicLong();
this.totalBackoff = new AtomicLong();
}

private void initializeMap() {
ArrayList<String> retryCountList = new ArrayList<String>(
Arrays.asList("1", "2", "3", "4", "5_15", "15_25", "25AndAbove"));
for (String s : retryCountList) {
metricsMap.put(s, new AbfsDriverMetrics(s));
}
}

public AtomicLong getNumberOfRequestsSucceeded() {
return numberOfRequestsSucceeded;
}

public AtomicLong getMinBackoff() {
return minBackoff;
}

public AtomicLong getMaxBackoff() {
return maxBackoff;
}

public AtomicLong getTotalRequests() {
return totalRequests;
}

public AtomicLong getTotalBackoff() {
return totalBackoff;
}

public String getRetryCount() {
return retryCount;
}

public AtomicLong getNumberOfIOPSThrottledRequests() {
return numberOfIOPSThrottledRequests;
}

public AtomicLong getNumberOfBandwidthThrottledRequests() {
return numberOfBandwidthThrottledRequests;
}

public AtomicLong getNumberOfOtherThrottledRequests() {
return numberOfOtherThrottledRequests;
}

public AtomicLong getMaxRetryCount() {
return maxRetryCount;
}

public AtomicLong getTotalNumberOfRequests() {
return totalNumberOfRequests;
}

public Map<String, AbfsDriverMetrics> getMetricsMap() {
return metricsMap;
}

public AtomicLong getNumberOfRequestsSucceededWithoutRetrying() {
return numberOfRequestsSucceededWithoutRetrying;
}

public AtomicLong getNumberOfRequestsFailed() {
return numberOfRequestsFailed;
}

public AtomicLong getNumberOfNetworkFailedRequests() {
return numberOfNetworkFailedRequests;
}

/*
Acronyms :-
1.RCTSI :- Request count that succeeded in x retries
2.MMA :- Min Max Average (This refers to the backoff or sleep time between 2 requests)
3.s :- seconds
4.BWT :- Number of Bandwidth throttled requests
5.IT :- Number of IOPS throttled requests
6.OT :- Number of Other throttled requests
7.NFR :- Number of requests which failed due to network errors
7.%RT :- Percentage of requests that are throttled
8.TRNR :- Total number of requests which succeeded without retrying
9.TRF :- Total number of requests which failed
10.TR :- Total number of requests which were made
11.MRC :- Max retry count across all requests
*/
@Override
public String toString() {
StringBuilder metricString = new StringBuilder();
long totalRequestsThrottled = numberOfBandwidthThrottledRequests.get()
+ numberOfIOPSThrottledRequests.get()
+ numberOfOtherThrottledRequests.get();
double percentageOfRequestsThrottled =
((double) totalRequestsThrottled / totalNumberOfRequests.get()) * 100;
for (Map.Entry<String, AbfsDriverMetrics> entry : metricsMap.entrySet()) {
metricString.append("#RCTSI#_").append(entry.getKey())
.append("R_").append("=")
.append(entry.getValue().getNumberOfRequestsSucceeded()).append(" ");
long totalRequests = entry.getValue().getTotalRequests().get();
if (totalRequests > 0) {
metricString.append("#MMA#_").append(entry.getKey())
.append("R_").append("=")
.append(String.format("%.3f",
(double) entry.getValue().getMinBackoff().get() / 1000L))
.append("s ")
.append(String.format("%.3f",
(double) entry.getValue().getMaxBackoff().get() / 1000L))
.append("s ")
.append(String.format("%.3f",
((double)entry.getValue().getTotalBackoff().get() / totalRequests)
/ 1000L))
.append("s ");
} else {
metricString.append("#MMA#_").append(entry.getKey())
.append("R_").append("=0s ");
}
}
metricString.append("#BWT=")
.append(numberOfBandwidthThrottledRequests)
.append(" #IT=")
.append(numberOfIOPSThrottledRequests)
.append(" #OT=")
.append(numberOfOtherThrottledRequests)
.append(" #%RT=")
.append(String.format("%.3f", percentageOfRequestsThrottled))
.append(" #NFR=")
.append(numberOfNetworkFailedRequests)
.append(" #TRNR=")
.append(numberOfRequestsSucceededWithoutRetrying)
.append(" #TRF=")
.append(numberOfRequestsFailed)
.append(" #TR=")
.append(totalNumberOfRequests)
.append(" #MRC=")
.append(maxRetryCount);

return metricString + " ";
}
}

Loading