YARN-4630. Remove useless boxing/unboxing code. Contributed by Kousuke Saruta.

This commit is contained in:
Akira Ajisaka 2016-04-11 14:52:27 +09:00
parent 07920acc16
commit 1ff27f9d12
12 changed files with 34 additions and 34 deletions

View File

@ -165,13 +165,12 @@ public boolean equals(Object obj) {
@Override
public int compareTo(ContainerId other) {
if (this.getApplicationAttemptId().compareTo(
other.getApplicationAttemptId()) == 0) {
return Long.valueOf(getContainerId())
.compareTo(Long.valueOf(other.getContainerId()));
} else {
return this.getApplicationAttemptId().compareTo(
int result = this.getApplicationAttemptId().compareTo(
other.getApplicationAttemptId());
if (result == 0) {
return Long.compare(getContainerId(), other.getContainerId());
} else {
return result;
}
}

View File

@ -241,7 +241,7 @@ private static class ApplicationInformation {
@Override
public int
compare(ApplicationInformation a1, ApplicationInformation a2) {
return Long.valueOf(a1.usedMemory).compareTo(a2.usedMemory);
return Long.compare(a1.usedMemory, a2.usedMemory);
}
};
public static final Comparator<ApplicationInformation> ReservedMemoryComparator =
@ -249,7 +249,7 @@ private static class ApplicationInformation {
@Override
public int
compare(ApplicationInformation a1, ApplicationInformation a2) {
return Long.valueOf(a1.reservedMemory).compareTo(a2.reservedMemory);
return Long.compare(a1.reservedMemory, a2.reservedMemory);
}
};
public static final Comparator<ApplicationInformation> UsedVCoresComparator =
@ -273,7 +273,7 @@ private static class ApplicationInformation {
@Override
public int
compare(ApplicationInformation a1, ApplicationInformation a2) {
return Long.valueOf(a1.vcoreSeconds).compareTo(a2.vcoreSeconds);
return Long.compare(a1.vcoreSeconds, a2.vcoreSeconds);
}
};
public static final Comparator<ApplicationInformation> MemorySecondsComparator =
@ -281,7 +281,7 @@ private static class ApplicationInformation {
@Override
public int
compare(ApplicationInformation a1, ApplicationInformation a2) {
return Long.valueOf(a1.memorySeconds).compareTo(a2.memorySeconds);
return Long.compare(a1.memorySeconds, a2.memorySeconds);
}
};
public static final Comparator<ApplicationInformation> ProgressComparator =
@ -297,7 +297,7 @@ private static class ApplicationInformation {
@Override
public int
compare(ApplicationInformation a1, ApplicationInformation a2) {
return Long.valueOf(a1.runningTime).compareTo(a2.runningTime);
return Long.compare(a1.runningTime, a2.runningTime);
}
};
public static final Comparator<ApplicationInformation> AppNameComparator =

View File

@ -54,7 +54,7 @@ public void testRMWebUrlSpecified() throws Exception {
String rmWebUrl = WebAppUtils.getRMWebAppURLWithScheme(conf);
String[] parts = rmWebUrl.split(":");
Assert.assertEquals("RM Web URL Port is incrrect", 24543,
Integer.valueOf(parts[parts.length - 1]).intValue());
Integer.parseInt(parts[parts.length - 1]));
Assert.assertNotSame(
"RM Web Url not resolved correctly. Should not be rmtesting",
"http://rmtesting:24543", rmWebUrl);
@ -178,7 +178,7 @@ public void testUpdateConnectAddr() throws Exception {
conf.set(YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS, "yo.yo.yo");
serverAddress = new InetSocketAddress(
YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[0],
Integer.valueOf(YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[1]));
Integer.parseInt(YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[1]));
resourceTrackerConnectAddress = conf.updateConnectAddr(
YarnConfiguration.RM_BIND_HOST,
@ -194,7 +194,7 @@ public void testUpdateConnectAddr() throws Exception {
conf.set(YarnConfiguration.RM_BIND_HOST, "0.0.0.0");
serverAddress = new InetSocketAddress(
YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[0],
Integer.valueOf(YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[1]));
Integer.parseInt(YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[1]));
resourceTrackerConnectAddress = conf.updateConnectAddr(
YarnConfiguration.RM_BIND_HOST,
@ -213,7 +213,7 @@ public void testUpdateConnectAddr() throws Exception {
serverAddress = new InetSocketAddress(
YarnConfiguration.DEFAULT_NM_LOCALIZER_ADDRESS.split(":")[0],
Integer.valueOf(YarnConfiguration.DEFAULT_NM_LOCALIZER_ADDRESS.split(":")[1]));
Integer.parseInt(YarnConfiguration.DEFAULT_NM_LOCALIZER_ADDRESS.split(":")[1]));
InetSocketAddress localizerAddress = conf.updateConnectAddr(
YarnConfiguration.NM_BIND_HOST,

View File

@ -140,7 +140,7 @@ public NodeId toNodeId(String str) {
int idx = str.indexOf(':');
NodeId id =
NodeId.newInstance(str.substring(0, idx),
Integer.valueOf(str.substring(idx + 1)));
Integer.parseInt(str.substring(idx + 1)));
return id;
} else {
return NodeId.newInstance(str, CommonNodeLabelsManager.WILDCARD_PORT);

View File

@ -431,7 +431,7 @@ public void testDownload() throws IOException, URISyntaxException,
try {
for (Map.Entry<LocalResource,Future<Path>> p : pending.entrySet()) {
Path localized = p.getValue().get();
assertEquals(sizes[Integer.valueOf(localized.getName())], p.getKey()
assertEquals(sizes[Integer.parseInt(localized.getName())], p.getKey()
.getSize());
FileStatus status = files.getFileStatus(localized.getParent());

View File

@ -772,7 +772,7 @@ public static void disableZookeeperClientSASL() {
* @return true if the SASL client system property is set.
*/
public static boolean isClientSASLEnabled() {
return Boolean.valueOf(System.getProperty(
return Boolean.parseBoolean(System.getProperty(
ZookeeperConfigOptions.PROP_ZK_ENABLE_SASL_CLIENT, "true"));
}
@ -862,7 +862,7 @@ public String buildSecurityDiagnostics() {
String sasl =
System.getProperty(PROP_ZK_ENABLE_SASL_CLIENT,
DEFAULT_ZK_ENABLE_SASL_CLIENT);
boolean saslEnabled = Boolean.valueOf(sasl);
boolean saslEnabled = Boolean.parseBoolean(sasl);
builder.append(describeProperty(PROP_ZK_ENABLE_SASL_CLIENT,
DEFAULT_ZK_ENABLE_SASL_CLIENT));
if (saslEnabled) {

View File

@ -1017,7 +1017,7 @@ public void sanitizeEnv(Map<String, String> environment, Path pwd,
//variable can be set to indicate that distcache entries should come
//first
boolean preferLocalizedJars = Boolean.valueOf(
boolean preferLocalizedJars = Boolean.parseBoolean(
environment.get(Environment.CLASSPATH_PREPEND_DISTCACHE.name())
);

View File

@ -79,7 +79,7 @@ public static String getProcessId(Path path) throws IOException {
else {
// Otherwise, find first line containing a numeric pid.
try {
Long pid = Long.valueOf(temp);
long pid = Long.parseLong(temp);
if (pid > 0) {
processId = temp;
break;

View File

@ -89,7 +89,8 @@ public void setSizeBasedWeight(boolean sizeBasedWeight) {
@Override
public void configure(Map<String, String> conf) {
if (conf.containsKey(ENABLE_SIZE_BASED_WEIGHT)) {
sizeBasedWeight = Boolean.valueOf(conf.get(ENABLE_SIZE_BASED_WEIGHT));
sizeBasedWeight =
Boolean.parseBoolean(conf.get(ENABLE_SIZE_BASED_WEIGHT));
}
}

View File

@ -1032,10 +1032,10 @@ Resource[] parseResourceDetails(String[] resData) {
for (int i = 0; i < resData.length; i++) {
String[] resource = resData[i].split(":");
if (resource.length == 1) {
resourceList.add(Resource.newInstance(Integer.valueOf(resource[0]), 0));
resourceList.add(Resource.newInstance(Integer.parseInt(resource[0]), 0));
} else {
resourceList.add(Resource.newInstance(Integer.valueOf(resource[0]),
Integer.valueOf(resource[1])));
resourceList.add(Resource.newInstance(Integer.parseInt(resource[0]),
Integer.parseInt(resource[1])));
}
}
return resourceList.toArray(new Resource[resourceList.size()]);

View File

@ -929,12 +929,12 @@ private void mockContainers(String containersConfig, ApplicationAttemptId attemp
throw new IllegalArgumentException("Format to define container is:"
+ "(priority,resource,host,expression,repeat,reserved)");
}
Priority pri = Priority.newInstance(Integer.valueOf(values[0]));
Priority pri = Priority.newInstance(Integer.parseInt(values[0]));
Resource res = parseResourceFromString(values[1]);
NodeId host = NodeId.newInstance(values[2], 1);
String exp = values[3];
int repeat = Integer.valueOf(values[4]);
boolean reserved = Boolean.valueOf(values[5]);
int repeat = Integer.parseInt(values[4]);
boolean reserved = Boolean.parseBoolean(values[5]);
for (int i = 0; i < repeat; i++) {
Container c = mock(Container.class);
@ -1068,7 +1068,7 @@ private void mockNodeLabelsManager(String nodeLabelsConfigStr) throws IOExceptio
Resource res = parseResourceFromString(p.substring(p.indexOf("=") + 1,
p.indexOf(",")));
boolean exclusivity =
Boolean.valueOf(p.substring(p.indexOf(",") + 1, p.length()));
Boolean.parseBoolean(p.substring(p.indexOf(",") + 1, p.length()));
when(nlm.getResourceByLabel(eq(partitionName), any(Resource.class)))
.thenReturn(res);
when(nlm.isExclusiveNodeLabel(eq(partitionName))).thenReturn(exclusivity);
@ -1088,10 +1088,10 @@ private Resource parseResourceFromString(String p) {
String[] resource = p.split(":");
Resource res = Resources.createResource(0);
if (resource.length == 1) {
res = Resources.createResource(Integer.valueOf(resource[0]));
res = Resources.createResource(Integer.parseInt(resource[0]));
} else {
res = Resources.createResource(Integer.valueOf(resource[0]),
Integer.valueOf(resource[1]));
res = Resources.createResource(Integer.parseInt(resource[0]),
Integer.parseInt(resource[1]));
}
return res;
}

View File

@ -310,7 +310,7 @@ private void methodAction(final HttpServletRequest req,
String userApprovedParamS =
req.getParameter(ProxyUriUtils.PROXY_APPROVAL_PARAM);
boolean userWasWarned = false;
boolean userApproved = Boolean.valueOf(userApprovedParamS);
boolean userApproved = Boolean.parseBoolean(userApprovedParamS);
boolean securityEnabled = isSecurityEnabled();
final String remoteUser = req.getRemoteUser();
final String pathInfo = req.getPathInfo();
@ -342,7 +342,7 @@ private void methodAction(final HttpServletRequest req,
for (Cookie c : cookies) {
if (cookieName.equals(c.getName())) {
userWasWarned = true;
userApproved = userApproved || Boolean.valueOf(c.getValue());
userApproved = userApproved || Boolean.parseBoolean(c.getValue());
break;
}
}