adoroszlai commented on a change in pull request #1286:
URL: https://github.com/apache/hadoop-ozone/pull/1286#discussion_r467368213
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
##########
@@ -301,14 +302,19 @@ public InputStream readFile(String pathStr) throws
IOException {
}
}
+ @Deprecated
protected void incrementCounter(Statistic objectsRead) {
//noop: Use OzoneClientAdapterImpl which supports statistics.
Review comment:
```suggestion
protected void incrementCounter(Statistic objectsRead) {
incrementCounter(objectsRead, 1);
```
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java
##########
@@ -190,14 +190,19 @@ public InputStream readFile(String key) throws
IOException {
}
}
+ @Deprecated
protected void incrementCounter(Statistic objectsRead) {
//noop: Use OzoneClientAdapterImpl which supports statistics.
Review comment:
Why is this being deprecated? It could delegate to the new method.
```suggestion
protected void incrementCounter(Statistic objectsRead) {
incrementCounter(objectsRead, 1);
```
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
##########
@@ -457,45 +463,83 @@ public boolean deleteObject(String path) {
}
}
+ /**
+ * Helper function to check if the list of key paths are in the same volume
+ * and same bucket.
+ */
+ private boolean areInSameBucket(List<String> keyNameList) {
+ if (keyNameList.size() == 0) {
Review comment:
Nit: Sonar prefers `isEmpty()` over `size() == 0`.
```suggestion
if (keyNameList.isEmpty()) {
```
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
##########
@@ -220,17 +220,22 @@ protected InputStream createFSInputStream(InputStream
inputStream) {
return new OzoneFSInputStream(inputStream, statistics);
}
+ @Deprecated
protected void incrementCounter(Statistic statistic) {
//don't do anyting in this default implementation.
Review comment:
```suggestion
protected void incrementCounter(Statistic statistic) {
incrementCounter(statistic, 1);
```
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
##########
@@ -457,45 +463,83 @@ public boolean deleteObject(String path) {
}
}
+ /**
+ * Helper function to check if the list of key paths are in the same volume
+ * and same bucket.
+ */
+ private boolean areInSameBucket(List<String> keyNameList) {
+ if (keyNameList.size() == 0) {
+ return true;
+ }
+ String firstKeyPath = keyNameList.get(0);
+ final String volAndBucket = new OFSPath(firstKeyPath).getNonKeyPath();
+ // If any key path's volume and bucket from the second element and on
+ // in the list doesn't match the first element's, hasDifferentVolAndBucket
+ // would be true
+ boolean hasDifferentVolAndBucket = keyNameList.stream().skip(1)
+ .anyMatch(p -> !(new OFSPath(p).getNonKeyPath().equals(volAndBucket)));
+ return !hasDifferentVolAndBucket;
Review comment:
Nit: we could save two negations by using `allMatch()`.
##########
File path:
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
##########
@@ -183,25 +186,30 @@ public String getScheme() {
@Override
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
- incrementCounter(Statistic.INVOCATION_OPEN);
+ incrementCounter(Statistic.INVOCATION_OPEN, 1);
statistics.incrementReadOps(1);
LOG.trace("open() path: {}", path);
final String key = pathToKey(path);
return new FSDataInputStream(
new OzoneFSInputStream(adapter.readFile(key), statistics));
}
+ @Deprecated
protected void incrementCounter(Statistic statistic) {
//don't do anything in this default implementation.
Review comment:
```suggestion
protected void incrementCounter(Statistic statistic) {
incrementCounter(statistic, 1);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]