HDFS-16233. Do not use exception handler to implement copy-on-write for EnumCounters. (#3468)
(cherry picked from commit87632bbacf
) (cherry picked from commitbb08de559a
) (cherry picked from commit978ec57445
) (cherry picked from commitcd7c34f9b4
)
This commit is contained in:
parent
008bd8afc3
commit
6d11f7ae8c
|
@ -23,7 +23,6 @@ import org.apache.hadoop.fs.StorageType;
|
|||
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||
import org.apache.hadoop.hdfs.util.ConstEnumCounters;
|
||||
import org.apache.hadoop.hdfs.util.EnumCounters;
|
||||
import org.apache.hadoop.hdfs.util.ConstEnumCounters.ConstEnumException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -56,14 +55,10 @@ public class QuotaCounts {
|
|||
*/
|
||||
static <T extends Enum<T>> EnumCounters<T> modify(EnumCounters<T> counter,
|
||||
ModifyAction<T> action) {
|
||||
try {
|
||||
action.accept(counter);
|
||||
} catch (ConstEnumException cee) {
|
||||
// We don't call clone here because ConstEnumCounters.clone() will return
|
||||
// an object of class ConstEnumCounters. We want EnumCounters.
|
||||
if (counter instanceof ConstEnumCounters) {
|
||||
counter = counter.deepCopyEnumCounter();
|
||||
action.accept(counter);
|
||||
}
|
||||
action.accept(counter);
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue