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


Java SSHExec.disconnect方法代码示例

本文整理汇总了Java中net.neoremind.sshxcute.core.SSHExec.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java SSHExec.disconnect方法的具体用法?Java SSHExec.disconnect怎么用?Java SSHExec.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.neoremind.sshxcute.core.SSHExec的用法示例。


在下文中一共展示了SSHExec.disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateRSAKeyFiles

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
private static boolean generateRSAKeyFiles(String publicIp,
		String username, String password, String privateKey)
		throws TaskExecFailException {

	CustomTask task = new ExecCommand(
			"[[ -f ~/.ssh/id_rsa ]] || ssh-keygen -q -t rsa -P '' -f ~/.ssh/id_rsa; ");
	SSHExec connection = SSHUtils.connectToNode(publicIp, username,
			password, privateKey);
	if (connection.exec(task).rc != 0) {
		return false;
	}
	if (connection != null) {
		connection.disconnect();
	}
	return true;
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:17,代码来源:SSHUtils.java

示例2: downloadFile

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
/**
	 * Method to Get the path of log file for Downloading.
	 * 
	 * @param clusterName
	 *            Name of the cluster.
	 * @param filePath
	 *            Path of the file on remote machine.
	 * @return Path of the log file for Download.
	 * @throws Exception
	 *             the exception
	 */
	public String downloadFile(String clusterName, String filePath,
			String agentInstallDir) throws AnkushException, Exception {

		// Getting the log file content with total read count value.
		SSHExec conn = SSHUtils.connectToNode(hostname, username, authInfo,
				privateKey);

//		String command = "java -cp $HOME/.ankush/agent/libs/*:$HOME/.ankush/agent/libs/agent-0.1.jar"
//				+ " com.impetus.ankush.agent.action.ActionHandler upload "
//				+ filePath;

		StringBuilder command = new StringBuilder().append(AgentUtils
				.getActionHandlerCommand(agentInstallDir));
		command.append("upload").append(" ").append(filePath);
		ExecCommand task = new ExecCommand(command.toString());
		if (conn != null) {
			Result rs = conn.exec(task);
			if (rs.rc != 0) {
				conn.disconnect();
				throw new AnkushException(rs.error_msg);
			} else {
				conn.disconnect();
				// Getting the file name for file path.
				String fileName = FilenameUtils.getName(filePath);

				// Getting the cluster folder path.
				String downloadPath = "/public/clusters/logs/" + fileName
						+ ".zip";

				// return the down-load path
				return downloadPath;
			}
		}
		// return the down-load path
		throw new Exception("Unable to connect to node.");
	}
 
开发者ID:Impetus,项目名称:ankush,代码行数:48,代码来源:LogViewHandler.java

示例3: submitJob

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
/**
 * Submit job.
 * 
 * @param connection
 *            the connection
 * @param command
 *            the command
 */
private void submitJob(SSHExec connection, String command) {
	try {
		logger.debug("Submitting Job : " + command);
		CustomTask jobTask = new ExecCommand(command);
		connection.exec(jobTask);
	} catch (TaskExecFailException e) {
		logger.error("Could not submit Job.", e);
	} finally {
		// Disconnect the connection
		if (connection != null) {
			connection.disconnect();
		}
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:23,代码来源:HadoopComponentMonitor.java

示例4: setupPasswordlessSSH

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
@Override
public boolean setupPasswordlessSSH(Set<String> nodes) {
	try {
		LOG.info("Configuring Passwordless SSH from Hadoop NameNode.",
				Constant.Component.Name.HADOOP);

		String namenodeHost = HadoopUtils.getNameNodeHost(this.compConfig);

		if (!this.generateRsaKeysForHadoopNodes(nodes)) {
			return false;
		}

		if (this.clusterConfig.getNodes().containsKey(namenodeHost)) {
			if (!HadoopUtils.setupPasswordlessSSH(LOG, this.clusterConfig,
					namenodeHost, nodes)) {
				return false;
			}
		} else {
			SSHExec connection = SSHUtils.connectToNode(namenodeHost,
					this.clusterConfig.getAuthConf());
			if (!HadoopUtils.setupPasswordlessSSH(LOG, this.clusterConfig,
					namenodeHost, nodes, connection)) {
				return false;
			}
			if (connection != null) {
				connection.disconnect();
			}
		}
		return true;
	} catch (Exception e) {
		HadoopUtils.addAndLogError(LOG, clusterConfig,
				"Could not configure passwordless SSH for Hadoop",
				Constant.Component.Name.HADOOP, e);
		return false;
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:37,代码来源:Hadoop1Configurator.java

示例5: run

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
public void run() {

		try {
			ClusterConfig clusterConfig = new DBClusterManager().getCluster(
					clusterId).getClusterConfig();

			// Create servicebale object
			Serviceable serviceable = ObjectFactory.getServiceObject(component);

			// Connect to node
			AnkushUtils.connectNodesString(clusterConfig, Arrays.asList(node));

			// Start service
			serviceable.startServices(clusterConfig, node, new HashSet<String>(
					Arrays.asList(service)));

			// Disconnect node
			SSHExec connection = clusterConfig.getNodes().get(node)
					.getConnection();
			if (connection != null) {
				connection.disconnect();
				clusterConfig.getNodes().get(node).setConnection(null);
			}

		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}

		// Reduce try count
		tryCount--;
		logger.info(getId(clusterId, node, component, service) + " " + tryCount
				+ " try remains.");
		// Stop scheduler if trial count reach to zero
		if (tryCount == 0) {
			removeHAService(clusterId, node, component, service);
		}
	}
 
开发者ID:Impetus,项目名称:ankush,代码行数:38,代码来源:HAServiceExecutor.java

示例6: getMachineHostName

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
public static String getMachineHostName(String host, String username,
		String password, String privateKey) {

	SSHExec connection = null;
	try {
		connection = SSHUtils.connectToNode(host, username, password,
				privateKey);
		if (connection == null) {
			return "";
		}
		CustomTask task = new ExecCommand(
				Constant.SystemCommands.GETHOSTNAME);
		Result res = connection.exec(task);
		if (res.isSuccess) {
			if (!res.sysout.isEmpty()) {
				return res.sysout.trim().replaceAll("\n", "");
			}
		}
	} catch (Exception e) {
		return "";
	} finally {
		if (connection != null) {
			connection.disconnect();
		}
	}
	return "";
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:28,代码来源:HostOperation.java

示例7: disconnectNodesString

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
public static void disconnectNodesString(ClusterConfig clusterConfig,
		Collection<String> hostList) {
	for (String host : hostList) {
		NodeConfig nodeConf = clusterConfig.getNodes().get(host);
		SSHExec connection = nodeConf.getConnection();
		if (connection != null) {
			connection.disconnect();
		}
		nodeConf.setConnection(null);
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:12,代码来源:AnkushUtils.java

示例8: disconnectCompNodes

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
public static void disconnectCompNodes(ClusterConfig clusterConfig,
		Collection<String> hostList) {
	for (String host : hostList) {
		NodeConfig nodeConf = clusterConfig.getNodes().get(host);
		SSHExec connection = nodeConf.getConnection();
		if (connection != null) {
			connection.disconnect();
		}
		nodeConf.setConnection(null);
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:12,代码来源:AnkushUtils.java

示例9: disconnectNodes

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
public static void disconnectNodes(ClusterConfig clusterConfig,
		Collection<NodeConfig> nodeConfList) {
	for (NodeConfig nodeConf : nodeConfList) {
		SSHExec connection = nodeConf.getConnection();
		if (connection != null) {
			connection.disconnect();
		}
		nodeConf.setConnection(null);
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:11,代码来源:AnkushUtils.java

示例10: addParameter

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
private void addParameter(String hostName, String propertyName,
		String propertyValue, String propertyFilePath, String fileType,
		String loggedUser, String fileName) {
	Result res = null;
	ConfigurationManager confManager = new ConfigurationManager();
	SSHExec connection = null;
	try {
		// connect to node/machine
		connection = SSHUtils.connectToNode(hostName,
				clusterConf.getAuthConf());
		// if connection is established.
		if (connection == null) {
			throw new AnkushException("Could not connect to node: "
					+ hostName + ".");
		}
		AnkushTask add = new AddConfProperty(propertyName, propertyValue,
				propertyFilePath, fileType);
		res = connection.exec(add);
		if (res.isSuccess) {
			// Configuration manager to save the
			// property file change records.
			confManager.saveConfiguration(dbCluster.getId(), loggedUser,
					fileName, hostName, propertyName, propertyValue);
		}
	} catch (Exception e) {
		addAndLogError(e.getMessage());
	} finally {
		// Disconnecting the connection
		if (connection != null) {
			connection.disconnect();
		}
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:34,代码来源:CassandraClusterMonitor.java

示例11: editParameter

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
private void editParameter(String host, String propertyName,
		String newValue, String propertyFilePath, String fileType,
		String loggedUser, String fileName) {
	Result res = null;
	ConfigurationManager confManager = new ConfigurationManager();
	SSHExec connection = null;
	try {
		// connect to node/machine
		connection = SSHUtils
				.connectToNode(host, clusterConf.getAuthConf());
		// if connection is established.
		if (connection == null) {
			throw new AnkushException("Could not connect to node: " + host
					+ ".");
		}
		AnkushTask update = new EditConfProperty(propertyName, newValue,
				propertyFilePath, fileType);
		res = connection.exec(update);
		if (res.isSuccess) {
			// Configuration manager to save the
			// property file change records.
			confManager.saveConfiguration(dbCluster.getId(), loggedUser,
					fileName, host, propertyName, newValue);
		}
	} catch (Exception e) {
		addAndLogError(e.getMessage());
	} finally {
		// Disconnecting the connection
		if (connection != null) {
			connection.disconnect();
		}
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:34,代码来源:CassandraClusterMonitor.java

示例12: deleteParameter

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
private void deleteParameter(String host, String propertyName,
		String propertyFilePath, String fileType, String fileName) {
	Result res = null;
	ConfigurationManager confManager = new ConfigurationManager();
	SSHExec connection = null;
	try {
		connection = SSHUtils
				.connectToNode(host, clusterConf.getAuthConf());
		if (connection == null) {
			throw new AnkushException("Could not connect to node.");
		}
		AnkushTask update = new DeleteConfProperty(propertyName,
				propertyFilePath, fileType);
		res = connection.exec(update);
		if (res.isSuccess) {
			confManager.removeOldConfiguration(dbCluster.getId(), host,
					fileName, propertyName);
		}
	} catch (Exception e) {
		addAndLogError(e.getMessage());
	} finally {
		// Disconnecting the connection
		if (connection != null) {
			connection.disconnect();
		}
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:28,代码来源:CassandraClusterMonitor.java

示例13: postNodeService

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
private void postNodeService(String host) {
	// Disconnect node
	SSHExec connection = clusterConfig.getNodes().get(host).getConnection();
	if (connection != null) {
		connection.disconnect();
		clusterConfig.getNodes().get(host).setConnection(null);
	}
	// updating operation completion time and status
	updateOperationProgress();
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:11,代码来源:ServiceManager.java

示例14: setupPasswordlessSSH

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
@Override
public boolean setupPasswordlessSSH(Set<String> nodes) {
	try {
		LOG.info("Configuring Passwordless SSH for Hadoop 2.x cluster",
				Constant.Component.Name.HADOOP);

		if (!this.generateRsaKeysForHadoopNodes(nodes)) {
			return false;
		}

		Set<String> sourceHosts = new HashSet<String>();
		sourceHosts.add(HadoopUtils.getNameNodeHost(this.compConfig));
		sourceHosts
				.add(HadoopUtils.getResourceManagerHost(this.compConfig));

		boolean isHaEnabled = (Boolean) this.compConfig
				.getAdvanceConfProperty(HadoopConstants.AdvanceConfKeys.HA_ENABLED);

		if (isHaEnabled) {
			sourceHosts.add(HadoopUtils
					.getActiveNameNodeHost(this.compConfig));
			sourceHosts.add(HadoopUtils
					.getStandByNameNodeHost(this.compConfig));
		}

		for (String sourceHost : sourceHosts) {
			if (this.clusterConfig.getNodes().containsKey(sourceHost)) {
				if (!HadoopUtils.setupPasswordlessSSH(LOG,
						this.clusterConfig, sourceHost, nodes)) {
					return false;
				}
			} else {
				SSHExec connection = SSHUtils.connectToNode(sourceHost,
						this.clusterConfig.getAuthConf());
				if (!HadoopUtils.setupPasswordlessSSH(LOG,
						this.clusterConfig, sourceHost, nodes, connection)) {
					return false;
				}
				if (connection != null) {
					connection.disconnect();
				}
			}
		}

		return true;
	} catch (Exception e) {
		HadoopUtils.addAndLogError(LOG, clusterConfig,
				"Could not configure passwordless SSH for Hadoop",
				Constant.Component.Name.HADOOP, e);
		return false;
	}
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:53,代码来源:Hadoop2Configurator.java

示例15: addNode

import net.neoremind.sshxcute.core.SSHExec; //导入方法依赖的package包/类
@Override
public boolean addNode(NodeConfig nodeConfig) {
	SSHExec namenodeConnection = null;
	try {
		LOG.info(
				"Copying HADOOP_HOME from NameNode to "
						+ nodeConfig.getHost(),
				Constant.Component.Name.HADOOP, nodeConfig.getHost());

		AnkushTask ankushTask = new MakeDirectory(
				this.compConfig.getHomeDir());
		if (nodeConfig.getConnection().exec(ankushTask).rc != 0) {
			HadoopUtils.addAndLogError(LOG, clusterConfig,
					"Could not create HADOOP_HOME directory - "
							+ this.compConfig.getHomeDir(),
					Constant.Component.Name.HADOOP, nodeConfig.getHost());
			return false;
		}

		LOG.info(
				"Connecting to NameNode - "
						+ HadoopUtils.getNameNodeHost(this.compConfig),
				Constant.Component.Name.HADOOP,
				HadoopUtils.getNameNodeHost(this.compConfig));

		namenodeConnection = SSHUtils.connectToNode(
				HadoopUtils.getNameNodeHost(this.compConfig),
				clusterConfig.getAuthConf());

		ankushTask = new SyncFolder(nodeConfig.getHost(),
				this.compConfig.getHomeDir());

		if (namenodeConnection.exec(ankushTask).rc != 0) {
			HadoopUtils.addAndLogError(LOG, clusterConfig,
					"Could not copy HADOOP_HOME directory from NameNode- "
							+ this.compConfig.getHomeDir(),
					Constant.Component.Name.HADOOP, nodeConfig.getHost());
			return false;
		}
	} catch (Exception e) {
		HadoopUtils.addAndLogError(LOG, clusterConfig,
				"Could not copy HADOOP_HOME directory from NameNode- "
						+ this.compConfig.getHomeDir(),
				Constant.Component.Name.HADOOP, nodeConfig.getHost(), e);
		return false;
	} finally {
		if (namenodeConnection != null) {
			namenodeConnection.disconnect();
		}
	}
	return true;
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:53,代码来源:HadoopBundleInstaller.java


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