本文整理汇总了Java中org.apache.hadoop.http.HtmlQuoting类的典型用法代码示例。如果您正苦于以下问题:Java HtmlQuoting类的具体用法?Java HtmlQuoting怎么用?Java HtmlQuoting使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HtmlQuoting类属于org.apache.hadoop.http包,在下文中一共展示了HtmlQuoting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFilter
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws IOException,
ServletException {
String uri = HtmlQuoting.quoteHtmlChars(request.getRequestURI());
String redirectPath = containerLogPageRedirectPath(uri);
if (redirectPath != null) {
String redirectMsg =
"Redirecting to log server" + " : " + redirectPath;
PrintWriter out = response.getWriter();
out.println(redirectMsg);
response.setHeader("Location", redirectPath);
response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
return;
}
super.doFilter(request, response, chain);
}
示例2: printGotoForm
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
public static void printGotoForm(JspWriter out,
int namenodeInfoPort,
String tokenString,
String file,
String nnAddress) throws IOException {
out.print("<form action=\"browseDirectory.jsp\" method=\"get\" name=\"goto\">");
out.print("Goto : ");
out.print("<input name=\"dir\" type=\"text\" width=\"50\" id=\"dir\" value=\""+ HtmlQuoting.quoteHtmlChars(file)+"\"/>");
out.print("<input name=\"go\" type=\"submit\" value=\"go\"/>");
out.print("<input name=\"namenodeInfoPort\" type=\"hidden\" "
+ "value=\"" + namenodeInfoPort + "\"/>");
if (UserGroupInformation.isSecurityEnabled()) {
out.print("<input name=\"" + DELEGATION_PARAMETER_NAME
+ "\" type=\"hidden\" value=\"" + tokenString + "\"/>");
}
out.print("<input name=\""+ NAMENODE_ADDRESS +"\" type=\"hidden\" "
+ "value=\"" + nnAddress + "\"/>");
out.print("</form>");
}
示例3: handleRedirect
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
private void handleRedirect(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse,
String activeServerAddress) throws IOException {
String requestURI = servletRequest.getRequestURI();
String queryString = servletRequest.getQueryString();
if ((queryString != null) && (!queryString.isEmpty())) {
requestURI += "?" + queryString;
}
String quotedUri = HtmlQuoting.quoteHtmlChars(requestURI);
if (quotedUri == null) {
quotedUri = "/";
}
String redirectLocation = activeServerAddress + quotedUri;
LOG.info("Not active. Redirecting to {}", redirectLocation);
// A POST/PUT/DELETE require special handling by sending HTTP 307 instead of the regular 301/302.
// Reference: http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect
if (isUnsafeHttpMethod(servletRequest)) {
httpServletResponse.setHeader(HttpHeaders.LOCATION, redirectLocation);
httpServletResponse.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
} else {
httpServletResponse.sendRedirect(redirectLocation);
}
}
示例4: printGotoForm
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
public static void printGotoForm(JspWriter out, int namenodeInfoPort,
String tokenString, String file, String nnAddress) throws IOException {
out.print(
"<form action=\"browseDirectory.jsp\" method=\"get\" name=\"goto\">");
out.print("Goto : ");
out.print(
"<input name=\"dir\" type=\"text\" width=\"50\" id=\"dir\" value=\"" +
HtmlQuoting.quoteHtmlChars(file) + "\"/>");
out.print("<input name=\"go\" type=\"submit\" value=\"go\"/>");
out.print("<input name=\"namenodeInfoPort\" type=\"hidden\" " + "value=\"" +
namenodeInfoPort + "\"/>");
if (UserGroupInformation.isSecurityEnabled()) {
out.print("<input name=\"" + DELEGATION_PARAMETER_NAME +
"\" type=\"hidden\" value=\"" + tokenString + "\"/>");
}
out.print("<input name=\"" + NAMENODE_ADDRESS + "\" type=\"hidden\" " +
"value=\"" + nnAddress + "\"/>");
out.print("</form>");
}
示例5: printJobACLs
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
/**
* Nicely print the Job-ACLs
* @param tracker
* @param jobAcls
* @param out
* @throws IOException
*/
static void printJobACLs(JobTracker tracker,
Map<JobACL, AccessControlList> jobAcls, JspWriter out)
throws IOException {
if (tracker.areACLsEnabled()) {
// Display job-view-acls and job-modify-acls configured for this job
out.print("<b>Job-ACLs:</b><br>");
for (JobACL aclName : JobACL.values()) {
String aclConfigName = aclName.getAclName();
AccessControlList aclConfigured = jobAcls.get(aclName);
if (aclConfigured != null) {
String aclStr = aclConfigured.toString();
out.print(" " + aclConfigName + ": "
+ HtmlQuoting.quoteHtmlChars(aclStr) + "<br>");
}
}
}
else {
out.print("<b>Job-ACLs: " + new AccessControlList("*").toString()
+ "</b><br>");
}
}
示例6: printJob
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
private void printJob(String timestamp,
String jobId, String jobName,
String user, Path logFile, JspWriter out)
throws IOException {
out.print("<tr>");
out.print("<td>" + new Date(Long.parseLong(timestamp)) + "</td>");
out.print("<td>" + "<a href=\"jobdetailshistory.jsp?logFile="
+ logFile.toString() + "\">" + jobId + "</a></td>");
out.print("<td>"
+ HtmlQuoting.quoteHtmlChars(unescapeUnderscores(jobName))
+ "</td>");
out.print("<td>"
+ HtmlQuoting.quoteHtmlChars(unescapeUnderscores(user))
+ "</td>");
out.print("</tr>");
}
示例7: doFilter
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws IOException,
ServletException {
response.setCharacterEncoding("UTF-8");
String uri = HtmlQuoting.quoteHtmlChars(request.getRequestURI());
String queryString = request.getQueryString();
if (uri == null) {
uri = "/";
}
if (queryString != null) {
uri = uri + "?" + queryString;
}
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
rmWebApp.checkIfStandbyRM();
if (rmWebApp.isStandby()
&& shouldRedirect(rmWebApp, uri)) {
String redirectPath = rmWebApp.getRedirectPath() + uri;
if (redirectPath != null && !redirectPath.isEmpty()) {
String redirectMsg =
"This is standby RM. The redirect url is: " + redirectPath;
PrintWriter out = response.getWriter();
out.println(redirectMsg);
response.setHeader("Location", redirectPath);
response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
return;
}
}
super.doFilter(request, response, chain);
}
示例8: doFilter
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws IOException,
ServletException {
response.setCharacterEncoding("UTF-8");
String uri = HtmlQuoting.quoteHtmlChars(request.getRequestURI());
if (uri == null) {
uri = "/";
}
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
rmWebApp.checkIfStandbyRM();
if (rmWebApp.isStandby()
&& shouldRedirect(rmWebApp, uri)) {
String redirectPath = rmWebApp.getRedirectPath() + uri;
if (redirectPath != null && !redirectPath.isEmpty()) {
String redirectMsg =
"This is standby RM. The redirect url is: " + redirectPath;
PrintWriter out = response.getWriter();
out.println(redirectMsg);
response.setHeader("Location", redirectPath);
response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
return;
}
}
super.doFilter(request, response, chain);
}
示例9: doFilter
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws IOException,
ServletException {
response.setCharacterEncoding("UTF-8");
String uri = HtmlQuoting.quoteHtmlChars(request.getRequestURI());
if (uri == null) {
uri = "/";
}
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
rmWebApp.checkIfStandbyRM();
if (rmWebApp.isStandby()
&& shouldRedirect(rmWebApp, uri)) {
String redirectPath = rmWebApp.getRedirectPath() + uri;
if (redirectPath != null && !redirectPath.isEmpty()) {
String redirectMsg =
"This is standby RM. Redirecting to the current active RM: "
+ redirectPath;
response.addHeader("Refresh", "3; url=" + redirectPath);
PrintWriter out = response.getWriter();
out.println(redirectMsg);
return;
}
}
super.doFilter(request, response, chain);
}
示例10: printPathWithLinks
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
public static void printPathWithLinks(String dir, JspWriter out,
int namenodeInfoPort,
String tokenString,
String nnAddress
) throws IOException {
try {
String[] parts = dir.split(Path.SEPARATOR);
StringBuilder tempPath = new StringBuilder(dir.length());
out.print("<a href=\"browseDirectory.jsp" + "?dir="+ Path.SEPARATOR
+ "&namenodeInfoPort=" + namenodeInfoPort
+ getDelegationTokenUrlParam(tokenString)
+ getUrlParam(NAMENODE_ADDRESS, nnAddress) + "\">" + Path.SEPARATOR
+ "</a>");
tempPath.append(Path.SEPARATOR);
for (int i = 0; i < parts.length-1; i++) {
if (!parts[i].equals("")) {
tempPath.append(parts[i]);
out.print("<a href=\"browseDirectory.jsp" + "?dir="
+ HtmlQuoting.quoteHtmlChars(tempPath.toString()) + "&namenodeInfoPort=" + namenodeInfoPort
+ getDelegationTokenUrlParam(tokenString)
+ getUrlParam(NAMENODE_ADDRESS, nnAddress));
out.print("\">" + HtmlQuoting.quoteHtmlChars(parts[i]) + "</a>" + Path.SEPARATOR);
tempPath.append(Path.SEPARATOR);
}
}
if(parts.length > 0) {
out.print(HtmlQuoting.quoteHtmlChars(parts[parts.length-1]));
}
}
catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
}
示例11: getHtmlEscapedURIWithQueryString
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
/**
* Get a HTML escaped uri with the query parameters of the request.
* @param request HttpServletRequest with the request details
* @return HTML escaped uri with the query paramters
*/
public static String getHtmlEscapedURIWithQueryString(
HttpServletRequest request) {
String urlEncodedQueryString = getURLEncodedQueryString(request);
if (urlEncodedQueryString != null) {
return HtmlQuoting.quoteHtmlChars(
request.getRequestURI() + "?" + urlEncodedQueryString);
}
return HtmlQuoting.quoteHtmlChars(request.getRequestURI());
}
示例12: printPathWithLinks
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
public static void printPathWithLinks(String dir, JspWriter out,
int namenodeInfoPort, String tokenString, String nnAddress)
throws IOException {
try {
String[] parts = dir.split(Path.SEPARATOR);
StringBuilder tempPath = new StringBuilder(dir.length());
out.print("<a href=\"browseDirectory.jsp" + "?dir=" + Path.SEPARATOR +
"&namenodeInfoPort=" + namenodeInfoPort +
getDelegationTokenUrlParam(tokenString) +
getUrlParam(NAMENODE_ADDRESS, nnAddress) + "\">" + Path.SEPARATOR +
"</a>");
tempPath.append(Path.SEPARATOR);
for (int i = 0; i < parts.length - 1; i++) {
if (!parts[i].equals("")) {
tempPath.append(parts[i]);
out.print("<a href=\"browseDirectory.jsp" + "?dir=" +
HtmlQuoting.quoteHtmlChars(tempPath.toString()) +
"&namenodeInfoPort=" + namenodeInfoPort +
getDelegationTokenUrlParam(tokenString) +
getUrlParam(NAMENODE_ADDRESS, nnAddress));
out.print("\">" + HtmlQuoting.quoteHtmlChars(parts[i]) + "</a>" +
Path.SEPARATOR);
tempPath.append(Path.SEPARATOR);
}
}
if (parts.length > 0) {
out.print(HtmlQuoting.quoteHtmlChars(parts[parts.length - 1]));
}
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
}
示例13: doFilter
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws IOException,
ServletException {
response.setCharacterEncoding("UTF-8");
String uri = HtmlQuoting.quoteHtmlChars(request.getRequestURI());
if (uri == null) {
uri = "/";
}
RMWebApp rmWebApp = injector.getInstance(RMWebApp.class);
rmWebApp.checkIfStandbyRM();
if (rmWebApp.isStandby()
&& !uri.equals("/" + rmWebApp.wsName() + "/v1/cluster/info")
&& !uri.equals("/" + rmWebApp.name() + "/cluster")) {
String redirectPath = rmWebApp.getRedirectPath() + uri;
if (redirectPath != null && !redirectPath.isEmpty()) {
String redirectMsg =
"This is standby RM. Redirecting to the current active RM: "
+ redirectPath;
response.addHeader("Refresh", "3; url=" + redirectPath);
PrintWriter out = response.getWriter();
out.println(redirectMsg);
return;
}
}
super.doFilter(request, response, chain);
}
示例14: streamBlockInAscii
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
public static void streamBlockInAscii(InetSocketAddress addr,
long blockId, Token<BlockTokenIdentifier> blockToken, long genStamp,
long blockSize, long offsetIntoBlock, long chunkSizeToView,
JspWriter out, Configuration conf) throws IOException {
if (chunkSizeToView == 0) return;
Socket s = new Socket();
s.connect(addr, HdfsConstants.READ_TIMEOUT);
s.setSoTimeout(HdfsConstants.READ_TIMEOUT);
long amtToRead = Math.min(chunkSizeToView, blockSize - offsetIntoBlock);
// Use the block name for file name.
String file = BlockReader.getFileName(addr, blockId);
BlockReader blockReader = BlockReader.newBlockReader(s, file,
new Block(blockId, 0, genStamp), blockToken,
offsetIntoBlock, amtToRead, conf.getInt("io.file.buffer.size", 4096));
byte[] buf = new byte[(int)amtToRead];
int readOffset = 0;
int retries = 2;
while ( amtToRead > 0 ) {
int numRead;
try {
numRead = blockReader.readAll(buf, readOffset, (int)amtToRead);
}
catch (IOException e) {
retries--;
if (retries == 0)
throw new IOException("Could not read data from datanode");
continue;
}
amtToRead -= numRead;
readOffset += numRead;
}
blockReader = null;
s.close();
out.print(HtmlQuoting.quoteHtmlChars(new String(buf)));
}
示例15: printBlackListedTrackers
import org.apache.hadoop.http.HtmlQuoting; //导入依赖的package包/类
private void printBlackListedTrackers(JspWriter out,
JobInProgress job) throws IOException {
Map<String, Integer> trackerErrors = job.getTaskTrackerErrors();
out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">");
out.print("<tr><th>TaskTracker</th><th>No. of Failures</th></tr>\n");
int maxErrorsPerTracker = job.getJobConf().getMaxTaskFailuresPerTracker();
for (Map.Entry<String,Integer> e : trackerErrors.entrySet()) {
if (e.getValue().intValue() >= maxErrorsPerTracker) {
out.print("<tr><td>" + HtmlQuoting.quoteHtmlChars(e.getKey()) +
"</td><td>" + e.getValue() + "</td></tr>\n");
}
}
out.print("</table>\n");
}