Skip to content
Merged
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 @@ -41,6 +41,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants;
import org.apache.hadoop.fs.azurebfs.constants.HttpOperationType;
Expand Down Expand Up @@ -242,21 +243,24 @@ private AbfsClient(final URL baseUrl,
this.isMetricCollectionStopped = new AtomicBoolean(false);
this.metricAnalysisPeriod = abfsConfiguration.getMetricAnalysisTimeout();
this.metricIdlePeriod = abfsConfiguration.getMetricIdleTimeout();
if (!metricFormat.toString().equals("")) {
isMetricCollectionEnabled = true;
abfsCounters.initializeMetrics(metricFormat);
if (StringUtils.isNotEmpty(metricFormat.toString())) {
String metricAccountName = abfsConfiguration.getMetricAccount();
int dotIndex = metricAccountName.indexOf(AbfsHttpConstants.DOT);
if (dotIndex <= 0) {
throw new InvalidUriException(
metricAccountName + " - account name is not fully qualified.");
}
String metricAccountKey = abfsConfiguration.getMetricAccountKey();
try {
metricSharedkeyCredentials = new SharedKeyCredentials(metricAccountName.substring(0, dotIndex),
metricAccountKey);
} catch (IllegalArgumentException e) {
throw new IOException("Exception while initializing metric credentials " + e);
if (StringUtils.isNotEmpty(metricAccountName) && StringUtils.isNotEmpty(metricAccountKey)) {
isMetricCollectionEnabled = true;
abfsCounters.initializeMetrics(metricFormat);
int dotIndex = metricAccountName.indexOf(AbfsHttpConstants.DOT);
if (dotIndex <= 0) {
throw new InvalidUriException(
metricAccountName + " - account name is not fully qualified.");
}
try {
metricSharedkeyCredentials = new SharedKeyCredentials(
metricAccountName.substring(0, dotIndex),
metricAccountKey);
} catch (IllegalArgumentException e) {
throw new IOException("Exception while initializing metric credentials ", e);
}
}
}
if (isMetricCollectionEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_LOGGING_LEVEL_INFO;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_READ_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_WRITE_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_URI;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.MIN_BUFFER_SIZE;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_KB;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_MB;
Expand All @@ -30,6 +33,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.azurebfs.utils.MetricFormat;

import org.junit.Assume;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -47,6 +52,20 @@
public class ITestAbfsReadFooterMetrics extends AbstractAbfsScaleTest {

public ITestAbfsReadFooterMetrics() throws Exception {
checkPrerequisites();
}

private void checkPrerequisites(){
checkIfConfigIsSet(FS_AZURE_METRIC_ACCOUNT_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a method in base class already defined for this purpose. We can use that itself assumeValidTestConfigPresent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taken

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Here also we could have used the assumeValidTestConfigPresent method

checkIfConfigIsSet(FS_AZURE_METRIC_ACCOUNT_KEY);
checkIfConfigIsSet(FS_AZURE_METRIC_URI);
}

private void checkIfConfigIsSet(String configKey){
AbfsConfiguration conf = getConfiguration();
String value = conf.get(configKey);
Assume.assumeTrue(configKey + " config is mandatory for the test to run",
Copy link
Contributor

Choose a reason for hiding this comment

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

@anmolanmol1234 Should this be Assert.assertTrue instead of Assume.assumeTrue ?

Assume will skip the test in case of failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to skip the tests if the config is not present hence Assume.assumeTrue

value != null && value.trim().length() > 1);
}

private static final String TEST_PATH = "/testfile";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import org.apache.hadoop.fs.azurebfs.utils.MetricFormat;
import org.junit.Test;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.HTTP_METHOD_DELETE;
import static org.apache.hadoop.fs.azurebfs.services.AbfsRestOperationType.DeletePath;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_URI;
import static org.apache.hadoop.fs.azurebfs.services.AbfsRestOperationType.DeletePath;
import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem;
import org.apache.hadoop.fs.azurebfs.AbstractAbfsIntegrationTest;
import java.util.ArrayList;
Expand All @@ -39,6 +42,12 @@ public class TestAbfsRestOperation extends
public TestAbfsRestOperation() throws Exception {
}

private void checkPrerequisites() {
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_ACCOUNT_NAME);
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_ACCOUNT_KEY);
assumeValidTestConfigPresent(getRawConfiguration(), FS_AZURE_METRIC_URI);
}

/**
* Test for backoff retry metrics.
*
Expand All @@ -49,6 +58,7 @@ public TestAbfsRestOperation() throws Exception {
*/
@Test
public void testBackoffRetryMetrics() throws Exception {
checkPrerequisites();
// Create an AzureBlobFileSystem instance.
final Configuration configuration = getRawConfiguration();
configuration.set(FS_AZURE_METRIC_FORMAT, String.valueOf(MetricFormat.INTERNAL_BACKOFF_METRIC_FORMAT));
Expand Down
Loading