本文整理汇总了Java中com.alibaba.jstorm.utils.HttpserverUtils类的典型用法代码示例。如果您正苦于以下问题:Java HttpserverUtils类的具体用法?Java HttpserverUtils怎么用?Java HttpserverUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpserverUtils类属于com.alibaba.jstorm.utils包,在下文中一共展示了HttpserverUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleShowLog
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
private void handleShowLog(HttpExchange t, Map<String, String> paramMap)
throws IOException {
Pair<Long, byte[]> logPair = queryLog(t, paramMap);
if (logPair == null) {
return;
}
String size = String.format(
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_SIZE_FORMAT,
logPair.getFirst());
byte[] sizeByts = size.getBytes();
byte[] logData = logPair.getSecond();
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, sizeByts.length
+ logData.length);
OutputStream os = t.getResponseBody();
os.write(sizeByts);
os.write(logData);
os.close();
}
示例2: handleListDir
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
void handleListDir(HttpExchange t, Map<String, String> paramMap)
throws IOException {
byte[] filesJson = "Failed to get file list".getBytes();
try {
String dir = paramMap.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_DIR);
filesJson = getJSonFiles(dir);
} catch (Exception e) {
LOG.error("Failed to list files", e);
handlFailure(t, "Failed to get file list");
return;
}
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, filesJson.length);
OutputStream os = t.getResponseBody();
os.write(filesJson);
os.close();
}
示例3: handleJstack
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
void handleJstack(HttpExchange t, Map<String, String> paramMap)
throws IOException {
String workerPort = paramMap.get(
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_WORKER_PORT);
if (workerPort == null) {
handlFailure(t, "Not set worker's port");
return ;
}
LOG.info("Begin to get jstack of " + workerPort);
StringBuffer sb = new StringBuffer();
List<Integer> pids = Worker.getOldPortPids(workerPort);
for (Integer pid : pids) {
sb.append("!!!!!!!!!!!!!!!!!!\r\n");
sb.append("WorkerPort:" + workerPort + ", pid:" + pid);
sb.append("\r\n!!!!!!!!!!!!!!!!!!\r\n");
handleJstack(sb, pid);
}
byte[] data = sb.toString().getBytes();
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, data.length);
OutputStream os = t.getResponseBody();
os.write(data);
os.close();
}
示例4: LogPage
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
public LogPage() throws Exception {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
clusterName = ctx.getExternalContext()
.getRequestParameterMap().get("clusterName");
}
if (ctx.getExternalContext().getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_POS) != null) {
position = ctx.getExternalContext().getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_POS);
}
if (ctx.getExternalContext().getRequestParameterMap().get("port") != null) {
port = JStormUtils.parseInt(ctx.getExternalContext()
.getRequestParameterMap().get("port"), 0);
}
init();
}
示例5: JStackPage
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
public JStackPage() throws Exception {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx.getExternalContext().getRequestParameterMap().get("host") != null) {
host = ctx.getExternalContext().getRequestParameterMap()
.get("host");
}
if (ctx.getExternalContext().getRequestParameterMap().get("port") != null) {
port = JStormUtils.parseInt(ctx.getExternalContext()
.getRequestParameterMap().get("port"), 0);
}
if (ctx.getExternalContext().getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_WORKER_PORT) != null) {
workerPort = JStormUtils.parseInt(ctx.getExternalContext()
.getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_WORKER_PORT));
}
init();
}
示例6: queryLog
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
/**
* proxy query log for the specified task.
*
* @param task
* the specified task
*/
private void queryLog(Map conf) {
// PROXY_URL = "http://%s:%s/logview?%s=%s&%s=%s";
String baseUrl = String
.format(PROXY_URL, NetWorkUtils.host2Ip(host), port,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_JSTACK,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_WORKER_PORT,
workerPort);
String url = baseUrl;
try {
// 1. proxy call the task host log view service
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
HttpResponse response = client.execute(post);
setData(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
setData(e.getMessage());
LOG.error(e.getCause(), e);
}
}
示例7: handleShowLog
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
private void handleShowLog(HttpExchange t, Map<String, String> paramMap) throws IOException {
Pair<Long, byte[]> logPair = queryLog(t, paramMap);
if (logPair == null) {
return;
}
String size = String.format(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_SIZE_FORMAT, logPair.getFirst());
byte[] sizeByts = size.getBytes();
byte[] logData = logPair.getSecond();
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, sizeByts.length + logData.length);
OutputStream os = t.getResponseBody();
os.write(sizeByts);
os.write(logData);
os.close();
}
示例8: handleListDir
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
void handleListDir(HttpExchange t, Map<String, String> paramMap) throws IOException {
byte[] filesJson = "Failed to get file list".getBytes();
try {
String dir = paramMap.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_DIR);
filesJson = getJSonFiles(dir);
} catch (Exception e) {
LOG.error("Failed to list files", e);
handlFailure(t, "Failed to get file list");
return;
}
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, filesJson.length);
OutputStream os = t.getResponseBody();
os.write(filesJson);
os.close();
}
示例9: handleJstack
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
void handleJstack(HttpExchange t, Map<String, String> paramMap) throws IOException {
String workerPort = paramMap.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_WORKER_PORT);
if (workerPort == null) {
handlFailure(t, "Not set worker's port");
return;
}
LOG.info("Begin to get jstack of " + workerPort);
StringBuffer sb = new StringBuffer();
List<Integer> pids = Worker.getOldPortPids(workerPort);
for (Integer pid : pids) {
sb.append("!!!!!!!!!!!!!!!!!!\r\n");
sb.append("WorkerPort:" + workerPort + ", pid:" + pid);
sb.append("\r\n!!!!!!!!!!!!!!!!!!\r\n");
handleJstack(sb, pid);
}
byte[] data = sb.toString().getBytes();
t.sendResponseHeaders(HttpURLConnection.HTTP_OK, data.length);
OutputStream os = t.getResponseBody();
os.write(data);
os.close();
}
示例10: LogPage
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
public LogPage() throws Exception {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
clusterName = (String) ctx.getExternalContext()
.getRequestParameterMap().get("clusterName");
}
if (ctx.getExternalContext().getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_POS) != null) {
position = ctx.getExternalContext().getRequestParameterMap()
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_POS);
}
if (ctx.getExternalContext().getRequestParameterMap().get("port") != null) {
port = JStormUtils.parseInt(ctx.getExternalContext()
.getRequestParameterMap().get("port"), 0);
}
init();
}
示例11: handle
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
@Override
public void handle(HttpExchange t) throws IOException {
URI uri = t.getRequestURI();
Map<String, String> paramMap = parseRawQuery(uri.getRawQuery());
LOG.info("Receive command " + paramMap);
String cmd = paramMap
.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD);
if (StringUtils.isBlank(cmd) == true) {
handlFailure(t, "Bad Request, Not set command type");
return;
}
if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW.equals(cmd)) {
handleShowLog(t, paramMap);
return;
} else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_LIST
.equals(cmd)) {
handleListDir(t, paramMap);
return;
}else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_JSTACK.equals(cmd)) {
handleJstack(t, paramMap);
return ;
}else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW_CONF.equals(cmd)) {
handleShowConf(t, paramMap);
return ;
}
handlFailure(t, "Bad Request, Not support command type " + cmd);
return;
}
示例12: queryConf
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
/**
* proxy query log for the specified task.
*
* @param task
* the specified task
*/
private void queryConf() {
// PROXY_URL = "http://%s:%s/logview?%s=%s&log=%s";
String baseUrl = String.format(PROXY_URL, NetWorkUtils.host2Ip(host), port,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW_CONF);
String url = baseUrl;
try {
// 1. proxy call the task host log view service
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
HttpResponse response = client.execute(post);
// 2. check the request is success, then read the log
if (response.getStatusLine().getStatusCode() == 200) {
String data = EntityUtils.toString(response.getEntity(), ConfigExtension.getLogViewEncoding(conf));
setConfData(parseJsonConf(data));
} else {
setConfData(EntityUtils.toString(response.getEntity()));
}
} catch (Exception e) {
setConfData(e.getMessage());
LOG.error(e.getCause(), e);
}
}
示例13: insertPage
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
private void insertPage(long index) {
long pos = index * HttpserverUtils.HTTPSERVER_LOGVIEW_PAGESIZE;
LogPageIndex page = new LogPageIndex();
page.setIndex(String.valueOf(index));
page.setPos(String.valueOf(pos));
pages.add(page);
}
示例14: queryLog
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
/**
* proxy query log for the specified task.
*
* @param task
* the specified task
*/
private void queryLog(Map conf) {
// PROXY_URL = "http://%s:%s/logview?%s=%s&log=%s";
String baseUrl = String.format(PROXY_URL, NetWorkUtils.host2Ip(host), port,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD,
HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW, logFileName);
String url = baseUrl;
if (position != null) {
url += ("&" + HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_POS + "=" + position);
}
try {
// 1. proxy call the task host log view service
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
HttpResponse response = client.execute(post);
// 2. check the request is success, then read the log
if (response.getStatusLine().getStatusCode() == 200) {
String data = EntityUtils.toString(response.getEntity(), ConfigExtension.getLogViewEncoding(conf));
String sizeStr = data.substring(0, 16);
genPageUrl(sizeStr);
setLog(data);
} else {
setLog(EntityUtils.toString(response.getEntity()));
}
} catch (Exception e) {
setLog(e.getMessage());
LOG.error(e.getCause(), e);
}
}
示例15: handle
import com.alibaba.jstorm.utils.HttpserverUtils; //导入依赖的package包/类
public void handle(HttpExchange t) throws IOException {
URI uri = t.getRequestURI();
Map<String, String> paramMap = parseRawQuery(uri.getRawQuery());
LOG.info("Receive command " + paramMap);
String cmd = paramMap.get(HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD);
if (StringUtils.isBlank(cmd) == true) {
handlFailure(t, "Bad Request, Not set command type");
return;
}
if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW.equals(cmd)) {
handleShowLog(t, paramMap);
return;
} else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_LIST.equals(cmd)) {
handleListDir(t, paramMap);
return;
} else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_JSTACK.equals(cmd)) {
handleJstack(t, paramMap);
return;
} else if (HttpserverUtils.HTTPSERVER_LOGVIEW_PARAM_CMD_SHOW_CONF.equals(cmd)) {
handleShowConf(t, paramMap);
return;
}
handlFailure(t, "Bad Request, Not support command type " + cmd);
return;
}