-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-16961. ABFS: Adding metrics to AbfsInputStream #1946
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
bgaborg
wants to merge
1
commit into
apache:trunk
from
bgaborg:HADOOP-16961-abfs-streamstat-and-logging
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStreamStatistics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * 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.services; | ||
|
|
||
| import org.apache.hadoop.classification.InterfaceStability; | ||
|
|
||
| /** | ||
| * Interface for statistics for the AbfsInputStream. | ||
| */ | ||
| @InterfaceStability.Unstable | ||
| public interface AbfsInputStreamStatistics { | ||
| /** | ||
| * Seek backwards, incrementing the seek and backward seek counters. | ||
| * @param negativeOffset how far was the seek? | ||
| * This is expected to be negative. | ||
| */ | ||
| void seekBackwards(long negativeOffset); | ||
|
|
||
| /** | ||
| * Record a forward seek, adding a seek operation, a forward | ||
| * seek operation, and any bytes skipped. | ||
| * @param skipped number of bytes skipped by reading from the stream. | ||
| * If the seek was implemented by a close + reopen, set this to zero. | ||
| */ | ||
| void seekForwards(long skipped); | ||
|
|
||
| /** | ||
| * Record a forward or backward seek, adding a seek operation, a forward or | ||
| * a backward seek operation, and number of bytes skipped. | ||
| * @param seekTo seek to the position | ||
| * @param currentPos current position | ||
| */ | ||
| void seek(long seekTo, long currentPos); | ||
|
|
||
| /** | ||
| * Increment the bytes read counter by the number of bytes; | ||
| * no-op if the argument is negative. | ||
| * @param bytes number of bytes read | ||
| */ | ||
| void bytesRead(long bytes); | ||
|
|
||
| void bytesReadFromBuffer(long bytes); | ||
|
|
||
| void seekInBuffer(); | ||
|
|
||
| /** | ||
| * A {@code read(byte[] buf, int off, int len)} operation has started. | ||
| * @param pos starting position of the read | ||
| * @param len length of bytes to read | ||
| */ | ||
| void readOperationStarted(long pos, long len); | ||
|
|
||
| void remoteReadOperation(); | ||
|
|
||
| @Override | ||
| @InterfaceStability.Unstable | ||
| String toString(); | ||
| } |
145 changes: 145 additions & 0 deletions
145
...e/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStreamStatisticsImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| /** | ||
| * 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.services; | ||
|
|
||
| import org.apache.hadoop.classification.InterfaceStability; | ||
|
|
||
| /** | ||
| * Stats for the AbfsInputStream. | ||
| */ | ||
| public class AbfsInputStreamStatisticsImpl | ||
| implements AbfsInputStreamStatistics { | ||
| public volatile long seekOperations; | ||
| public volatile long forwardSeekOperations; | ||
| public volatile long backwardSeekOperations; | ||
| public volatile long bytesRead; | ||
| public volatile long bytesSkippedOnSeek; | ||
| public volatile long bytesBackwardsOnSeek; | ||
| public volatile long seekInBuffer; | ||
| public volatile long readOperations; | ||
| public volatile long bytesReadFromBuffer; | ||
| public volatile long remoteReadOperations; | ||
|
|
||
| /** | ||
| * Seek backwards, incrementing the seek and backward seek counters. | ||
| * @param negativeOffset how far was the seek? | ||
| * This is expected to be negative. | ||
| */ | ||
| @Override | ||
| public void seekBackwards(long negativeOffset) { | ||
| seekOperations++; | ||
| backwardSeekOperations++; | ||
| bytesBackwardsOnSeek -= negativeOffset; | ||
| } | ||
|
|
||
| /** | ||
| * Record a forward seek, adding a seek operation, a forward | ||
| * seek operation, and any bytes skipped. | ||
| * @param skipped number of bytes skipped by reading from the stream. | ||
| * If the seek was implemented by a close + reopen, set this to zero. | ||
| */ | ||
| @Override | ||
| public void seekForwards(long skipped) { | ||
| seekOperations++; | ||
| forwardSeekOperations++; | ||
| if (skipped > 0) { | ||
| bytesSkippedOnSeek += skipped; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Record a forward or backward seek, adding a seek operation, a forward or | ||
| * a backward seek operation, and number of bytes skipped. | ||
| * The seek direction will be calculated based on the parameters. | ||
| * @param seekTo seek to the position | ||
| * @param currentPos current position | ||
| */ | ||
| @Override | ||
| public void seek(long seekTo, long currentPos) { | ||
| if (seekTo >= currentPos) { | ||
| this.seekForwards(seekTo - currentPos); | ||
| } else { | ||
| this.seekBackwards(currentPos - seekTo); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Increment the bytes read counter by the number of bytes; | ||
| * no-op if the argument is negative. | ||
| * @param bytes number of bytes read | ||
| */ | ||
| @Override | ||
| public void bytesRead(long bytes) { | ||
| if (bytes > 0) { | ||
| bytesRead += bytes; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void bytesReadFromBuffer(long bytes) { | ||
| if (bytes > 0) { | ||
| bytesReadFromBuffer += bytes; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void seekInBuffer() { | ||
| seekInBuffer++; | ||
| } | ||
|
|
||
| /** | ||
| * A {@code read(byte[] buf, int off, int len)} operation has started. | ||
| * @param pos starting position of the read | ||
| * @param len length of bytes to read | ||
| */ | ||
| @Override | ||
| public void readOperationStarted(long pos, long len) { | ||
| readOperations++; | ||
| } | ||
|
|
||
| @Override | ||
| public void remoteReadOperation() { | ||
| remoteReadOperations++; | ||
| } | ||
|
|
||
| /** | ||
| * String operator describes all the current statistics. | ||
| * <b>Important: there are no guarantees as to the stability | ||
| * of this value.</b> | ||
| * @return the current values of the stream statistics. | ||
| */ | ||
| @Override | ||
| @InterfaceStability.Unstable | ||
| public String toString() { | ||
| final StringBuilder sb = new StringBuilder( | ||
| "StreamStatistics{"); | ||
| sb.append(", SeekOperations=").append(seekOperations); | ||
| sb.append(", ForwardSeekOperations=").append(forwardSeekOperations); | ||
| sb.append(", BackwardSeekOperations=").append(backwardSeekOperations); | ||
| sb.append(", BytesSkippedOnSeek=").append(bytesSkippedOnSeek); | ||
| sb.append(", BytesBackwardsOnSeek=").append(bytesBackwardsOnSeek); | ||
| sb.append(", seekInBuffer=").append(seekInBuffer); | ||
| sb.append(", BytesRead=").append(bytesRead); | ||
| sb.append(", ReadOperations=").append(readOperations); | ||
| sb.append(", bytesReadFromBuffer=").append(bytesReadFromBuffer); | ||
| sb.append(", remoteReadOperations=").append(remoteReadOperations); | ||
| sb.append('}'); | ||
| return sb.toString(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
interface rather than impl?