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

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
fang zhenyi 2018-02-18 22:19:23 +09:00 committed by Akira Ajisaka
parent 87bdde6943
commit 4d4dde5112
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;
}
@SuppressWarnings("unchecked")
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;
}
@SuppressWarnings("unchecked")
public Map<String, String> getAttributes() {
return (attributes == null) ? Collections.EMPTY_MAP : attributes;
return (attributes == null) ? Collections.emptyMap() : attributes;
}
@Override

View File

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

View File

@ -28,7 +28,6 @@
public class DummyGroupMapping implements GroupMappingServiceProvider {
@Override
@SuppressWarnings("unchecked")
public List<String> getGroups(String user) throws IOException {
if (user.equals("root")) {
return Arrays.asList("admin");
@ -37,7 +36,7 @@ else if (user.equals("nobody")) {
return Arrays.asList("nobody");
} else {
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) {
this.tombstones = tombstones;
} 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.
PathMetadata pm = metadataStore.get(path, needEmptyDirectoryFlag);
Set<Path> tombstones = Collections.EMPTY_SET;
Set<Path> tombstones = Collections.emptySet();
if (pm != null) {
if (pm.isDeleted()) {
throw new FileNotFoundException("Path " + f + " is recorded as " +

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -80,10 +80,9 @@ public void setLogAggregationReportsForApps(
this.logAggregationReportsForApps = logAggregationReportsForApps;
}
@SuppressWarnings("unchecked")
public List<Container> getNMReportedIncreasedContainers() {
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.
*/
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 Collections.EMPTY_LIST;
return Collections.emptyList();
}
public List<SchedulingRequestWithPlacementAttempt> pullRejectedRequests(
@ -104,7 +104,7 @@ public List<SchedulingRequestWithPlacementAttempt> pullRejectedRequests(
}
return retList;
}
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
void clearApplicationState(ApplicationId applicationId) {

View File

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

View File

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

View File

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