Skip to content

Commit c9f620c

Browse files
committed
HADOOP-16830. Reinstate the deleted FunctionsRaisingIOE class.
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
1 parent 22ad7d6 commit c9f620c

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.fs.impl;
20+
21+
import java.io.IOException;
22+
23+
import org.apache.hadoop.classification.InterfaceAudience;
24+
import org.apache.hadoop.classification.InterfaceStability;
25+
26+
/**
27+
* Support for functional programming/lambda-expressions.
28+
* @deprecated use {@code org.apache.hadoop.util.functional} classes
29+
*/
30+
@InterfaceAudience.Private
31+
@InterfaceStability.Unstable
32+
public final class FunctionsRaisingIOE {
33+
34+
private FunctionsRaisingIOE() {
35+
}
36+
37+
/**
38+
* Function of arity 1 which may raise an IOException.
39+
* @param <T> type of arg1
40+
* @param <R> type of return value.
41+
* @deprecated use {@link org.apache.hadoop.util.functional.FunctionRaisingIOE}
42+
*/
43+
@FunctionalInterface
44+
public interface FunctionRaisingIOE<T, R> {
45+
46+
R apply(T t) throws IOException;
47+
}
48+
49+
/**
50+
* Function of arity 2 which may raise an IOException.
51+
* @param <T> type of arg1
52+
* @param <U> type of arg2
53+
* @param <R> type of return value.
54+
* @deprecated use {@link org.apache.hadoop.util.functional.BiFunctionRaisingIOE}
55+
*/
56+
@FunctionalInterface
57+
public interface BiFunctionRaisingIOE<T, U, R> {
58+
59+
R apply(T t, U u) throws IOException;
60+
}
61+
62+
/**
63+
* This is a callable which only raises an IOException.
64+
* @param <R> return type
65+
* @deprecated use {@link org.apache.hadoop.util.functional.CallableRaisingIOE}
66+
*/
67+
@FunctionalInterface
68+
public interface CallableRaisingIOE<R> {
69+
70+
R apply() throws IOException;
71+
}
72+
73+
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsSnapshot.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,27 @@ public synchronized boolean aggregate(
179179
}
180180

181181
@Override
182-
public Map<String, Long> counters() {
182+
public synchronized Map<String, Long> counters() {
183183
return counters;
184184
}
185185

186186
@Override
187-
public Map<String, Long> gauges() {
187+
public synchronized Map<String, Long> gauges() {
188188
return gauges;
189189
}
190190

191191
@Override
192-
public Map<String, Long> minimums() {
192+
public synchronized Map<String, Long> minimums() {
193193
return minimums;
194194
}
195195

196196
@Override
197-
public Map<String, Long> maximums() {
197+
public synchronized Map<String, Long> maximums() {
198198
return maximums;
199199
}
200200

201201
@Override
202-
public Map<String, MeanStatistic> meanStatistics() {
202+
public synchronized Map<String, MeanStatistic> meanStatistics() {
203203
return meanStatistics;
204204
}
205205

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/MeanStatistic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ public synchronized boolean equals(final Object o) {
258258
// if we are empty, then so must the other.
259259
return that.isEmpty();
260260
}
261-
return sum == that.sum &&
262-
samples == that.samples;
261+
return getSum() == that.getSum() &&
262+
getSamples() == that.getSamples();
263263
}
264264

265265
@Override

0 commit comments

Comments
 (0)