当前位置: 首页>>代码示例>>Java>>正文


Java HttpserverUtils类代码示例

本文整理汇总了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();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:22,代码来源:Httpserver.java

示例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();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:19,代码来源:Httpserver.java

示例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();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:27,代码来源:Httpserver.java

示例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();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:22,代码来源:LogPage.java

示例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();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:23,代码来源:JStackPage.java

示例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);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:29,代码来源:JStackPage.java

示例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();
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:18,代码来源:Httpserver.java

示例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();
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:18,代码来源:Httpserver.java

示例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();
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:25,代码来源:Httpserver.java

示例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();
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:22,代码来源:LogPage.java

示例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;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:32,代码来源:Httpserver.java

示例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);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:33,代码来源:ConfPage.java

示例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);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:10,代码来源:LogPage.java

示例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);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:38,代码来源:LogPage.java

示例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;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:29,代码来源:Httpserver.java


注:本文中的com.alibaba.jstorm.utils.HttpserverUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。