Repository: incubator-ignite Updated Branches: refs/heads/sprint-3 b53e53188 -> 3d19a1dee
# ignite-573 Fixed javadoc. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/aa168f46 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/aa168f46 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/aa168f46 Branch: refs/heads/sprint-3 Commit: aa168f465f1004cf29d72f924b3dfefb66581c7b Parents: 740d4be Author: anovikov <anovi...@gridgain.com> Authored: Wed Mar 25 10:12:15 2015 +0700 Committer: anovikov <anovi...@gridgain.com> Committed: Wed Mar 25 10:12:15 2015 +0700 ---------------------------------------------------------------------- .../commands/deploy/VisorDeployCommand.scala | 98 ++++++++------------ 1 file changed, 40 insertions(+), 58 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa168f46/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommand.scala index 3cea592..7c3dcc1 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommand.scala @@ -20,6 +20,7 @@ package org.apache.ignite.visor.commands.deploy import org.apache.ignite.internal.util.io.GridFilenameUtils import org.apache.ignite.internal.util.typedef.X import org.apache.ignite.internal.util.{IgniteUtils => U} +import org.apache.ignite.internal.util.lang.{GridFunc => F} import com.jcraft.jsch._ @@ -142,92 +143,73 @@ private case class VisorCopier( * @return `IGNITE_HOME` value. */ private def ggHome(): String = { - /** - * Non interactively execute command. - * - * @param cmd command. - * @return command results - */ + // Non interactively execute command. def exec(cmd: String) = { - val ch = ses.openChannel("exec").asInstanceOf[ChannelExec] - try { - ch.setCommand(cmd) + val ch = ses.openChannel("exec").asInstanceOf[ChannelExec] + + try { + ch.setCommand(cmd) - ch.connect() + ch.connect() - new BufferedReader(new InputStreamReader(ch.getInputStream)).readLine + new BufferedReader(new InputStreamReader(ch.getInputStream)).readLine + } + finally { + if (ch.isConnected) + ch.disconnect() + } } catch { - case e: JSchException => + case e: Throwable => warn(e.getMessage) "" } - finally { - if (ch.isConnected) - ch.disconnect() - } } - /** - * Interactively execute command. - * - * @param cmd command. - * @return command results. - */ - def shell(cmd: String): String = { - val ch = ses.openChannel("shell").asInstanceOf[ChannelShell] - + // Interactively execute command. + def shell(cmd: String) = { try { - ch.connect() + val ch = ses.openChannel("shell").asInstanceOf[ChannelShell] - // Added to skip login message. - U.sleep(1000) + try { + ch.connect() + + // Added to skip login message. + U.sleep(1000) - val writer = new PrintStream(ch.getOutputStream, true) + val writer = new PrintStream(ch.getOutputStream, true) - val reader = new BufferedReader(new InputStreamReader(ch.getInputStream)) + val reader = new BufferedReader(new InputStreamReader(ch.getInputStream)) - // Send command. - writer.println(cmd) + // Send command. + writer.println(cmd) - // Read echo command. - reader.readLine() + // Read echo command. + reader.readLine() - // Read command result. - reader.readLine() + // Read command result. + reader.readLine() + } + finally { + if (ch.isConnected) + ch.disconnect() + } } catch { - case e: JSchException => + case e: Throwable => warn(e.getMessage) "" } - finally { - if (ch.isConnected) - ch.disconnect() - } } - /** - * Checks whether host is running Windows OS. - * - * @return Whether host is running Windows OS. - * @throws JSchException In case of SSH error. - */ - def windows = { - try - exec("cmd.exe") != null - catch { - case ignored: IOException => false - } - } - - if (windows) - exec("echo %IGNITE_HOME%") + // Use interactive shell under nix because need read env from .profile and etc. + if (F.isEmpty(exec("cmd.exe"))) + shell("echo $IGNITE_HOME") else - shell("echo $IGNITE_HOME") // Use interactive shell under nix because need read env from .profile and etc. + exec("echo %IGNITE_HOME%") } /**