|
@@ -21,9 +21,8 @@ import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
import com.google.common.collect.Multimap;
|
|
|
import com.google.common.collect.UnmodifiableIterator;
|
|
|
-import com.google.common.collect.Iterables;
|
|
|
-import com.google.common.collect.Collections2;
|
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -40,7 +39,7 @@ import java.util.Collection;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-import com.google.common.base.Predicate;
|
|
|
+
|
|
|
|
|
|
import org.apache.hadoop.hdfs.util.CombinedHostsFileReader;
|
|
|
|
|
@@ -82,37 +81,26 @@ public class CombinedHostFileManager extends HostConfigManager {
|
|
|
// If the includes list is empty, act as if everything is in the
|
|
|
// includes list.
|
|
|
synchronized boolean isIncluded(final InetSocketAddress address) {
|
|
|
- return emptyInServiceNodeLists || Iterables.any(
|
|
|
- allDNs.get(address.getAddress()),
|
|
|
- new Predicate<DatanodeAdminProperties>() {
|
|
|
- public boolean apply(DatanodeAdminProperties input) {
|
|
|
- return input.getPort() == 0 ||
|
|
|
- input.getPort() == address.getPort();
|
|
|
- }
|
|
|
- });
|
|
|
+ return emptyInServiceNodeLists || allDNs.get(address.getAddress())
|
|
|
+ .stream().anyMatch(
|
|
|
+ input -> input.getPort() == 0 ||
|
|
|
+ input.getPort() == address.getPort());
|
|
|
}
|
|
|
|
|
|
synchronized boolean isExcluded(final InetSocketAddress address) {
|
|
|
- return Iterables.any(allDNs.get(address.getAddress()),
|
|
|
- new Predicate<DatanodeAdminProperties>() {
|
|
|
- public boolean apply(DatanodeAdminProperties input) {
|
|
|
- return input.getAdminState().equals(
|
|
|
- AdminStates.DECOMMISSIONED) &&
|
|
|
- (input.getPort() == 0 ||
|
|
|
- input.getPort() == address.getPort());
|
|
|
- }
|
|
|
- });
|
|
|
+ return allDNs.get(address.getAddress()).stream().anyMatch(
|
|
|
+ input -> input.getAdminState().equals(
|
|
|
+ AdminStates.DECOMMISSIONED) &&
|
|
|
+ (input.getPort() == 0 ||
|
|
|
+ input.getPort() == address.getPort()));
|
|
|
}
|
|
|
|
|
|
synchronized String getUpgradeDomain(final InetSocketAddress address) {
|
|
|
- Iterable<DatanodeAdminProperties> datanode = Iterables.filter(
|
|
|
- allDNs.get(address.getAddress()),
|
|
|
- new Predicate<DatanodeAdminProperties>() {
|
|
|
- public boolean apply(DatanodeAdminProperties input) {
|
|
|
- return (input.getPort() == 0 ||
|
|
|
- input.getPort() == address.getPort());
|
|
|
- }
|
|
|
- });
|
|
|
+ Iterable<DatanodeAdminProperties> datanode =
|
|
|
+ allDNs.get(address.getAddress()).stream().filter(
|
|
|
+ input -> (input.getPort() == 0 ||
|
|
|
+ input.getPort() == address.getPort())).collect(
|
|
|
+ Collectors.toList());
|
|
|
return datanode.iterator().hasNext() ?
|
|
|
datanode.iterator().next().getUpgradeDomain() : null;
|
|
|
}
|
|
@@ -127,36 +115,22 @@ public class CombinedHostFileManager extends HostConfigManager {
|
|
|
}
|
|
|
|
|
|
Iterable<InetSocketAddress> getExcludes() {
|
|
|
- return new Iterable<InetSocketAddress>() {
|
|
|
- @Override
|
|
|
- public Iterator<InetSocketAddress> iterator() {
|
|
|
- return new HostIterator(
|
|
|
- Collections2.filter(allDNs.entries(),
|
|
|
- new Predicate<java.util.Map.Entry<InetAddress,
|
|
|
- DatanodeAdminProperties>>() {
|
|
|
- public boolean apply(java.util.Map.Entry<InetAddress,
|
|
|
- DatanodeAdminProperties> entry) {
|
|
|
- return entry.getValue().getAdminState().equals(
|
|
|
- AdminStates.DECOMMISSIONED);
|
|
|
- }
|
|
|
- }
|
|
|
- ));
|
|
|
- }
|
|
|
- };
|
|
|
+ return () -> new HostIterator(
|
|
|
+ allDNs.entries().stream().filter(
|
|
|
+ entry -> entry.getValue().getAdminState().equals(
|
|
|
+ AdminStates.DECOMMISSIONED)).collect(
|
|
|
+ Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
synchronized long getMaintenanceExpireTimeInMS(
|
|
|
final InetSocketAddress address) {
|
|
|
- Iterable<DatanodeAdminProperties> datanode = Iterables.filter(
|
|
|
- allDNs.get(address.getAddress()),
|
|
|
- new Predicate<DatanodeAdminProperties>() {
|
|
|
- public boolean apply(DatanodeAdminProperties input) {
|
|
|
- return input.getAdminState().equals(
|
|
|
+ Iterable<DatanodeAdminProperties> datanode =
|
|
|
+ allDNs.get(address.getAddress()).stream().filter(
|
|
|
+ input -> input.getAdminState().equals(
|
|
|
AdminStates.IN_MAINTENANCE) &&
|
|
|
(input.getPort() == 0 ||
|
|
|
- input.getPort() == address.getPort());
|
|
|
- }
|
|
|
- });
|
|
|
+ input.getPort() == address.getPort())).collect(
|
|
|
+ Collectors.toList());
|
|
|
// if DN isn't set to maintenance state, ignore MaintenanceExpireTimeInMS
|
|
|
// set in the config.
|
|
|
return datanode.iterator().hasNext() ?
|