Skip to content

Conversation

@steveloughran
Copy link
Contributor

Hadoop-common side of the patch

  • API definition
  • interface
  • tests
  • implementation
  • wiring up of the IO core classes

Change-Id: Ic0cdd0c3707066fff8b21f9cca6e7265a547267c
@steveloughran
Copy link
Contributor Author

hadoop common part of #2069 : API and impl,

While this is isolated for review, know that I'll be doing my changes on #2324 and cherry-picking here. It's just isolated for ease of review/to scare people less.

@steveloughran
Copy link
Contributor Author

I see the problem. This PR only includes the common changes, but as that moved some fs.impl methods to being public in a new package, the uses in the s3 code won't build.

[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19:15 min
[INFO] Finished at: 2020-09-21T20:50:29Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hadoop-aws: Compilation failure: Compilation failure: 
[ERROR] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[82,32] error: cannot find symbol
[ERROR] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[1637,25] error: package FunctionsRaisingIOE does not exist
[ERROR] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[1638,10] error: lambda expression not expected here
[ERROR] -> [Help 1]
[ERROR] 

Briefly I will reinstate the delete class from fs.impl so everything builds again

This is to allow hadoop-aws to compile without needing to move to the
moved interfaces; it will also allow anything external which used those
methods (unlikely) to keep working.

Also: throw synchronized at methods to get findbugs to STFU.

Tempting just to turn it off on the basis that it is overkill, but it could
maybe be correct.

Making all of MeanStatistics synchronized is irritating, as it will hurt
performance on what should be a lightweight class. But it is needed to
ensure samples and sum are consistently set.

Change-Id: I4c3e2726e1e97d705c55dbb43a507ea4d0e81e28
Change-Id: I5f64704a82a196fd8ff66cbde10d4970722e1fd7
@steveloughran
Copy link
Contributor Author

steveloughran commented Sep 24, 2020

findbugs

module:hadoop-common-project/hadoop-common
--
  | org.apache.hadoop.fs.statistics.IOStatisticsSnapshot's readObject method is synchronized At IOStatisticsSnapshot.java: At IOStatisticsSnapshot.java:[lines 241-254]

The synchronized was lifted from TreeMap writeObject. When I turn it off I'll be reasonably confident that findbugs will start complaining about unsynchronized accesses to field. Let's see. If it blows up then I'll just disable the check here

checkstyles are on the uses of the now deprecated methods;

[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CallableSupplier.java:[34,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[82,32] [deprecation] FunctionsRaisingIOE in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[83,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/RetryingCollection.java:[24,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CallableSupplier.java:[68,16] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java:[436,51] [deprecation] FAST_UPLOAD in Constants has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[829,13] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[1637,6] [deprecation] FunctionsRaisingIOE in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java:[1637,25] [deprecation] CallableRaisingIOE in FunctionsRaisingIOE has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/RetryingCollection.java:[103,18] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/RetryingCollection.java:[121,18] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/select/ITestS3SelectMRJob.java:[33,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/scale/ILoadTestS3ABulkDeleteThrottling.java:[48,32] [deprecation] FunctionsRaisingIOE in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/scale/ILoadTestS3ABulkDeleteThrottling.java:[49,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestDynamoDBMetadataStoreScale.java:[52,32] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/select/ITestS3SelectMRJob.java:[212,22] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/scale/ILoadTestS3ABulkDeleteThrottling.java:[320,21] [deprecation] FunctionsRaisingIOE in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/scale/ILoadTestS3ABulkDeleteThrottling.java:[320,40] [deprecation] CallableRaisingIOE in FunctionsRaisingIOE has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/scale/ILoadTestS3ABulkDeleteThrottling.java:[324,16] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated
[WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2323/src/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestDynamoDBMetadataStoreScale.java:[535,13] [deprecation] WrappedIOException in org.apache.hadoop.fs.impl has been deprecated

In the full s3a patch these are all migrated; in this PR I'm restricting all changes to hadoop-common, so will not fixe them in this patch

@apache apache deleted a comment from hadoop-yetus Sep 24, 2020
@apache apache deleted a comment from hadoop-yetus Sep 24, 2020
Change-Id: I3e9bb83bc32eddc5c7d84c1df7be77cea3e60f5d
Copy link
Contributor

@mehakmeet mehakmeet left a comment

Choose a reason for hiding this comment

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

For DurationTrackers in IOStatisticsStore() if we add a tracker in a try block, what happens to it in case of failure should be looked at to avoid inaccurate values for the trackers.

}

@Override
public long incrementCounter(final String key, final long value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should check if value>0 before incrementing to avoid negative values for counters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make a no-op. And test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed now

@steveloughran
Copy link
Contributor Author

steveloughran commented Sep 28, 2020

For DurationTrackers in IOStatisticsStore() if we add a tracker in a try block, what happens to it in case of failure should be looked at to avoid inaccurate values for the trackers.

I was thinking about failure reporting myself

  • we may want to count failures
  • any failure which with a longer or shorter duration than successful operations Will skew the results. Example: network failures -> long durations; auth failures -> short ones.

At the same time, try-with-resources is nice. What to do?

For each set of duration stats, we add counter/mean/min/max of failures
on a failure, those statistics are updated instead.

Issue: how best to record a failure, given we can't get at the try-with-resources classes in catch or finally? I'd initially thought we could set it in the catch(), but it'd be out of scope.

  1. Pessimistic: assume that all attempts are failure, make last operation in every try clause set the success flag. Ugly.
  2. Move construction out of try-with-resources and instead explicit catch and finally. Differently ugly

Fancy lambda-expression wrapper thing? Doable.

object = DurationTrackerFactory.track("statistic", () ->
  s3.listObjects());

Then in that code we'd put the code of option #2 in

Fancy curried-function-Haskell-elitism option

Duration tracker takes a function and returns a new one

FunctionRaisingIOE<A, B> track(String, FunctionRaisingIOE<A, B> inner)

you'd get a function back which you could then apply at leisure.

DurationTrackerFactory.track("statistic", () ->
  s3.listObjects()).apply();

Maybe worth doing both. I could also look at adding into the S3A Invoke code, as every iteration of a retried operation we'd want the statistic updated.

invoker.invoke(()-> durationTracker.track("listings",  () -> s3a.list()

That is where curried functions come out to play, with something like

invoker.invoke(durationTracker.track("listings", () -> s3a.list()). apply

At the same time: this gets complex fast. Could we make the design of this a followup?

@steveloughran
Copy link
Contributor Author

Update: you will get the ability to wrap a Callable, CallableRaisingIOE or functionRaisingIOE with a duration tracking, which then returns a new instance of the same

submit(unboundedThreadPool,
          trackDurationOfCallable(
              listingContext.getDurationTrackerFactory(),
              OBJECT_LIST_REQUEST,
              () -> listObjects(request)));

When there's a failure we update the failure count, move timings into the failures section. Attempts are counted for both, so success == attempts - failures.

- failures are registered and reported differently
- helper in statistics.impl to wrap functions and callable with handling for this

Move BufferedIOStatistics streams from impl to fs.statistics, so its declared
OK for others to use

counter increment to ignore negative values; returns existing value.
successful increment returns the latest value, as documented.

Tests for the counter and gauge behaviour

Change-Id: Ic851240ebe94033bf93e0a11abefb7adda534191
Copy link
Contributor

@mehakmeet mehakmeet left a comment

Choose a reason for hiding this comment

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

Have a doubt regarding getter for Min, Max, and Mean values for DurationTrackers.
for e.g ioStatisticsStore.getMeanStatistic(<STAT_NAME_FOR_DURATIONTRACKER>).mean();
should return a double value for the duration tracker but am met with a java.lang.NullPointerException: unknown statistic <STAT_NAME_FOR_DURATIONTRACKER>
error. This is solved when I add ".mean" at the end of the DurationTracker stat name. The same with Max(".max" has to be added) and Min(".min" has to be added) to fetch their values.
Was thinking if we could add it to the getter rather than having to append with stat name.

return 0;
}
if (value < 0) {
LOG.debug("Ignoring negative incrment value {} for counter {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in debug statement (incrment).

@steveloughran
Copy link
Contributor Author

error. This is solved when I add ".mean" at the end of the DurationTracker stat name. The same with Max(".max" has to be added) and Min(".min" has to be added) to fetch their values.
Was thinking if we could add it to the getter rather than having to append with stat name.

I'm a bit reluctant to, as then people would ask about failures next. What could be handy would be something in the support class to get all stats for a duration (or null), with some struct to contain them all. e.g

fetchDurationStatistics(IOStatistics, key) -> {count, min, max ,mean, failed, failed.min, failed.max, failed.mean), and you'd then work off that. Seem good?
Troublespot: what if only some of the values were found? they'd be null in the result. Maybe we'd let you ask for the success/failure stats separately, deal with it that way, and have some boolean isComplete() probe to check all are set

on hasNext/Next, close() is called, so as to cleanup any open state/handles
etc. Avoids having to tell developers downstream to look for an iterator
being closeable, and call it if so.

+ minor improvements in iterator test suite
+ fix typo found by Mehakmeet

Change-Id: Ibd103941278b8c0bc6c93a09ea469be4c60a58b1
@mehakmeet
Copy link
Contributor

In IOStatisticsBinding class we have methods for tracking duration but, I am not able to wrap it around a normal function.
There are 3 methods for tracking durations which are for Callable, CallableRaisingIOE, and FunctionRaisingIOE<A, B>. We should add 1 more for a normal function too.

+ add class which can be used to store duration results, primarily for
testing. Made public for others to play with too

Change-Id: I0a7f274f5a2a180e1800102be177b308050725c0
@steveloughran
Copy link
Contributor Author

@mehakmeet

  • duration tracking for classic function. Issue: are the names of the trackDuration calls correct now?
  • class DurationStatisticSummary to store and extract duration stats from a statistic.
  • which is used in the tests to verify that the new functions all work

@steveloughran
Copy link
Contributor Author

Yetus: javac is all about the deprecation changes fixed in #2324

checkstyles from new tests & code

./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:41:   * @deprecated use {@link org.apache.hadoop.util.functional.FunctionRaisingIOE}: Line is longer than 80 characters (found 81). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:54:   * @deprecated use {@link org.apache.hadoop.util.functional.BiFunctionRaisingIOE}: Line is longer than 80 characters (found 83). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:65:   * @deprecated use {@link org.apache.hadoop.util.functional.CallableRaisingIOE}: Line is longer than 80 characters (found 81). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/BufferedIOStatisticsInputStream.java:51:  /**: First sentence should end with a period. [JavadocStyle]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/package-info.java:28: * {@link org.apache.hadoop.fs.statistics.IOStatisticsSource#getIOStatistics()} .: Line is longer than 80 characters (found 81). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/functional/RemoteIterators.java:412:    /**: First sentence should end with a period. [JavadocStyle]
./hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/statistics/TestDurationTracking.java:112:        (Integer x) -> x);: 'lambda arguments' has incorrect indentation level 8, expected level should be one of the following: 10, 12. [Indentation]
./hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/statistics/TestDurationTracking.java:200:  /**: First sentence should end with a period. [JavadocStyle]

will fix those

* move the methods in fs.impl.FutureIOSupport which turn out to be needed
  when working with the async code to the public utils.functional package
* duration tracking invocation in IOStatisticsBinding tuning based on the
  ABFS coding experience.

Change-Id: Ide9467fa67a8a5d3d8daec94a7a39ff87f106a47
Fix checkstyle in RemoteIOException
unwrapping of exception looks for Error and rethrows

Change-Id: I673b1e487cae2ec3204ce6ba1103cdae14cfe48c
@apache apache deleted a comment from hadoop-yetus Oct 8, 2020
@apache apache deleted a comment from hadoop-yetus Oct 8, 2020
@steveloughran
Copy link
Contributor Author

javac failures on newly deprecated static fs.impl.FutureIOSupport methods I'm retaining to avoiding breaking things; checkstyle on 4 javadoc lines which are too wide because they reference other classes

./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:41:   * @deprecated use {@link org.apache.hadoop.util.functional.FunctionRaisingIOE}: Line is longer than 80 characters (found 81). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:54:   * @deprecated use {@link org.apache.hadoop.util.functional.BiFunctionRaisingIOE}: Line is longer than 80 characters (found 83). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/FunctionsRaisingIOE.java:65:   * @deprecated use {@link org.apache.hadoop.util.functional.CallableRaisingIOE}: Line is longer than 80 characters (found 81). [LineLength]
./hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/package-info.java:28: * {@link org.apache.hadoop.fs.statistics.IOStatisticsSource#getIOStatistics()} .: Line is longer than 80 characters (found 81). [LineLength]

@bgaborg bgaborg self-requested a review October 8, 2020 16:12
* the trackDuration(DurationTrackerFactory,...) methods support null factory
  and switch to a stub tracker
* there's an overloaded logIOStatisticsAtDebug() method to use the
  IOStatisticsLogging own logger

Change-Id: Ie786dc7aa8920a3fc8b22b55916f4b811810dab3
@hadoop-yetus

This comment has been minimized.

@steveloughran
Copy link
Contributor Author

build failure was in native IO. full PR in #2324 didn't show this. I'd rebase this PR except it would complicate everything else too much

* PairedDurationTrackerFactory allows listing code to update both FS and instance
  level stats.
* test assertions to become verifyStatistic* assertStatistic* to make clear
  these are statistic assertions; also helps code completion
* stream_read_unbuffered stream key

Change-Id: I25272fffeb3e66b5cec90ae6c6af74808c139b26
@steveloughran
Copy link
Contributor Author

Also, should use java.io.UncheckedIOException for the wrapper class for an IOE. That's new in Java8, but as its public API there, what we should adopt. This is good, even if its a bit more work

@steveloughran
Copy link
Contributor Author

This PR won't merge right now due to the move to shaded Preconditons. The PR #2324 has been rebased; I'll be rebuilding this PR from that one as a trunk + one big fat patch

@steveloughran
Copy link
Contributor Author

steveloughran commented Dec 15, 2020

Closing as it's impossible to maintain the interface and impl branches. The combined -common and -aws changes make for a bigger pr, but each patch has gone in separately, It will be possible to merge the changes into Hadoop as two separate patches

@steveloughran steveloughran deleted the s3/HADOOP-16830-iostatistics-common branch January 14, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants