类org.apache.zookeeper.client.FourLetterWordMain源码实例Demo

下面列出了怎么用org.apache.zookeeper.client.FourLetterWordMain的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ankush   文件: ZookeeperMonitor.java
/**
 * Rest API to run fourLetterCommand Run four letter command.
 */
private void runFourLetterCommand() {
	if (!this.setEnsembleId()) {
		return;
	}
	// Getting the ip address from parameter map.
	String host = (String) parameterMap.get(Constant.Keys.HOST);

	// Getting the ip address from parameter map.
	String command = (String) parameterMap.get(Constant.Keys.COMMAND);

	int clientPort = compConf
			.getAdvanceConfIntegerProperty(ZookeeperConstant.Keys.CLIENT_PORT);

	try {
		logger.info("Zookeeper 4 Letter Command Execution ...");
		String commandOutput = FourLetterWordMain.send4LetterWord(host,
				clientPort, command);

		result.put(Constant.Keys.OUT, commandOutput);

	} catch (Exception e) {
		addErrorAndLogException(
				"Error while executing Zookeeper 4 Letter Command: ", e);
	}
}
 
源代码2 项目: Mario   文件: ZooKeeperState.java
@Override
public void run() {
	try {
		ret = FourLetterWordMain.send4LetterWord(host, port, cmd);
	} catch (IOException e) {
		return;
	}
}
 
源代码3 项目: Mario   文件: IndexController.java
@Override
public void run() {
	try {
		ret = FourLetterWordMain.send4LetterWord(info.gethost().trim(), info.getport(), cmd);
	} catch (IOException e) {
		return;
	}
}
 
源代码4 项目: ankush   文件: ZookeeperMonitor.java
/**
 * Exec four letter cmd.
 * 
 * @param host
 *            the host
 * @param command
 *            the command
 * @param clientPort
 *            the client port
 * @return the string
 */
private String execFourLetterCmd(String host, String command, int clientPort) {
	try {
		String commandOutput = FourLetterWordMain.send4LetterWord(host,
				clientPort, command);

		List<String> sysoutList = new ArrayList<String>(
				Arrays.asList(commandOutput.split("\n")));
		String data = new String();

		String escapeCharacter;
		String parameterName;

		if (command
				.equalsIgnoreCase(ZookeeperConstant.Monitor_Keys.COMMAND_MNTR)) {
			escapeCharacter = "\t";
			parameterName = "zk_server_state";
		} else if (command
				.equalsIgnoreCase(ZookeeperConstant.Monitor_Keys.COMMAND_SRVR)) {
			escapeCharacter = ":";
			parameterName = "Mode";
		} else if (command
				.equalsIgnoreCase(ZookeeperConstant.Monitor_Keys.COMMAND_CONF)) {
			escapeCharacter = "=";
			parameterName = "serverId";
		} else {
			escapeCharacter = " ";
			parameterName = " ";
		}

		for (String outData : sysoutList) {

			if (outData.contains(escapeCharacter)) {
				if (outData.split(escapeCharacter)[0].trim()
						.equalsIgnoreCase(parameterName)) {
					data = outData.split(escapeCharacter)[1].trim();
					logger.info("data: " + data);
				}
			}
		}

		return data;
	} catch (Exception e) {
		// addErrorAndLogException("Couldn't execute command-"+command, e);
		logger.error(e.getMessage(), e);
	}
	return "";
}
 
 类所在包
 类方法
 同包方法