Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public static enum ConfVars implements ConfigKey {
TAJO_MASTER_CLIENT_RPC_ADDRESS("tajo.master.client-rpc.address", "localhost:26002",
Validators.networkAddr()),
TAJO_MASTER_INFO_ADDRESS("tajo.master.info-http.address", "0.0.0.0:26080", Validators.networkAddr()),
TAJO_MASTER_INFO_ADDRESS_CONTEXT_PATH("tajo.master.info-http.address.context.path", "/", Validators.javaString()),

// Tajo Rest Service
REST_SERVICE_ADDRESS("tajo.rest.service.address", "0.0.0.0:26880", Validators.networkAddr()),
Expand Down
21 changes: 21 additions & 0 deletions tajo-core/src/main/java/org/apache/tajo/util/JSPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,25 @@ public static <T extends Object> List<T> getPageNavigationList(List<T> originLis

return originList;
}

public static String getTajoMasterHttpAddrContextPath(Configuration config) {
if (!(config instanceof TajoConf)) {
throw new IllegalArgumentException("config should be a TajoConf type.");
}
try {
TajoConf conf = (TajoConf) config;
String tajoMasterHttpAddrContextPath = conf.getVar(ConfVars.TAJO_MASTER_INFO_ADDRESS_CONTEXT_PATH);
if (tajoMasterHttpAddrContextPath == null || tajoMasterHttpAddrContextPath.length() == 0 || "/".equals(tajoMasterHttpAddrContextPath)) {
tajoMasterHttpAddrContextPath = "";
} else {
if(!tajoMasterHttpAddrContextPath.startsWith("/") && tajoMasterHttpAddrContextPath.length() > 0) {
tajoMasterHttpAddrContextPath = "/" + tajoMasterHttpAddrContextPath;
}
}
return tajoMasterHttpAddrContextPath;
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.tajo.conf.TajoConf;
import org.apache.tajo.util.TUtil;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
Expand Down Expand Up @@ -65,6 +67,8 @@ public HttpServer(String name, String bindAddress, int port,
this.webServer = new Server();
this.findPort = findPort;

TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class);

if (connector == null) {
listenerStartedExternally = false;
listener = createBaseListener(conf);
Expand Down Expand Up @@ -92,7 +96,7 @@ public HttpServer(String name, String bindAddress, int port,

webAppContext = new WebAppContext();
webAppContext.setDisplayName(name);
webAppContext.setContextPath("/");
webAppContext.setContextPath(tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_INFO_ADDRESS_CONTEXT_PATH));
webAppContext.setResourceBase(appDir + "/" + name);
webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml");

Expand Down
9 changes: 6 additions & 3 deletions tajo-core/src/main/resources/webapps/admin/cluster.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<%@ page import="org.apache.tajo.webapp.StaticHttpServer" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.InetSocketAddress" %>
<%@ page import="org.apache.tajo.conf.TajoConf" %>

<%
TajoMaster master = (TajoMaster) StaticHttpServer.getInstance().getAttribute("tajo.info.server.object");
Expand All @@ -38,6 +39,8 @@
InetSocketAddress socketAddress = new InetSocketAddress(masterName[0], Integer.parseInt(masterName[1]));
String masterLabel = socketAddress.getAddress().getHostName()+ ":" + socketAddress.getPort();

String tajoMasterInfoAddressContextPath = JSPUtil.getTajoMasterHttpAddrContextPath(master.getConfig());

Map<Integer, NodeStatus> nodes = master.getContext().getResourceManager().getNodes();
List<Integer> wokerKeys = new ArrayList<>(nodes.keySet());
Collections.sort(wokerKeys);
Expand Down Expand Up @@ -126,7 +129,7 @@

for(TajoMasterInfo eachMaster : masters) {
String tajoMasterHttp = "http://" + eachMaster.getWebServerAddress().getHostName() + ":" +
eachMaster.getWebServerAddress().getPort() + "/index.jsp";
eachMaster.getWebServerAddress().getPort() + tajoMasterInfoAddressContextPath + "/index.jsp";
String isActive = eachMaster.isActive() == true ? "ACTIVE" : "BACKUP";
String isAvailable = eachMaster.isAvailable() == true ? "RUNNING" : "FAILED";
%>
Expand Down Expand Up @@ -174,7 +177,7 @@
for(NodeStatus queryMaster: liveQueryMasters) {
WorkerConnectionInfo connectionInfo = queryMaster.getConnectionInfo();
String queryMasterHttp = "http://" + connectionInfo.getHost()
+ ":" + connectionInfo.getHttpInfoPort() + "/index.jsp";
+ ":" + connectionInfo.getHttpInfoPort() + tajoMasterInfoAddressContextPath + "/index.jsp";
%>
<tr>
<td width='30' align='right'><%=no++%></td>
Expand Down Expand Up @@ -234,7 +237,7 @@
int no = 1;
for(NodeStatus node: liveNodes) {
WorkerConnectionInfo connectionInfo = node.getConnectionInfo();
String nodeHttp = "http://" + connectionInfo.getHost() + ":" + connectionInfo.getHttpInfoPort() + "/index.jsp";
String nodeHttp = "http://" + connectionInfo.getHost() + ":" + connectionInfo.getHttpInfoPort() + tajoMasterInfoAddressContextPath + "/index.jsp";
%>
<tr>
<td width='30' align='right'><%=no++%></td>
Expand Down
4 changes: 3 additions & 1 deletion tajo-core/src/main/resources/webapps/admin/query.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
InetSocketAddress socketAddress = new InetSocketAddress(masterName[0], Integer.parseInt(masterName[1]));
String masterLabel = socketAddress.getAddress().getHostName()+ ":" + socketAddress.getPort();

String tajoMasterInfoAddressContextPath = JSPUtil.getTajoMasterHttpAddrContextPath(master.getConfig());

List<QueryInProgress> submittedQueries =
new ArrayList<>(master.getContext().getQueryJobManager().getSubmittedQueries());
JSPUtil.sortQueryInProgress(submittedQueries, true);
Expand Down Expand Up @@ -158,7 +160,7 @@
for(QueryInProgress eachQuery: runningQueries) {
long time = System.currentTimeMillis() - eachQuery.getQueryInfo().getStartTime();
String detailView = "http://" + eachQuery.getQueryInfo().getQueryMasterHost() + ":" + portMap.get(eachQuery.getQueryInfo().getQueryMasterHost()) +
"/querydetail.jsp?queryId=" + eachQuery.getQueryId() + "&startTime=" + eachQuery.getQueryInfo().getStartTime();
tajoMasterInfoAddressContextPath + "/querydetail.jsp?queryId=" + eachQuery.getQueryId() + "&startTime=" + eachQuery.getQueryInfo().getStartTime();
%>
<tr>
<td><a href='<%=detailView%>'><%=eachQuery.getQueryId()%></a></td>
Expand Down
4 changes: 3 additions & 1 deletion tajo-core/src/main/resources/webapps/admin/querytasks.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
TajoMaster master = (TajoMaster) StaticHttpServer.getInstance().getAttribute("tajo.info.server.object");
HistoryReader reader = master.getContext().getHistoryReader();

String tajoMasterInfoAddressContextPath = JSPUtil.getTajoMasterHttpAddrContextPath(master.getConfig());

String queryId = request.getParameter("queryId");
String startTime = request.getParameter("startTime");
String ebId = request.getParameter("ebid");
Expand Down Expand Up @@ -221,7 +223,7 @@
NodeStatus nodeStatus = nodeMap.get(eachTask.getHostAndPort());
if (nodeStatus != null) {
String[] hostTokens = eachTask.getHostAndPort().split(":");
taskHost = "<a href='http://" + hostTokens[0] + ":" + nodeStatus.getConnectionInfo().getHttpInfoPort() +
taskHost = "<a href='http://" + hostTokens[0] + ":" + nodeStatus.getConnectionInfo().getHttpInfoPort() + tajoMasterInfoAddressContextPath +
"/taskhistory.jsp?taskAttemptId=" + eachTask.getId() + "&startTime=" + eachTask.getLaunchTime() +
"'>" + eachTask.getHostAndPort() + "</a>";
}
Expand Down
4 changes: 3 additions & 1 deletion tajo-core/src/main/resources/webapps/worker/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
<%@ page import="org.apache.tajo.util.JSPUtil" %>
<%@ page import="org.apache.tajo.webapp.StaticHttpServer" %>
<%@ page import="org.apache.tajo.worker.TajoWorker" %>
<%@ page import="org.apache.tajo.conf.TajoConf" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
TajoWorker tmpTajoWorker = (TajoWorker) StaticHttpServer.getInstance().getAttribute("tajo.info.server.object");
String tajoMasterHttp = "http://" + JSPUtil.getTajoMasterHttpAddr(tmpTajoWorker.getConfig());
String tajoMasterInfoAddressContextPath = JSPUtil.getTajoMasterHttpAddrContextPath(tmpTajoWorker.getConfig());
String tajoMasterHttp = "http://" + JSPUtil.getTajoMasterHttpAddr(tmpTajoWorker.getConfig()) + tajoMasterInfoAddressContextPath;
%>
<div class="menu">
<div style='float:left; margin-left:12px; margin-top:6px;'><a href='<%=tajoMasterHttp%>/index.jsp'><img src='/static/img/logo_tajo.gif' border='0'/></a></div>
Expand Down
2 changes: 1 addition & 1 deletion tajo-core/src/main/resources/webapps/worker/querytasks.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
if(lastAttempt != null && lastAttempt.getWorkerConnectionInfo() != null) {
WorkerConnectionInfo conn = lastAttempt.getWorkerConnectionInfo();
TaskAttemptId lastAttemptId = lastAttempt.getId();
taskHost = "<a href='http://" + conn.getHost() + ":" + conn.getHttpInfoPort() + "/taskdetail.jsp?taskAttemptId=" + lastAttemptId + "'>" + conn.getHost() + "</a>";
taskHost = "<a href='http://" + conn.getHost() + ":" + conn.getHttpInfoPort() + tajoMasterInfoAddressContextPath + "/taskdetail.jsp?taskAttemptId=" + lastAttemptId + "'>" + conn.getHost() + "</a>";
progress = eachTask.getLastAttempt().getProgress();
}
%>
Expand Down
3 changes: 2 additions & 1 deletion tajo-dist/src/main/bin/start-tajo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fi
# Display WEB UI URL and TajoMaster RPC address.
# Getting configuration value of http address and rpc address.
HTTP_ADDRESS=$("$bin"/tajo getconf tajo.master.info-http.address)
HTTP_ADDRESS_CONTEXT_PATH=$("$bin"/tajo getconf tajo.master.info-http.address.context.path)
RPC_ADDRESS=$("$bin"/tajo getconf tajo.master.client-rpc.address)
HTTP_ADDRESS=(${HTTP_ADDRESS//:/ })
RPC_ADDRESS=(${RPC_ADDRESS//:/ })
Expand All @@ -70,5 +71,5 @@ if [ ${RPC_ADDRESS[0]} = "0.0.0.0" ] ||
RPC_ADDRESS[0]=`hostname`
fi

echo "Tajo master web UI: http://${HTTP_ADDRESS[0]}:${HTTP_ADDRESS[1]}"
echo "Tajo master web UI: http://${HTTP_ADDRESS[0]}:${HTTP_ADDRESS[1]}${HTTP_ADDRESS_CONTEXT_PATH}"
echo "Tajo Client Service: ${RPC_ADDRESS[0]}:${RPC_ADDRESS[1]}"