HADOOP-14957. ReconfigurationTaskStatus is exposing guava Optional in its public api. Contributed by Haibo Chen, Xiao Chen.

This commit is contained in:
Xiao Chen 2017-10-25 14:10:33 -07:00
parent 075dd45a24
commit f66ad1fab9
6 changed files with 10 additions and 11 deletions

View File

@ -19,7 +19,6 @@
package org.apache.hadoop.conf; package org.apache.hadoop.conf;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Time;
@ -31,6 +30,7 @@
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Optional;
/** /**
* Utility base class for implementing the Reconfigurable interface. * Utility base class for implementing the Reconfigurable interface.
@ -148,7 +148,7 @@ public void run() {
} catch (ReconfigurationException e) { } catch (ReconfigurationException e) {
errorMessage = e.getCause().getMessage(); errorMessage = e.getCause().getMessage();
} }
results.put(change, Optional.fromNullable(errorMessage)); results.put(change, Optional.ofNullable(errorMessage));
} }
synchronized (parent.reconfigLock) { synchronized (parent.reconfigLock) {

View File

@ -18,15 +18,15 @@
package org.apache.hadoop.conf; package org.apache.hadoop.conf;
import com.google.common.base.Optional;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange;
import java.util.Map; import java.util.Map;
import java.util.Optional;
@InterfaceAudience.Public @InterfaceAudience.LimitedPrivate({"HDFS", "Management Tools"})
@InterfaceStability.Stable @InterfaceStability.Unstable
public class ReconfigurationTaskStatus { public class ReconfigurationTaskStatus {
long startTime; long startTime;
long endTime; long endTime;

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.conf; package org.apache.hadoop.conf;
import com.google.common.base.Optional;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
@ -44,6 +43,7 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;

View File

@ -19,13 +19,13 @@
package org.apache.hadoop.hdfs.protocolPB; package org.apache.hadoop.hdfs.protocolPB;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.apache.hadoop.conf.ReconfigurationTaskStatus; import org.apache.hadoop.conf.ReconfigurationTaskStatus;
import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange;
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusConfigChangeProto; import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusConfigChangeProto;
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusResponseProto; import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusResponseProto;
import com.google.common.base.Optional;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
/** /**
@ -56,7 +56,7 @@ public static ReconfigurationTaskStatus getReconfigurationStatus(
if (change.hasErrorMessage()) { if (change.hasErrorMessage()) {
errorMessage = change.getErrorMessage(); errorMessage = change.getErrorMessage();
} }
statusMap.put(pc, Optional.fromNullable(errorMessage)); statusMap.put(pc, Optional.ofNullable(errorMessage));
} }
} }
return new ReconfigurationTaskStatus(startTime, endTime, statusMap); return new ReconfigurationTaskStatus(startTime, endTime, statusMap);

View File

@ -19,6 +19,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.apache.hadoop.conf.ReconfigurationTaskStatus; import org.apache.hadoop.conf.ReconfigurationTaskStatus;
import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange;
@ -26,8 +27,6 @@
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusResponseProto; import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.ListReconfigurablePropertiesResponseProto; import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.ListReconfigurablePropertiesResponseProto;
import com.google.common.base.Optional;
/** /**
* This is a server side utility class that handles * This is a server side utility class that handles
* common logic to to parameter reconfiguration. * common logic to to parameter reconfiguration.

View File

@ -33,11 +33,11 @@
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;