HADOOP-15223. Replace Collections.EMPTY* with empty* when available

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
(cherry picked from commit 4d4dde5112e9ee6b37cbdea17104c5a4c6870bd5)
This commit is contained in:
fang zhenyi 2018-02-18 22:19:23 +09:00 committed by Akira Ajisaka
parent 7ee3713f73
commit 55669df4f9
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
23 changed files with 34 additions and 43 deletions

View File

@ -199,9 +199,8 @@ public String getCipher() {
return cipher; return cipher;
} }
@SuppressWarnings("unchecked")
public Map<String, String> getAttributes() { public Map<String, String> getAttributes() {
return (attributes == null) ? Collections.EMPTY_MAP : attributes; return (attributes == null) ? Collections.emptyMap() : attributes;
} }
/** /**
@ -370,9 +369,8 @@ public String getDescription() {
return description; return description;
} }
@SuppressWarnings("unchecked")
public Map<String, String> getAttributes() { public Map<String, String> getAttributes() {
return (attributes == null) ? Collections.EMPTY_MAP : attributes; return (attributes == null) ? Collections.emptyMap() : attributes;
} }
@Override @Override

View File

@ -54,7 +54,7 @@ public void testInterfaceSuperset() {
assertEquals(fsM.stream() assertEquals(fsM.stream()
.map(MethodSignature::toString) .map(MethodSignature::toString)
.collect(joining("\n")), .collect(joining("\n")),
Collections.EMPTY_SET, fsM); Collections.emptySet(), fsM);
} }
/** Map non-static, declared methods for this class to signatures. */ /** Map non-static, declared methods for this class to signatures. */

View File

