YARN-10491. Fix deprecation warnings in SLSWebApp.java (#2519)

Signed-off-by: Akira Ajisaka <ajisaka@apache.org>
(cherry picked from commit aaf9e3d320)
This commit is contained in:
Ankit Kumar 2020-12-09 07:22:31 +05:30 committed by Akira Ajisaka
parent e02b179c4c
commit f04a9dfda1
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
2 changed files with 8 additions and 6 deletions

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.sls.web;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@ -94,11 +95,11 @@ public class SLSWebApp extends HttpServlet {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
simulateInfoTemplate = IOUtils.toString(
cl.getResourceAsStream("html/simulate.info.html.template"));
cl.getResourceAsStream("html/simulate.info.html.template"), StandardCharsets.UTF_8);
simulateTemplate = IOUtils.toString(
cl.getResourceAsStream("html/simulate.html.template"));
cl.getResourceAsStream("html/simulate.html.template"), StandardCharsets.UTF_8);
trackTemplate = IOUtils.toString(
cl.getResourceAsStream("html/track.html.template"));
cl.getResourceAsStream("html/track.html.template"), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Map;
@ -34,7 +35,7 @@ public class TestSLSWebApp {
@Test
public void testSimulateInfoPageHtmlTemplate() throws Exception {
String simulateInfoTemplate = FileUtils.readFileToString(
new File("src/main/html/simulate.info.html.template"));
new File("src/main/html/simulate.info.html.template"), StandardCharsets.UTF_8);
Map<String, Object> simulateInfoMap = new HashMap<>();
simulateInfoMap.put("Number of racks", 10);
@ -72,7 +73,7 @@ public class TestSLSWebApp {
@Test
public void testSimulatePageHtmlTemplate() throws Exception {
String simulateTemplate = FileUtils.readFileToString(
new File("src/main/html/simulate.html.template"));
new File("src/main/html/simulate.html.template"), StandardCharsets.UTF_8);
Set<String> queues = new HashSet<String>();
queues.add("sls_queue_1");
@ -96,7 +97,7 @@ public class TestSLSWebApp {
@Test
public void testTrackPageHtmlTemplate() throws Exception {
String trackTemplate = FileUtils.readFileToString(
new File("src/main/html/track.html.template"));
new File("src/main/html/track.html.template"), StandardCharsets.UTF_8);
String trackedQueueInfo = "";
Set<String> trackedQueues = new HashSet<String>();
trackedQueues.add("sls_queue_1");