This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 918086f4b7 HDDS-8804. Further clean up functional interfaces that
throw checked exceptions (#4871)
918086f4b7 is described below
commit 918086f4b78458ee50b676d97171ef7c15b0ced9
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Sat Jun 17 13:45:43 2023 +0200
HDDS-8804. Further clean up functional interfaces that throw checked
exceptions (#4871)
---
.../apache/hadoop/hdds/scm/XceiverClientGrpc.java | 5 +-
.../apache/hadoop/hdds/scm/XceiverClientRatis.java | 3 +-
...onWithServiceException.java => Predicates.java} | 37 ++++++----
.../hdds/function/SupplierWithIOException.java | 35 ----------
.../apache/hadoop/hdds/tracing/TracingUtil.java | 61 ++++++++---------
.../org/apache/hadoop/ozone/common/Storage.java | 14 ++--
.../authority/profile/DefaultCAProfile.java | 28 ++------
.../authority/profile/DefaultProfile.java | 79 +++++++---------------
.../certificate/authority/profile/PKIProfile.java | 5 +-
.../hadoop/hdds/security/x509/keys/KeyCodec.java | 15 ++--
.../server/OzoneProtocolMessageDispatcher.java | 4 +-
.../java/org/apache/hadoop/hdds/utils/HAUtils.java | 25 +------
.../hdds/scm/pipeline/TestPipelineManagerImpl.java | 9 +--
.../org/apache/ozone/test/GenericTestUtils.java | 11 +--
.../org/apache/hadoop/hdds/cli/OzoneAdmin.java | 4 +-
.../hadoop/ozone/client/OzoneKeyDetails.java | 20 ++----
.../apache/hadoop/ozone/client/rpc/RpcClient.java | 6 +-
.../hadoop/ozone/util/BooleanBiFunction.java | 29 --------
.../hadoop/ozone/MiniOzoneHAClusterImpl.java | 10 +--
.../apache/hadoop/ozone/dn/DatanodeTestUtils.java | 19 ++----
.../ozone/om/ratis/OzoneManagerDoubleBuffer.java | 68 ++++++++-----------
.../om/request/bucket/acl/OMBucketAclRequest.java | 27 ++------
.../request/bucket/acl/OMBucketAddAclRequest.java | 16 ++---
.../bucket/acl/OMBucketRemoveAclRequest.java | 17 ++---
.../request/bucket/acl/OMBucketSetAclRequest.java | 17 ++---
.../org/apache/hadoop/fs/ozone/OzoneFsShell.java | 4 +-
.../org/apache/hadoop/ozone/shell/OzoneShell.java | 5 +-
.../org/apache/hadoop/ozone/shell/s3/S3Shell.java | 4 +-
.../hadoop/ozone/shell/tenant/TenantShell.java | 4 +-
29 files changed, 178 insertions(+), 403 deletions(-)
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
index 332f667816..f178a7c7de 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto;
@@ -341,13 +340,11 @@ public class XceiverClientGrpc extends XceiverClientSpi {
String spanName = "XceiverClientGrpc." + request.getCmdType().name();
return TracingUtil.executeInNewSpan(spanName,
- (SupplierWithIOException<XceiverClientReply>) () -> {
-
+ () -> {
ContainerCommandRequestProto finalPayload =
ContainerCommandRequestProto.newBuilder(request)
.setTraceID(TracingUtil.exportCurrentSpan()).build();
return sendCommandWithRetry(finalPayload, validators);
-
});
}
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java
index 3ea269b08b..58492c10d1 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java
@@ -33,7 +33,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Supplier;
import java.util.stream.Stream;
import org.apache.hadoop.hdds.HddsUtils;
@@ -227,7 +226,7 @@ public final class XceiverClientRatis extends
XceiverClientSpi {
ContainerCommandRequestProto request) {
return TracingUtil.executeInNewSpan(
"XceiverClientRatis." + request.getCmdType().name(),
- (Supplier<CompletableFuture<RaftClientReply>>) () -> {
+ () -> {
final ContainerCommandRequestMessage message
= ContainerCommandRequestMessage.toMessage(
request, TracingUtil.exportCurrentSpan());
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/FunctionWithServiceException.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/Predicates.java
similarity index 64%
rename from
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/FunctionWithServiceException.java
rename to
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/Predicates.java
index b9d7bceb48..58e79ef05e 100644
---
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/FunctionWithServiceException.java
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/Predicates.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -17,20 +17,31 @@
*/
package org.apache.hadoop.hdds.function;
-import com.google.protobuf.ServiceException;
+import java.util.function.BiPredicate;
+import java.util.function.Predicate;
/**
- * Functional interface like java.util.function.Function but with
- * checked exception.
+ * Common predicates.
*/
-@FunctionalInterface
-public interface FunctionWithServiceException<T, R> {
+public final class Predicates {
+
+ public static <T> Predicate<T> yes() {
+ return x -> true;
+ }
+
+ public static <T> Predicate<T> no() {
+ return x -> false;
+ }
+
+ public static <T, U> BiPredicate<T, U> yesBi() {
+ return (t, u) -> true;
+ }
+
+ public static <T, U> BiPredicate<T, U> noBi() {
+ return (t, u) -> false;
+ }
- /**
- * Applies this function to the given argument.
- *
- * @param t the function argument
- * @return the function result
- */
- R apply(T t) throws ServiceException;
+ private Predicates() {
+ // no instances
+ }
}
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/SupplierWithIOException.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/SupplierWithIOException.java
deleted file mode 100644
index a30e69aebe..0000000000
---
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/function/SupplierWithIOException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.hdds.function;
-
-import java.io.IOException;
-
-/**
- * Functional interface like java.util.function.Supplier but with
- * checked exception.
- */
-@FunctionalInterface
-public interface SupplierWithIOException<T> {
-
- /**
- * Return the given output..
- *
- * @return the function result
- */
- T get() throws IOException;
-}
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java
index 2270db79c3..d30e50f803 100644
---
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/tracing/TracingUtil.java
@@ -17,13 +17,9 @@
*/
package org.apache.hadoop.hdds.tracing;
-import java.io.IOException;
import java.lang.reflect.Proxy;
-import java.util.concurrent.Callable;
-import java.util.function.Supplier;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import io.jaegertracing.Configuration;
@@ -33,6 +29,8 @@ import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
+import org.apache.ratis.util.function.CheckedRunnable;
+import org.apache.ratis.util.function.CheckedSupplier;
/**
* Utility class to collect all the tracing helper methods.
@@ -142,41 +140,31 @@ public final class TracingUtil {
}
/**
- * Call {@code callee} in a new active span.
+ * Execute {@code supplier} inside an activated new span.
*/
- public static <T> T executeInNewSpan(String spanName,
- Callable<T> callee)
- throws Exception {
+ public static <R, E extends Exception> R executeInNewSpan(String spanName,
+ CheckedSupplier<R, E> supplier) throws E {
Span span = GlobalTracer.get()
.buildSpan(spanName).start();
- try (Scope ignored = GlobalTracer.get().activateSpan(span)) {
- return callee.call();
- } catch (Exception ex) {
- span.setTag("failed", true);
- throw ex;
- } finally {
- span.finish();
- }
+ return executeInSpan(span, supplier);
}
/**
- * Execute a new function inside an activated span.
+ * Execute a function inside an activated new span.
*/
- public static <R> R executeInNewSpan(String spanName,
- SupplierWithIOException<R> supplier)
- throws IOException {
+ public static <E extends Exception> void executeInNewSpan(String spanName,
+ CheckedRunnable<E> runnable) throws E {
Span span = GlobalTracer.get()
.buildSpan(spanName).start();
- return executeInSpan(span, supplier);
+ executeInSpan(span, runnable);
}
/**
- * Execute a new function inside an activated span.
+ * Execute {@code supplier} in the given {@code span}.
+ * @return the value returned by {@code supplier}
*/
- public static <R> R executeInNewSpan(String spanName,
- Supplier<R> supplier) {
- Span span = GlobalTracer.get()
- .buildSpan(spanName).start();
+ private static <R, E extends Exception> R executeInSpan(Span span,
+ CheckedSupplier<R, E> supplier) throws E {
try (Scope ignored = GlobalTracer.get().activateSpan(span)) {
return supplier.get();
} catch (Exception ex) {
@@ -188,12 +176,12 @@ public final class TracingUtil {
}
/**
- * Execute a new function a given span.
+ * Execute {@code runnable} in the given {@code span}.
*/
- private static <R> R executeInSpan(Span span,
- SupplierWithIOException<R> supplier) throws IOException {
+ private static <E extends Exception> void executeInSpan(Span span,
+ CheckedRunnable<E> runnable) throws E {
try (Scope ignored = GlobalTracer.get().activateSpan(span)) {
- return supplier.get();
+ runnable.run();
} catch (Exception ex) {
span.setTag("failed", true);
throw ex;
@@ -205,12 +193,21 @@ public final class TracingUtil {
/**
* Execute a new function as a child span of the parent.
*/
- public static <R> R executeAsChildSpan(String spanName, String parentName,
- SupplierWithIOException<R> supplier) throws IOException {
+ public static <R, E extends Exception> R executeAsChildSpan(String spanName,
+ String parentName, CheckedSupplier<R, E> supplier) throws E {
Span span = TracingUtil.importAndCreateSpan(spanName, parentName);
return executeInSpan(span, supplier);
}
+ /**
+ * Execute a new function as a child span of the parent.
+ */
+ public static <E extends Exception> void executeAsChildSpan(String spanName,
+ String parentName, CheckedRunnable<E> runnable) throws E {
+ Span span = TracingUtil.importAndCreateSpan(spanName, parentName);
+ executeInSpan(span, runnable);
+ }
+
/**
* Create an active span with auto-close at finish.
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Storage.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Storage.java
index cc1f388f54..ae291c633f 100644
---
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Storage.java
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Storage.java
@@ -33,7 +33,7 @@ import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;
-import java.util.function.Supplier;
+import java.util.function.IntSupplier;
/**
* Storage information file. This Class defines the methods to check
@@ -57,8 +57,8 @@ public abstract class Storage {
private final File root;
private final File storageDir;
- private StorageState state;
- private StorageInfo storageInfo;
+ private final StorageState state;
+ private final StorageInfo storageInfo;
/**
@@ -220,7 +220,6 @@ public abstract class Storage {
* Check consistency of the storage directory.
*
* @return state {@link StorageState} of the storage directory
- * @throws IOException
*/
private StorageState getStorageState() throws IOException {
assert root != null : "root is null";
@@ -260,7 +259,6 @@ public abstract class Storage {
/**
* Creates the Version file if not present,
* otherwise returns with IOException.
- * @throws IOException
*/
public void initialize() throws IOException {
if (state == StorageState.INITIALIZED) {
@@ -274,7 +272,6 @@ public abstract class Storage {
/**
* Creates the Version file even if it exists.
- * @throws IOException
*/
public void forceInitialize() throws IOException {
if (state != StorageState.INITIALIZED) {
@@ -286,7 +283,6 @@ public abstract class Storage {
/**
* Persists current StorageInfo to file system..
- * @throws IOException
*/
public void persistCurrentState() throws IOException {
if (!getCurrentDir().exists()) {
@@ -298,10 +294,10 @@ public abstract class Storage {
protected static int getInitLayoutVersion(OzoneConfiguration conf,
String configKey,
- Supplier<Integer> defaultLvSupplier) {
+ IntSupplier defaultLvSupplier) {
int lV = conf.getInt(configKey, OZONE_INIT_DEFAULT_LAYOUT_VERSION_DEFAULT);
if (lV == OZONE_INIT_DEFAULT_LAYOUT_VERSION_DEFAULT) {
- lV = defaultLvSupplier.get();
+ lV = defaultLvSupplier.getAsInt();
}
return lV;
}
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultCAProfile.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultCAProfile.java
index 737fa5492e..8d35db7b3a 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultCAProfile.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultCAProfile.java
@@ -25,40 +25,22 @@ import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.KeyUsage;
import java.util.Map;
-import java.util.function.BiFunction;
-
-import static java.lang.Boolean.TRUE;
+import java.util.function.BiPredicate;
/**
* CA Profile, this is needed when SCM does HA.
- * A place holder class indicating what we need to do when we support issuing
+ * A placeholder class indicating what we need to do when we support issuing
* CA certificates to other SCMs in HA mode.
*/
public class DefaultCAProfile extends DefaultProfile {
- static final BiFunction<Extension, PKIProfile, Boolean>
+ private static final BiPredicate<Extension, PKIProfile>
VALIDATE_BASIC_CONSTRAINTS = DefaultCAProfile::validateBasicExtensions;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_CRL_NUMBER = (e, b) -> TRUE;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_REASON_CODE = (e, b) -> TRUE;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_DELTA_CRL_INDICATOR = (e, b) -> TRUE;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_NAME_CONSTRAINTS = (e, b) -> TRUE;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_CRL_DISTRIBUTION_POINTS = (e, b) -> TRUE;
-
private static boolean validateBasicExtensions(Extension ext,
PKIProfile pkiProfile) {
BasicConstraints constraints =
BasicConstraints.getInstance(ext.getParsedValue());
- if (constraints.isCA()) {
- if (pkiProfile.isCA()) {
- return true;
- }
- }
- return false;
+ return constraints.isCA() && pkiProfile.isCA();
}
@Override
@@ -68,7 +50,7 @@ public class DefaultCAProfile extends DefaultProfile {
@Override
public Map<ASN1ObjectIdentifier,
- BiFunction< Extension, PKIProfile, Boolean>> getExtensionsMap() {
+ BiPredicate<Extension, PKIProfile>> getExtensionsMap() {
// Add basic constraint.
EXTENSIONS_MAP.putIfAbsent(Extension.basicConstraints,
VALIDATE_BASIC_CONSTRAINTS);
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultProfile.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultProfile.java
index 4f9ad41a92..d565eedae4 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultProfile.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/DefaultProfile.java
@@ -42,11 +42,11 @@ import java.util.BitSet;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static java.lang.Boolean.TRUE;
+import static org.apache.hadoop.hdds.function.Predicates.yesBi;
import static org.bouncycastle.asn1.x509.KeyPurposeId.id_kp_clientAuth;
import static org.bouncycastle.asn1.x509.KeyPurposeId.id_kp_serverAuth;
@@ -57,17 +57,18 @@ import static
org.bouncycastle.asn1.x509.KeyPurposeId.id_kp_serverAuth;
* by SCM CA are constrained
*/
public class DefaultProfile implements PKIProfile {
- static final BiFunction<Extension, PKIProfile, Boolean>
+
+ private static final BiPredicate<Extension, PKIProfile>
VALIDATE_KEY_USAGE = DefaultProfile::validateKeyUsage;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_AUTHORITY_KEY_IDENTIFIER = (e, b) -> TRUE;
- static final BiFunction<Extension, PKIProfile, Boolean>
- VALIDATE_LOGO_TYPE = (e, b) -> TRUE;
+ private static final BiPredicate<Extension, PKIProfile>
+ VALIDATE_AUTHORITY_KEY_IDENTIFIER = yesBi();
+ private static final BiPredicate<Extension, PKIProfile> VALIDATE_LOGO_TYPE =
+ yesBi();
private static final Logger LOG =
LoggerFactory.getLogger(DefaultProfile.class);
- static final BiFunction<Extension, PKIProfile, Boolean>
+ private static final BiPredicate<Extension, PKIProfile>
VALIDATE_SAN = DefaultProfile::validateSubjectAlternativeName;
- static final BiFunction<Extension, PKIProfile, Boolean>
+ private static final BiPredicate<Extension, PKIProfile>
VALIDATE_EXTENDED_KEY_USAGE = DefaultProfile::validateExtendedKeyUsage;
// If we decide to add more General Names, we should add those here and
// also update the logic in validateGeneralName function.
@@ -77,8 +78,8 @@ public class DefaultProfile implements PKIProfile {
GeneralName.otherName,
};
// Map that handles all the Extensions lookup and validations.
- protected static final Map<ASN1ObjectIdentifier, BiFunction<Extension,
- PKIProfile, Boolean>> EXTENSIONS_MAP = Stream.of(
+ protected static final Map<ASN1ObjectIdentifier, BiPredicate<Extension,
+ PKIProfile>> EXTENSIONS_MAP = Stream.of(
new SimpleEntry<>(Extension.keyUsage, VALIDATE_KEY_USAGE),
new SimpleEntry<>(Extension.subjectAlternativeName, VALIDATE_SAN),
new SimpleEntry<>(Extension.authorityKeyIdentifier,
@@ -103,7 +104,7 @@ public class DefaultProfile implements PKIProfile {
};
private final Set<KeyPurposeId> extendKeyPurposeSet;
- private Set<Integer> generalNameSet;
+ private final Set<Integer> generalNameSet;
/**
* Construct DefaultProfile.
@@ -126,7 +127,7 @@ public class DefaultProfile implements PKIProfile {
* @param profile - PKI Profile - In this case this profile.
* @return True, if the request key usage is a subset, false otherwise.
*/
- private static Boolean validateKeyUsage(Extension ext, PKIProfile profile) {
+ private static boolean validateKeyUsage(Extension ext, PKIProfile profile) {
KeyUsage keyUsage = profile.getKeyUsage();
KeyUsage requestedUsage = KeyUsage.getInstance(ext.getParsedValue());
BitSet profileBitSet = BitSet.valueOf(keyUsage.getBytes());
@@ -145,7 +146,7 @@ public class DefaultProfile implements PKIProfile {
* @return - True if the request contains only SANs, General names that we
* support. False otherwise.
*/
- private static Boolean validateSubjectAlternativeName(Extension ext,
+ private static boolean validateSubjectAlternativeName(Extension ext,
PKIProfile profile) {
if (ext.isCritical()) {
// SAN extensions should not be marked as critical under ozone profile.
@@ -177,7 +178,7 @@ public class DefaultProfile implements PKIProfile {
* @param profile - PKI Profile - In this case this profile.
* @return True, if the request key usage is a subset, false otherwise.
*/
- private static Boolean validateExtendedKeyUsage(Extension ext,
+ private static boolean validateExtendedKeyUsage(Extension ext,
PKIProfile profile) {
if (ext.isCritical()) {
// https://tools.ietf.org/html/rfc5280#section-4.2.1.12
@@ -195,25 +196,16 @@ public class DefaultProfile implements PKIProfile {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public int[] getGeneralNames() {
return Arrays.copyOfRange(GENERAL_NAMES, 0, GENERAL_NAMES.length);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isSupportedGeneralName(int generalName) {
return generalNameSet.contains(generalName);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean validateGeneralName(int type, String value) {
// TODO : We should add more validation for IP address, for example
@@ -231,7 +223,7 @@ public class DefaultProfile implements PKIProfile {
// that before passing it on.
// getByAddress call converts the IP address to hostname/ipAddress
format.
- // if the hostname cannot determined then it will be /ipAddress.
+ // if the hostname cannot be determined then it will be /ipAddress.
// TODO: Fail? if we cannot resolve the Hostname?
try {
@@ -247,7 +239,7 @@ public class DefaultProfile implements PKIProfile {
case GeneralName.dNSName:
return DomainValidator.getInstance().isValid(value);
case GeneralName.otherName:
- // for other name its a general string, nothing to validate
+ // for other name it's a general string, nothing to validate
return true;
default:
// This should not happen, since it guarded via isSupportedGeneralName.
@@ -261,25 +253,16 @@ public class DefaultProfile implements PKIProfile {
return extendKeyPurposeSet.contains(id);
}
- /**
- * {@inheritDoc}
- */
@Override
public ASN1ObjectIdentifier[] getSupportedExtensions() {
return getExtensionsMap().keySet().toArray(new ASN1ObjectIdentifier[0]);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isSupportedExtension(Extension extension) {
return getExtensionsMap().containsKey(extension.getExtnId());
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean validateExtension(Extension extension) {
Preconditions.checkNotNull(extension, "Extension cannot be null");
@@ -290,44 +273,27 @@ public class DefaultProfile implements PKIProfile {
return false;
}
- BiFunction<Extension, PKIProfile, Boolean> func =
- EXTENSIONS_MAP.get(extension.getExtnId());
-
- if (func != null) {
- return func.apply(extension, this);
- }
- return false;
+ return EXTENSIONS_MAP.getOrDefault(extension.getExtnId(), (x, y) -> false)
+ .test(extension, this);
}
- /**
- * {@inheritDoc}
- */
@Override
public KeyUsage getKeyUsage() {
return new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment
| KeyUsage.dataEncipherment | KeyUsage.keyAgreement);
}
- /**
- * {@inheritDoc}
- */
@Override
public RDN[] getRDNs() {
return new RDN[0];
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isValidRDN(RDN distinguishedName) {
// TODO: Right now we just approve all strings.
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean validateRDN(RDN name) {
return true;
@@ -339,8 +305,9 @@ public class DefaultProfile implements PKIProfile {
}
@Override
- public Map<ASN1ObjectIdentifier, BiFunction< Extension, PKIProfile,
- Boolean>> getExtensionsMap() {
+ public Map<ASN1ObjectIdentifier, BiPredicate<Extension, PKIProfile>>
+ getExtensionsMap() {
return EXTENSIONS_MAP;
}
+
}
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/PKIProfile.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/PKIProfile.java
index 6e6a6b8f95..c8f563441c 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/PKIProfile.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/profile/PKIProfile.java
@@ -27,7 +27,7 @@ import org.bouncycastle.asn1.x509.KeyUsage;
import java.net.UnknownHostException;
import java.util.Map;
-import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
/**
* Base class for profile rules. Generally profiles are documents that define
@@ -142,8 +142,7 @@ public interface PKIProfile {
/**
* Return all extensions supported by this profile.
- * @return
*/
Map<ASN1ObjectIdentifier,
- BiFunction< Extension, PKIProfile, Boolean> > getExtensionsMap();
+ BiPredicate<Extension, PKIProfile>> getExtensionsMap();
}
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/keys/KeyCodec.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/keys/KeyCodec.java
index ab175d7838..b8d0104c61 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/keys/KeyCodec.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/keys/KeyCodec.java
@@ -48,7 +48,7 @@ import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Set;
-import java.util.function.Supplier;
+import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -69,13 +69,13 @@ public class KeyCodec {
LoggerFactory.getLogger(KeyCodec.class);
private final Path location;
private final SecurityConfig securityConfig;
- private Set<PosixFilePermission> dirPermissionSet =
+ private final Set<PosixFilePermission> dirPermissionSet =
Stream.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE)
.collect(Collectors.toSet());
- private Set<PosixFilePermission> filePermissionSet =
+ private final Set<PosixFilePermission> filePermissionSet =
Stream.of(OWNER_READ, OWNER_WRITE)
.collect(Collectors.toSet());
- private Supplier<Boolean> isPosixFileSystem;
+ private BooleanSupplier isPosixFileSystem;
/**
* Creates a KeyCodec with component name.
@@ -106,7 +106,7 @@ public class KeyCodec {
*
* @return True if it supports posix.
*/
- private static Boolean isPosix() {
+ private static boolean isPosix() {
return FileSystems.getDefault().supportedFileAttributeViews()
.contains("posix");
}
@@ -123,7 +123,6 @@ public class KeyCodec {
/**
* Returns the file permission set.
- * @return
*/
public Set<PosixFilePermission> getFilePermissionSet() {
return filePermissionSet;
@@ -145,7 +144,7 @@ public class KeyCodec {
* systems that are not posix.
*/
@VisibleForTesting
- public void setIsPosixFileSystem(Supplier<Boolean> isPosixFileSystem) {
+ public void setIsPosixFileSystem(BooleanSupplier isPosixFileSystem) {
this.isPosixFileSystem = isPosixFileSystem;
}
@@ -396,7 +395,7 @@ public class KeyCodec {
*/
private void checkPreconditions(Path basePath) throws IOException {
Preconditions.checkNotNull(basePath, "Base path cannot be null");
- if (!isPosixFileSystem.get()) {
+ if (!isPosixFileSystem.getAsBoolean()) {
LOG.error("Keys cannot be stored securely without POSIX file system "
+ "support for now.");
throw new IOException("Unsupported File System for pem file.");
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/OzoneProtocolMessageDispatcher.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/OzoneProtocolMessageDispatcher.java
index 5996bda7c2..b39707bfae 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/OzoneProtocolMessageDispatcher.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/OzoneProtocolMessageDispatcher.java
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hdds.server;
-import org.apache.hadoop.hdds.function.FunctionWithServiceException;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.hdds.utils.ProtocolMessageMetrics;
import com.google.protobuf.ServiceException;
import io.opentracing.Span;
+import org.apache.ratis.util.function.CheckedFunction;
import org.slf4j.Logger;
import java.util.function.UnaryOperator;
@@ -66,7 +66,7 @@ public class OzoneProtocolMessageDispatcher<REQUEST,
RESPONSE, TYPE> {
public RESPONSE processRequest(
REQUEST request,
- FunctionWithServiceException<REQUEST, RESPONSE> methodCall,
+ CheckedFunction<REQUEST, RESPONSE, ServiceException> methodCall,
TYPE type,
String traceId) throws ServiceException {
Span span = TracingUtil.importAndCreateSpan(type.toString(), traceId);
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
index 6ed7ce9214..342a0400cb 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
@@ -22,7 +22,6 @@ import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import
org.apache.hadoop.hdds.protocol.proto.SCMSecurityProtocolProtos.SCMGetCertResponseProto;
import
org.apache.hadoop.hdds.protocolPB.SCMSecurityProtocolClientSideTranslatorPB;
import org.apache.hadoop.hdds.scm.AddSCMRequest;
@@ -51,6 +50,7 @@ import org.apache.hadoop.ozone.OzoneSecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ratis.util.ExitUtils;
import org.apache.ratis.util.FileUtils;
+import org.apache.ratis.util.function.CheckedSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,7 +116,6 @@ public final class HAUtils {
* @param selfId - Node Id of the SCM which is submitting the request to
* add SCM.
* @return true - if SCM node is added successfully, else false.
- * @throws IOException
*/
public static boolean addSCM(OzoneConfiguration conf, AddSCMRequest request,
String selfId) throws IOException {
@@ -132,9 +131,6 @@ public final class HAUtils {
/**
* Create a scm block client.
- *
- * @return {@link ScmBlockLocationProtocol}
- * @throws IOException
*/
public static ScmBlockLocationProtocol getScmBlockClient(
OzoneConfiguration conf) {
@@ -177,7 +173,6 @@ public final class HAUtils {
* @param lastAppliedIndex the last applied index in the current SCM DB.
* @param checkpointPath path to the new DB checkpoint
* @return location of backup of the original DB
- * @throws Exception
*/
public static File replaceDBWithCheckpoint(long lastAppliedIndex,
File oldDB, Path checkpointPath, String dbPrefix) throws IOException {
@@ -250,10 +245,7 @@ public final class HAUtils {
/**
* Obtain Transaction info from DB.
- * @param tempConfig
* @param dbDir path to DB
- * @return TransactionInfo
- * @throws IOException
*/
private static TransactionInfo getTransactionInfoFromDB(
OzoneConfiguration tempConfig, Path dbDir, String dbName,
@@ -296,11 +288,6 @@ public final class HAUtils {
*
* If transaction info transaction Index is less than or equal to
* lastAppliedIndex, return false, else return true.
- * @param transactionInfo
- * @param lastAppliedIndex
- * @param leaderId
- * @param newDBlocation
- * @return boolean
*/
public static boolean verifyTransactionInfo(TransactionInfo transactionInfo,
long lastAppliedIndex, String leaderId, Path newDBlocation,
@@ -391,10 +378,7 @@ public final class HAUtils {
*
* If certificate client is null, obtain the list of CA using SCM security
* client, else it uses certificate client.
- * @param certClient
- * @param configuration
* @return list of CA
- * @throws IOException
*/
public static List<String> buildCAList(CertificateClient certClient,
ConfigurationSource configuration) throws IOException {
@@ -483,13 +467,13 @@ public final class HAUtils {
}
private static List<String> waitForCACerts(
- final SupplierWithIOException<List<String>> applyFunction,
+ final CheckedSupplier<List<String>, IOException> caCertListSupplier,
int expectedCount) throws IOException {
// TODO: If SCMs are bootstrapped later, then listCA need to be
// refetched if listCA size is less than scm ha config node list size.
// For now when Client of SCM's are started we compare their node list
// size and ca list size if it is as expected, we return the ca list.
- List<String> caCertPemList = applyFunction.get();
+ List<String> caCertPemList = caCertListSupplier.get();
boolean caListUpToDate = caCertPemList.size() >= expectedCount;
if (!caListUpToDate) {
LOG.info("Expected CA list size {}, where as received CA List size " +
@@ -504,10 +488,7 @@ public final class HAUtils {
* Build CA List in the format of X509Certificate.
* If certificate client is null, obtain the list of CA using SCM
* security client, else it uses certificate client.
- * @param certClient
- * @param conf
* @return list of CA X509Certificates.
- * @throws IOException
*/
public static List<X509Certificate> buildCAX509List(
CertificateClient certClient,
diff --git
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
index 338fdfbdd3..80d3515247 100644
---
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
+++
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.hdds.scm.pipeline;
-import com.google.common.base.Supplier;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
@@ -724,12 +723,8 @@ public class TestPipelineManagerImpl {
// Simulate safemode check exiting.
scmContext.updateSafeModeStatus(
new SCMSafeModeManager.SafeModeStatus(true, true));
- GenericTestUtils.waitFor(new Supplier<Boolean>() {
- @Override
- public Boolean get() {
- return pipelineManager.getPipelines().size() != 0;
- }
- }, 100, 10000);
+ GenericTestUtils.waitFor(() -> pipelineManager.getPipelines().size() != 0,
+ 100, 10000);
pipelineManager.close();
}
diff --git
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
index 01abe67291..b2215f46ed 100644
---
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
+++
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.concurrent.TimeoutException;
import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -46,6 +45,7 @@ import org.junit.Assert;
import org.mockito.Mockito;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -60,7 +60,8 @@ public abstract class GenericTestUtils {
public static final String DEFAULT_TEST_DATA_DIR;
public static final String DEFAULT_TEST_DATA_PATH = "target/test/data/";
/**
- * Error string used in {@link GenericTestUtils#waitFor(Supplier, int, int)}.
+ * Error string used in
+ * {@link GenericTestUtils#waitFor(BooleanSupplier, int, int)}.
*/
public static final String ERROR_MISSING_ARGUMENT =
"Input supplier interface should be initialized";
@@ -211,18 +212,18 @@ public abstract class GenericTestUtils {
* time
* @throws InterruptedException if the method is interrupted while waiting
*/
- public static void waitFor(Supplier<Boolean> check, int checkEveryMillis,
+ public static void waitFor(BooleanSupplier check, int checkEveryMillis,
int waitForMillis) throws TimeoutException, InterruptedException {
Preconditions.checkNotNull(check, ERROR_MISSING_ARGUMENT);
Preconditions.checkArgument(waitForMillis >= checkEveryMillis,
ERROR_INVALID_ARGUMENT);
long st = monotonicNow();
- boolean result = check.get();
+ boolean result = check.getAsBoolean();
while (!result && (monotonicNow() - st < waitForMillis)) {
Thread.sleep(checkEveryMillis);
- result = check.get();
+ result = check.getAsBoolean();
}
if (!result) {
diff --git
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
index 2b171b2d5f..19c0d69bb9 100644
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
+++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
@@ -31,8 +31,6 @@ import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import picocli.CommandLine;
-import java.util.function.Supplier;
-
/**
* Ozone Admin Command line tool.
*/
@@ -90,6 +88,6 @@ public class OzoneAdmin extends GenericCli {
public int execute(String[] argv) {
TracingUtil.initTracing("shell", createOzoneConfiguration());
return TracingUtil.executeInNewSpan("main",
- (Supplier<Integer>) () -> super.execute(argv));
+ () -> super.execute(argv));
}
}
diff --git
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
index 757431bc6b..ff8e7a80d5 100644
---
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
+++
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java
@@ -22,8 +22,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.hadoop.fs.FileEncryptionInfo;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationType;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import org.apache.hadoop.ozone.client.io.OzoneInputStream;
+import org.apache.ratis.util.function.CheckedSupplier;
import java.io.IOException;
import java.util.List;
@@ -37,11 +37,11 @@ public class OzoneKeyDetails extends OzoneKey {
/**
* A list of block location information to specify replica locations.
*/
- private List<OzoneKeyLocation> ozoneKeyLocations;
+ private final List<OzoneKeyLocation> ozoneKeyLocations;
- private FileEncryptionInfo feInfo;
+ private final FileEncryptionInfo feInfo;
- private SupplierWithIOException<OzoneInputStream> contentSupplier;
+ private final CheckedSupplier<OzoneInputStream, IOException> contentSupplier;
/**
* Constructs OzoneKeyDetails from OmKeyInfo.
@@ -57,6 +57,7 @@ public class OzoneKeyDetails extends OzoneKey {
modificationTime, type, replicationFactor);
this.ozoneKeyLocations = ozoneKeyLocations;
this.feInfo = feInfo;
+ contentSupplier = null;
this.setMetadata(metadata);
}
@@ -71,7 +72,7 @@ public class OzoneKeyDetails extends OzoneKey {
ReplicationConfig replicationConfig,
Map<String, String> metadata,
FileEncryptionInfo feInfo,
- SupplierWithIOException<OzoneInputStream> contentSupplier) {
+ CheckedSupplier<OzoneInputStream, IOException> contentSupplier) {
super(volumeName, bucketName, keyName, size, creationTime,
modificationTime, replicationConfig, metadata);
this.ozoneKeyLocations = ozoneKeyLocations;
@@ -89,18 +90,9 @@ public class OzoneKeyDetails extends OzoneKey {
public FileEncryptionInfo getFileEncryptionInfo() {
return feInfo;
}
- /**
- * Set details of key location.
- * @param ozoneKeyLocations - details of key location
- */
- public void setOzoneKeyLocations(List<OzoneKeyLocation> ozoneKeyLocations) {
- this.ozoneKeyLocations = ozoneKeyLocations;
- }
/**
* Get OzoneInputStream to read the content of the key.
- * @return OzoneInputStream
- * @throws IOException
*/
@JsonIgnore
public OzoneInputStream getContent() throws IOException {
diff --git
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
index c6a5ea754d..ccb53c255a 100644
---
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
+++
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
@@ -59,7 +59,6 @@ import
org.apache.hadoop.hdds.client.ReplicationConfigValidator;
import org.apache.hadoop.hdds.client.ReplicationFactor;
import org.apache.hadoop.hdds.client.ReplicationType;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.StorageType;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
@@ -1553,15 +1552,12 @@ public class RpcClient implements ClientProtocol {
lastKeyOffset += info.getLength();
}
- SupplierWithIOException<OzoneInputStream> getInputStream =
- () -> getInputStreamWithRetryFunction(keyInfo);
-
return new OzoneKeyDetails(keyInfo.getVolumeName(),
keyInfo.getBucketName(),
keyInfo.getKeyName(), keyInfo.getDataSize(), keyInfo.getCreationTime(),
keyInfo.getModificationTime(), ozoneKeyLocations,
keyInfo.getReplicationConfig(), keyInfo.getMetadata(),
keyInfo.getFileEncryptionInfo(),
- getInputStream);
+ () -> getInputStreamWithRetryFunction(keyInfo));
}
@Override
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/BooleanBiFunction.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/BooleanBiFunction.java
deleted file mode 100644
index 82398b74be..0000000000
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/util/BooleanBiFunction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.ozone.util;
-
-/**
- * Defines a functional interface having two inputs and returns boolean as
- * output.
- */
-@FunctionalInterface
-public interface BooleanBiFunction<LEFT, RIGHT> {
- boolean apply(LEFT left, RIGHT right);
-}
-
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
index 7d2d22e34b..80fdd5ddb6 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
@@ -19,7 +19,6 @@
package org.apache.hadoop.ozone;
import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.hadoop.hdds.ExitManager;
@@ -175,12 +174,9 @@ public class MiniOzoneHAClusterImpl extends
MiniOzoneClusterImpl {
throws TimeoutException, InterruptedException {
if (waitForLeaderElection) {
final OzoneManager[] om = new OzoneManager[1];
- GenericTestUtils.waitFor(new Supplier<Boolean>() {
- @Override
- public Boolean get() {
- om[0] = getOMLeader();
- return om[0] != null;
- }
+ GenericTestUtils.waitFor(() -> {
+ om[0] = getOMLeader();
+ return om[0] != null;
}, 200, waitForClusterToBeReadyTimeout);
return om[0];
} else {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/DatanodeTestUtils.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/DatanodeTestUtils.java
index 372a71ab75..7ea1b2e82a 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/DatanodeTestUtils.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/DatanodeTestUtils.java
@@ -19,7 +19,6 @@
*/
package org.apache.hadoop.ozone.dn;
-import com.google.common.base.Supplier;
import org.apache.hadoop.ozone.container.common.volume.HddsVolume;
import org.apache.hadoop.ozone.container.common.volume.StorageVolume;
import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet;
@@ -230,12 +229,9 @@ public final class DatanodeTestUtils {
*/
public static void waitForCheckVolume(MutableVolumeSet volSet,
long numOfChecks) throws Exception {
- GenericTestUtils.waitFor(new Supplier<Boolean>() {
- @Override
- public Boolean get() {
- return numOfChecks == volSet.getVolumeChecker().getNumVolumeChecks();
- }
- }, 100, 10000);
+ GenericTestUtils.waitFor(
+ () -> numOfChecks == volSet.getVolumeChecker().getNumVolumeChecks(),
+ 100, 10000);
}
/**
@@ -246,12 +242,9 @@ public final class DatanodeTestUtils {
*/
public static void waitForHandleFailedVolume(
MutableVolumeSet volSet, int numOfFailedVolumes) throws Exception {
- GenericTestUtils.waitFor(new Supplier<Boolean>() {
- @Override
- public Boolean get() {
- return numOfFailedVolumes == volSet.getFailedVolumesList().size();
- }
- }, 100, 10000);
+ GenericTestUtils.waitFor(
+ () -> numOfFailedVolumes == volSet.getFailedVolumesList().size(),
+ 100, 10000);
}
public static File getHddsVolumeClusterDir(HddsVolume vol) {
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java
index e2ecf4081b..ab4e99470e 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java
@@ -40,7 +40,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
-import org.apache.hadoop.hdds.function.SupplierWithIOException;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.hdds.utils.TransactionInfo;
import org.apache.hadoop.hdds.utils.db.BatchOperation;
@@ -55,6 +54,7 @@ import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRespo
import org.apache.hadoop.util.Daemon;
import org.apache.hadoop.util.Time;
import org.apache.ratis.util.ExitUtils;
+import org.apache.ratis.util.function.CheckedRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -94,12 +94,12 @@ public final class OzoneManagerDoubleBuffer {
// daemon thread, we complete the futures in readyFutureQueue and clear them.
private volatile Queue<CompletableFuture<Void>> readyFutureQueue;
- private Daemon daemon;
+ private final Daemon daemon;
private final OMMetadataManager omMetadataManager;
private final AtomicLong flushedTransactionCount = new AtomicLong(0);
private final AtomicLong flushIterations = new AtomicLong(0);
private final AtomicBoolean isRunning = new AtomicBoolean(false);
- private OzoneManagerDoubleBufferMetrics ozoneManagerDoubleBufferMetrics;
+ private final OzoneManagerDoubleBufferMetrics
ozoneManagerDoubleBufferMetrics;
private long maxFlushedTransactionsInOneIteration;
private final OzoneManagerRatisSnapshot ozoneManagerRatisSnapShot;
@@ -112,7 +112,7 @@ public final class OzoneManagerDoubleBuffer {
/**
* function which will get term associated with the transaction index.
*/
- private Function<Long, Long> indexToTerm;
+ private final Function<Long, Long> indexToTerm;
/**
* Builder for creating OzoneManagerDoubleBuffer.
@@ -231,40 +231,42 @@ public final class OzoneManagerDoubleBuffer {
/**
* Add to write batch with trace span if tracing is enabled.
*/
- private Void addToBatchWithTrace(OMResponse omResponse,
- SupplierWithIOException<Void> supplier) throws IOException {
+ private void addToBatchWithTrace(OMResponse omResponse,
+ CheckedRunnable<IOException> runnable) throws IOException {
if (!isTracingEnabled) {
- return supplier.get();
+ runnable.run();
+ return;
}
String spanName = "DB-addToWriteBatch" + "-" +
- omResponse.getCmdType().toString();
- return TracingUtil.executeAsChildSpan(spanName, omResponse.getTraceID(),
- supplier);
+ omResponse.getCmdType();
+ TracingUtil.executeAsChildSpan(spanName, omResponse.getTraceID(),
runnable);
}
/**
* Flush write batch with trace span if tracing is enabled.
*/
- private Void flushBatchWithTrace(String parentName, int batchSize,
- SupplierWithIOException<Void> supplier) throws IOException {
+ private void flushBatchWithTrace(String parentName, int batchSize,
+ CheckedRunnable<IOException> runnable) throws IOException {
if (!isTracingEnabled) {
- return supplier.get();
+ runnable.run();
+ return;
}
String spanName = "DB-commitWriteBatch-Size-" + batchSize;
- return TracingUtil.executeAsChildSpan(spanName, parentName, supplier);
+ TracingUtil.executeAsChildSpan(spanName, parentName, runnable);
}
/**
* Add to writeBatch {@link TransactionInfo}.
*/
- private Void addToBatchTransactionInfoWithTrace(String parentName,
- long transactionIndex, SupplierWithIOException<Void> supplier)
+ private void addToBatchTransactionInfoWithTrace(String parentName,
+ long transactionIndex, CheckedRunnable<IOException> runnable)
throws IOException {
if (!isTracingEnabled) {
- return supplier.get();
+ runnable.run();
+ return;
}
String spanName = "DB-addWriteBatch-transactioninfo-" + transactionIndex;
- return TracingUtil.executeAsChildSpan(spanName, parentName, supplier);
+ TracingUtil.executeAsChildSpan(spanName, parentName, runnable);
}
/**
@@ -349,23 +351,17 @@ public final class OzoneManagerDoubleBuffer {
addToBatchTransactionInfoWithTrace(lastTraceId,
lastRatisTransactionIndex,
- () -> {
- omMetadataManager.getTransactionInfoTable().putWithBatch(
- batchOperation, TRANSACTION_INFO_KEY,
- new TransactionInfo.Builder()
- .setTransactionIndex(lastRatisTransactionIndex)
- .setCurrentTerm(term)
- .build());
- return null;
- });
+ () -> omMetadataManager.getTransactionInfoTable().putWithBatch(
+ batchOperation, TRANSACTION_INFO_KEY,
+ new TransactionInfo.Builder()
+ .setTransactionIndex(lastRatisTransactionIndex)
+ .setCurrentTerm(term)
+ .build()));
long startTime = Time.monotonicNow();
flushBatchWithTrace(lastTraceId, buffer.size(),
- () -> {
- omMetadataManager.getStore()
- .commitBatchOperation(batchOperation);
- return null;
- });
+ () -> omMetadataManager.getStore()
+ .commitBatchOperation(batchOperation));
ozoneManagerDoubleBufferMetrics.updateFlushTime(
Time.monotonicNow() - startTime);
@@ -410,10 +406,7 @@ public final class OzoneManagerDoubleBuffer {
try {
addToBatchWithTrace(omResponse,
- () -> {
- response.checkAndUpdateDB(omMetadataManager, batchOperation);
- return null;
- });
+ () -> response.checkAndUpdateDB(omMetadataManager,
batchOperation));
} catch (IOException ex) {
// During Adding to RocksDB batch entry got an exception.
// We should terminate the OM.
@@ -523,7 +516,6 @@ public final class OzoneManagerDoubleBuffer {
}
/**
* Update OzoneManagerDoubleBuffer metrics values.
- * @param flushedTransactionsSize
*/
private void updateMetrics(int flushedTransactionsSize) {
ozoneManagerDoubleBufferMetrics.incrTotalNumOfFlushOperations();
@@ -601,8 +593,6 @@ public final class OzoneManagerDoubleBuffer {
/**
* Add OmResponseBufferEntry to buffer.
- * @param response
- * @param transactionIndex
*/
public synchronized CompletableFuture<Void> add(OMClientResponse response,
long transactionIndex) {
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAclRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAclRequest.java
index 5baee40801..04648e18f7 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAclRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAclRequest.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.ozone.om.request.bucket.acl;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.function.BiPredicate;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.ozone.OzoneAcl;
@@ -35,7 +36,6 @@ import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
import org.apache.hadoop.ozone.om.request.OMClientRequest;
import org.apache.hadoop.ozone.om.response.bucket.acl.OMBucketAclResponse;
-import org.apache.hadoop.ozone.util.BooleanBiFunction;
import org.apache.hadoop.ozone.om.request.util.ObjectParser;
import org.apache.hadoop.ozone.om.response.OMClientResponse;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneObj.ObjectType;
@@ -45,8 +45,6 @@ import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import static
org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK;
@@ -55,13 +53,10 @@ import static
org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_L
*/
public abstract class OMBucketAclRequest extends OMClientRequest {
- private static final Logger LOG =
- LoggerFactory.getLogger(OMBucketAclRequest.class);
-
- private BooleanBiFunction<List<OzoneAcl>, OmBucketInfo> omBucketAclOp;
+ private final BiPredicate<List<OzoneAcl>, OmBucketInfo> omBucketAclOp;
public OMBucketAclRequest(OMRequest omRequest,
- BooleanBiFunction<List<OzoneAcl>, OmBucketInfo> aclOp) {
+ BiPredicate<List<OzoneAcl>, OmBucketInfo> aclOp) {
super(omRequest);
omBucketAclOp = aclOp;
}
@@ -76,7 +71,7 @@ public abstract class OMBucketAclRequest extends
OMClientRequest {
OMMetrics omMetrics = ozoneManager.getMetrics();
omMetrics.incNumBucketUpdates();
- OmBucketInfo omBucketInfo = null;
+ OmBucketInfo omBucketInfo;
OMResponse.Builder omResponse = onInit();
OMClientResponse omClientResponse = null;
@@ -111,7 +106,7 @@ public abstract class OMBucketAclRequest extends
OMClientRequest {
throw new OMException(OMException.ResultCodes.BUCKET_NOT_FOUND);
}
- operationResult = omBucketAclOp.apply(ozoneAcls, omBucketInfo);
+ operationResult = omBucketAclOp.test(ozoneAcls, omBucketInfo);
omBucketInfo.setUpdateID(transactionLogIndex,
ozoneManager.isRatisEnabled());
@@ -192,10 +187,6 @@ public abstract class OMBucketAclRequest extends
OMClientRequest {
/**
* Get the om client response on success case with lock.
- * @param omResponse
- * @param omBucketInfo
- * @param operationResult
- * @return OMClientResponse
*/
abstract OMClientResponse onSuccess(
OMResponse.Builder omResponse, OmBucketInfo omBucketInfo,
@@ -203,9 +194,6 @@ public abstract class OMBucketAclRequest extends
OMClientRequest {
/**
* Get the om client response on failure case with lock.
- * @param omResponse
- * @param exception
- * @return OMClientResponse
*/
OMClientResponse onFailure(OMResponse.Builder omResponse,
IOException exception) {
@@ -216,11 +204,6 @@ public abstract class OMBucketAclRequest extends
OMClientRequest {
/**
* Completion hook for final processing before return without lock.
* Usually used for logging without lock and metric update.
- * @param operationResult
- * @param exception
- * @param omMetrics
- * @param auditLogger
- * @param auditMap
*/
abstract void onComplete(boolean operationResult, IOException exception,
OMMetrics omMetrics, AuditLogger auditLogger,
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAddAclRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAddAclRequest.java
index e6e4bc528e..9b7861f690 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAddAclRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketAddAclRequest.java
@@ -31,7 +31,6 @@ import
org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
import org.apache.hadoop.ozone.om.request.util.OmResponseUtil;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.security.acl.OzoneObjInfo;
-import org.apache.hadoop.ozone.util.BooleanBiFunction;
import org.apache.hadoop.util.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,16 +55,9 @@ public class OMBucketAddAclRequest extends
OMBucketAclRequest {
private static final Logger LOG =
LoggerFactory.getLogger(OMBucketAddAclRequest.class);
- private static BooleanBiFunction<List<OzoneAcl>, OmBucketInfo>
bucketAddAclOp;
- private String path;
- private List<OzoneAcl> ozoneAcls;
- private OzoneObj obj;
-
- static {
- bucketAddAclOp = (ozoneAcls, omBucketInfo) -> {
- return omBucketInfo.addAcl(ozoneAcls.get(0));
- };
- }
+ private final String path;
+ private final List<OzoneAcl> ozoneAcls;
+ private final OzoneObj obj;
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
@@ -81,7 +73,7 @@ public class OMBucketAddAclRequest extends OMBucketAclRequest
{
}
public OMBucketAddAclRequest(OMRequest omRequest) {
- super(omRequest, bucketAddAclOp);
+ super(omRequest, (acls, omBucketInfo) -> omBucketInfo.addAcl(acls.get(0)));
OzoneManagerProtocolProtos.AddAclRequest addAclRequest =
getOmRequest().getAddAclRequest();
obj = OzoneObjInfo.fromProtobuf(addAclRequest.getObj());
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketRemoveAclRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketRemoveAclRequest.java
index 52e65ab1da..814fd0403b 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketRemoveAclRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketRemoveAclRequest.java
@@ -37,7 +37,6 @@ import com.google.common.collect.Lists;
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.om.OMMetrics;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
-import org.apache.hadoop.ozone.util.BooleanBiFunction;
import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.om.response.bucket.acl.OMBucketAclResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
@@ -53,16 +52,9 @@ public class OMBucketRemoveAclRequest extends
OMBucketAclRequest {
private static final Logger LOG =
LoggerFactory.getLogger(OMBucketRemoveAclRequest.class);
- private static BooleanBiFunction<List<OzoneAcl>, OmBucketInfo>
bucketAddAclOp;
- private String path;
- private List<OzoneAcl> ozoneAcls;
- private OzoneObj obj;
-
- static {
- bucketAddAclOp = (ozoneAcls, omBucketInfo) -> {
- return omBucketInfo.removeAcl(ozoneAcls.get(0));
- };
- }
+ private final String path;
+ private final List<OzoneAcl> ozoneAcls;
+ private final OzoneObj obj;
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
@@ -78,7 +70,8 @@ public class OMBucketRemoveAclRequest extends
OMBucketAclRequest {
}
public OMBucketRemoveAclRequest(OMRequest omRequest) {
- super(omRequest, bucketAddAclOp);
+ super(omRequest,
+ (acls, omBucketInfo) -> omBucketInfo.removeAcl(acls.get(0)));
OzoneManagerProtocolProtos.RemoveAclRequest removeAclRequest =
getOmRequest().getRemoveAclRequest();
obj = OzoneObjInfo.fromProtobuf(removeAclRequest.getObj());
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketSetAclRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketSetAclRequest.java
index 5d01c4ff6a..6132b09f2b 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketSetAclRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/acl/OMBucketSetAclRequest.java
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.om.OMMetrics;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
-import org.apache.hadoop.ozone.util.BooleanBiFunction;
import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.om.response.bucket.acl.OMBucketAclResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
@@ -52,17 +51,9 @@ public class OMBucketSetAclRequest extends
OMBucketAclRequest {
private static final Logger LOG =
LoggerFactory.getLogger(OMBucketSetAclRequest.class);
- private static BooleanBiFunction< List<OzoneAcl>,
- OmBucketInfo > bucketAddAclOp;
- private String path;
- private List<OzoneAcl> ozoneAcls;
- private OzoneObj obj;
-
- static {
- bucketAddAclOp = (ozoneAcls, omBucketInfo) -> {
- return omBucketInfo.setAcls(ozoneAcls);
- };
- }
+ private final String path;
+ private final List<OzoneAcl> ozoneAcls;
+ private final OzoneObj obj;
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
@@ -78,7 +69,7 @@ public class OMBucketSetAclRequest extends OMBucketAclRequest
{
}
public OMBucketSetAclRequest(OMRequest omRequest) {
- super(omRequest, bucketAddAclOp);
+ super(omRequest, (acls, omBucketInfo) -> omBucketInfo.setAcls(acls));
OzoneManagerProtocolProtos.SetAclRequest setAclRequest =
getOmRequest().getSetAclRequest();
obj = OzoneObjInfo.fromProtobuf(setAclRequest.getObj());
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFsShell.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFsShell.java
index 3e494c1c37..fe6c61ccc6 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFsShell.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFsShell.java
@@ -27,8 +27,6 @@ import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.util.ToolRunner;
-import java.util.concurrent.Callable;
-
/** Provide command line access to a Ozone FileSystem. */
@InterfaceAudience.Private
public class OzoneFsShell extends FsShell {
@@ -84,7 +82,7 @@ public class OzoneFsShell extends FsShell {
conf.setQuietMode(false);
shell.setConf(conf);
int res = TracingUtil.executeInNewSpan("main",
- (Callable<Integer>) () -> shell.execute(argv));
+ () -> shell.execute(argv));
System.exit(res);
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
index 353960339d..cc134913f3 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
@@ -17,8 +17,6 @@
*/
package org.apache.hadoop.ozone.shell;
-import java.util.function.Supplier;
-
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.tracing.TracingUtil;
@@ -41,7 +39,6 @@ public class OzoneShell extends Shell {
* Main for the ozShell Command handling.
*
* @param argv - System Args Strings[]
- * @throws Exception
*/
public static void main(String[] argv) throws Exception {
new OzoneShell().run(argv);
@@ -51,7 +48,7 @@ public class OzoneShell extends Shell {
public int execute(String[] argv) {
TracingUtil.initTracing("shell", createOzoneConfiguration());
return TracingUtil.executeInNewSpan("main",
- (Supplier<Integer>) () -> super.execute(argv));
+ () -> super.execute(argv));
}
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
index 359f92d774..685830f079 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
@@ -17,8 +17,6 @@
*/
package org.apache.hadoop.ozone.shell.s3;
-import java.util.function.Supplier;
-
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.ozone.shell.Shell;
@@ -40,7 +38,7 @@ public class S3Shell extends Shell {
public int execute(String[] argv) {
TracingUtil.initTracing("s3shell", createOzoneConfiguration());
return TracingUtil.executeInNewSpan("s3shell",
- (Supplier<Integer>) () -> super.execute(argv));
+ () -> super.execute(argv));
}
/**
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
index d06a330dd2..36f8066bf3 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
@@ -21,8 +21,6 @@ import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.ozone.shell.Shell;
import picocli.CommandLine.Command;
-import java.util.function.Supplier;
-
/**
* Shell for multi-tenant related operations.
*/
@@ -41,7 +39,7 @@ public class TenantShell extends Shell {
public int execute(String[] argv) {
TracingUtil.initTracing("tenant-shell", createOzoneConfiguration());
return TracingUtil.executeInNewSpan("tenant-shell",
- (Supplier<Integer>) () -> super.execute(argv));
+ () -> super.execute(argv));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]