@ -28,7 +28,6 @@
public class DummyGroupMapping implements GroupMappingServiceProvider { public class DummyGroupMapping implements GroupMappingServiceProvider {
@Override @Override
@SuppressWarnings("unchecked")
public List<String> getGroups(String user) throws IOException { public List<String> getGroups(String user) throws IOException {
if (user.equals("root")) { if (user.equals("root")) {
return Arrays.asList("admin"); return Arrays.asList("admin");
@ -37,7 +36,7 @@ else if (user.equals("nobody")) {
return Arrays.asList("nobody"); return Arrays.asList("nobody");
} else { } else {
String[] groups = HadoopUsersConfTestHelper.getHadoopUserGroups(user); String[] groups = HadoopUsersConfTestHelper.getHadoopUserGroups(user);
return (groups != null) ? Arrays.asList(groups) : Collections.EMPTY_LIST; return (groups != null) ? Arrays.asList(groups) : Collections.emptyList();
} }
} }

View File

@ -723,7 +723,7 @@ static class TombstoneReconcilingIterator implements
if (tombstones != null) { if (tombstones != null) {
this.tombstones = tombstones; this.tombstones = tombstones;
} else { } else {
this.tombstones = Collections.EMPTY_SET; this.tombstones = Collections.emptySet();
} }
} }

View File

@ -2099,7 +2099,7 @@ S3AFileStatus innerGetFileStatus(final Path f,
// Check MetadataStore, if any. // Check MetadataStore, if any.
PathMetadata pm = metadataStore.get(path, needEmptyDirectoryFlag); PathMetadata pm = metadataStore.get(path, needEmptyDirectoryFlag);
Set<Path> tombstones = Collections.EMPTY_SET; Set<Path> tombstones = Collections.emptySet();
if (pm != null) { if (pm != null) {
if (pm.isDeleted()) { if (pm.isDeleted()) {
throw new FileNotFoundException("Path " + f + " is recorded as " + throw new FileNotFoundException("Path " + f + " is recorded as " +

View File

@ -415,7 +415,7 @@ private static class NullInputFormat extends InputFormat {
@Override @Override
public List getSplits(JobContext context) public List getSplits(JobContext context)
throws IOException, InterruptedException { throws IOException, InterruptedException {
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
@Override @Override

View File

@ -144,9 +144,8 @@ public void resetLastNodeHeartBeatResponse() {
} }
@Override @Override
@SuppressWarnings("unchecked")
public List<UpdatedContainerInfo> pullContainerUpdates() { public List<UpdatedContainerInfo> pullContainerUpdates() {
List<UpdatedContainerInfo> list = Collections.EMPTY_LIST; List<UpdatedContainerInfo> list = Collections.emptyList();
if (! pulled) { if (! pulled) {
list = updates; list = updates;
pulled = true; pulled = true;
@ -168,11 +167,10 @@ public Set<String> getNodeLabels() {
return RMNodeLabelsManager.EMPTY_STRING_SET; return RMNodeLabelsManager.EMPTY_STRING_SET;
} }
@SuppressWarnings("unchecked")
@Override @Override
public List<Container> pullNewlyIncreasedContainers() { public List<Container> pullNewlyIncreasedContainers() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
public OpportunisticContainersStatus getOpportunisticContainersStatus() { public OpportunisticContainersStatus getOpportunisticContainersStatus() {

View File

@ -223,7 +223,7 @@ public abstract void setUpdateRequests(
@Public @Public
@Unstable @Unstable
public List<SchedulingRequest> getSchedulingRequests() { public List<SchedulingRequest> getSchedulingRequests() {
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
/** /**

View File

@ -420,7 +420,7 @@ public abstract void setContainersFromPreviousAttempts(
@Public @Public
@Unstable @Unstable
public List<RejectedSchedulingRequest> getRejectedSchedulingRequests() { public List<RejectedSchedulingRequest> getRejectedSchedulingRequests() {
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
/** /**

View File

@ -263,7 +263,7 @@ public void setVersion(int version) {
@Private @Private
@Unstable @Unstable
public Set<String> getAllocationTags() { public Set<String> getAllocationTags() {
return Collections.EMPTY_SET; return Collections.emptySet();
} }
@Private @Private

View File

@ -368,7 +368,7 @@ public Set<String> getAllcationTags() {
if (proto.getAllocationTagsList() != null) { if (proto.getAllocationTagsList() != null) {
return new HashSet<>(proto.getAllocationTagsList()); return new HashSet<>(proto.getAllocationTagsList());
} }
return Collections.EMPTY_SET; return Collections.emptySet();
} }
// TODO: Needed? // TODO: Needed?

View File

@ -169,7 +169,7 @@ public void setExecutionType(ExecutionType executionType) { }
* Get and set the Allocation tags associated with the container. * Get and set the Allocation tags associated with the container.
*/ */
public Set<String> getAllocationTags() { public Set<String> getAllocationTags() {
return Collections.EMPTY_SET; return Collections.emptySet();
} }
public void setAllocationTags(Set<String> allocationTags) { public void setAllocationTags(Set<String> allocationTags) {

View File

@ -46,7 +46,8 @@ public class ResourcePluginManager {
private static final Set<String> SUPPORTED_RESOURCE_PLUGINS = ImmutableSet.of( private static final Set<String> SUPPORTED_RESOURCE_PLUGINS = ImmutableSet.of(
GPU_URI, FPGA_URI); GPU_URI, FPGA_URI);
private Map<String, ResourcePlugin> configuredPlugins = Collections.EMPTY_MAP; private Map<String, ResourcePlugin> configuredPlugins =
Collections.emptyMap();
public synchronized void initialize(Context context) public synchronized void initialize(Context context)
throws YarnException { throws YarnException {

View File

@ -207,10 +207,10 @@ public void allocate(ApplicationAttemptId appAttemptId,
request.getResourceBlacklistRequest(); request.getResourceBlacklistRequest();
List<String> blacklistAdditions = List<String> blacklistAdditions =
(blacklistRequest != null) ? (blacklistRequest != null) ?
blacklistRequest.getBlacklistAdditions() : Collections.EMPTY_LIST; blacklistRequest.getBlacklistAdditions() : Collections.emptyList();
List<String> blacklistRemovals = List<String> blacklistRemovals =
(blacklistRequest != null) ? (blacklistRequest != null) ?
blacklistRequest.getBlacklistRemovals() : Collections.EMPTY_LIST; blacklistRequest.getBlacklistRemovals() : Collections.emptyList();
RMApp app = RMApp app =
getRmContext().getRMApps().get(appAttemptId.getApplicationId()); getRmContext().getRMApps().get(appAttemptId.getApplicationId());

View File

@ -136,23 +136,21 @@ public enum IntraQueuePreemptionOrderPolicy {
private Map<String, PreemptableQueue> preemptableQueues; private Map<String, PreemptableQueue> preemptableQueues;
private Set<ContainerId> killableContainers; private Set<ContainerId> killableContainers;
@SuppressWarnings("unchecked")
public ProportionalCapacityPreemptionPolicy() { public ProportionalCapacityPreemptionPolicy() {
clock = SystemClock.getInstance(); clock = SystemClock.getInstance();
allPartitions = Collections.EMPTY_SET; allPartitions = Collections.emptySet();
leafQueueNames = Collections.EMPTY_SET; leafQueueNames = Collections.emptySet();
preemptableQueues = Collections.EMPTY_MAP; preemptableQueues = Collections.emptyMap();
} }
@SuppressWarnings("unchecked")
@VisibleForTesting @VisibleForTesting
public ProportionalCapacityPreemptionPolicy(RMContext context, public ProportionalCapacityPreemptionPolicy(RMContext context,
CapacityScheduler scheduler, Clock clock) { CapacityScheduler scheduler, Clock clock) {
init(context.getYarnConfiguration(), context, scheduler); init(context.getYarnConfiguration(), context, scheduler);
this.clock = clock; this.clock = clock;
allPartitions = Collections.EMPTY_SET; allPartitions = Collections.emptySet();
leafQueueNames = Collections.EMPTY_SET; leafQueueNames = Collections.emptySet();
preemptableQueues = Collections.EMPTY_MAP; preemptableQueues = Collections.emptyMap();
} }
public void init(Configuration config, RMContext context, public void init(Configuration config, RMContext context,

View File

@ -2237,7 +2237,7 @@ public Set<String> getBlacklistedNodes() {
return attempt.getBlacklistedNodes(); return attempt.getBlacklistedNodes();
} }
} }
return Collections.EMPTY_SET; return Collections.emptySet();
} }
protected void onInvalidTranstion(RMAppAttemptEventType rmAppAttemptEventType, protected void onInvalidTranstion(RMAppAttemptEventType rmAppAttemptEventType,

View File

@ -1477,7 +1477,7 @@ public List<Container> pullNewlyIncreasedContainers() {
writeLock.lock(); writeLock.lock();
if (nmReportedIncreasedContainers.isEmpty()) { if (nmReportedIncreasedContainers.isEmpty()) {
return Collections.EMPTY_LIST; return Collections.emptyList();
} else { } else {
List<Container> container = List<Container> container =
new ArrayList<Container>(nmReportedIncreasedContainers.values()); new ArrayList<Container>(nmReportedIncreasedContainers.values());

View File

@ -80,10 +80,9 @@ public void setLogAggregationReportsForApps(
this.logAggregationReportsForApps = logAggregationReportsForApps; this.logAggregationReportsForApps = logAggregationReportsForApps;
} }
@SuppressWarnings("unchecked")
public List<Container> getNMReportedIncreasedContainers() { public List<Container> getNMReportedIncreasedContainers() {
return this.nodeStatus.getIncreasedContainers() == null ? return this.nodeStatus.getIncreasedContainers() == null ?
Collections.EMPTY_LIST : this.nodeStatus.getIncreasedContainers(); Collections.emptyList() : this.nodeStatus.getIncreasedContainers();
} }

View File

@ -131,7 +131,7 @@ public int getPlacementAttempt() {
* @return Set of blacklisted Nodes. * @return Set of blacklisted Nodes.
*/ */
public Set<NodeId> getBlacklist(String tag) { public Set<NodeId> getBlacklist(String tag) {
return blacklist.getOrDefault(tag, Collections.EMPTY_SET); return blacklist.getOrDefault(tag, Collections.emptySet());
} }
/** /**

View File

@ -87,7 +87,7 @@ public List<PlacedSchedulingRequest> pullPlacedRequests(
} }
return retList; return retList;
} }
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
public List<SchedulingRequestWithPlacementAttempt> pullRejectedRequests( public List<SchedulingRequestWithPlacementAttempt> pullRejectedRequests(
@ -104,7 +104,7 @@ public List<SchedulingRequestWithPlacementAttempt> pullRejectedRequests(
} }
return retList; return retList;
} }
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
void clearApplicationState(ApplicationId applicationId) { void clearApplicationState(ApplicationId applicationId) {

View File

@ -373,9 +373,8 @@ private void validateAndSetSchedulingRequest(SchedulingRequest newSchedulingRequ
} }
@Override @Override
@SuppressWarnings("unchecked")
public Map<String, ResourceRequest> getResourceRequests() { public Map<String, ResourceRequest> getResourceRequests() {
return Collections.EMPTY_MAP; return Collections.emptyMap();
} }
@Override @Override

View File

@ -723,13 +723,12 @@ protected RMNodeLabelsManager createNodeLabelManager() {
} }
} }
@SuppressWarnings("unchecked")
private NodeStatus getNodeStatusObject(NodeId nodeId) { private NodeStatus getNodeStatusObject(NodeId nodeId) {
NodeStatus status = Records.newRecord(NodeStatus.class); NodeStatus status = Records.newRecord(NodeStatus.class);
status.setNodeId(nodeId); status.setNodeId(nodeId);
status.setResponseId(0); status.setResponseId(0);
status.setContainersStatuses(Collections.EMPTY_LIST); status.setContainersStatuses(Collections.emptyList());
status.setKeepAliveApplications(Collections.EMPTY_LIST); status.setKeepAliveApplications(Collections.emptyList());
return status; return status;
} }

View File

@ -781,7 +781,7 @@ private Map<String, String> getOtherConfigurations(String queueExpr) {
} }
} }
return Collections.EMPTY_MAP; return Collections.emptyMap();
} }
/** /**