From aa168f465f1004cf29d72f924b3dfefb66581c7b Mon Sep 17 00:00:00 2001 From: anovikov Date: Wed, 25 Mar 2015 10:12:15 +0700 Subject: [PATCH 1/2] # ignite-573 Fixed javadoc. --- .../visor/commands/deploy/VisorDeployCommand.scala | 98 +++++++++------------- 1 file changed, 40 insertions(+), 58 deletions(-) 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%") } /** -- 2.1.2 From 70475a237e6ae5434d0d98b5b909d92acdc24b5f Mon Sep 17 00:00:00 2001 From: anovikov Date: Wed, 25 Mar 2015 10:42:18 +0700 Subject: [PATCH 2/2] # ignite-573 Fixed javadoc. --- .../apache/ignite/visor/commands/deploy/VisorDeployCommand.scala | 8 ++++---- .../apache/ignite/visor/commands/tasks/VisorTasksCommand.scala | 8 +------- 2 files changed, 5 insertions(+), 11 deletions(-) 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 7c3dcc1..3856672 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 @@ -414,7 +414,7 @@ class VisorDeployCommand { val port = try - if (hostPort.size > 1) hostPort(1).toInt else DFLT_PORT + if (hostPort.length > 1) hostPort(1).toInt else DFLT_PORT catch { case e: NumberFormatException => scold("Invalid port number: " + hostPort(1)).^^ @@ -429,7 +429,7 @@ class VisorDeployCommand { (hosts, port) } - if (arr.size == 1) { + if (arr.length == 1) { val (hosts, port) = extractHostsPort(arr(0)) val uname = dfltUname getOrElse System.getProperty("user.name") @@ -437,7 +437,7 @@ class VisorDeployCommand { hosts.map(VisorHost(_, port, uname, passwd)) } - else if (arr.size == 2) { + else if (arr.length == 2) { val (hosts, port) = extractHostsPort(arr(1)) arr = arr(0).split(':') @@ -445,7 +445,7 @@ class VisorDeployCommand { val uname = arr(0) val passwd = - if (arr.size > 1) + if (arr.length > 1) Some(arr(1)) else if (!hasKey) Some(dfltPasswd getOrElse askPassword(uname)) diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala index 723c135..9d9dde0 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala @@ -536,13 +536,7 @@ class VisorTasksCommand { }) } - /** - * If task name is task class name, show simple class name. - * - * @param taskName Task name. - * @param taskClsName Task class name. - * @return Simple class name. - */ + // If task name is task class name, show simple class name. def taskSimpleName(taskName: String, taskClsName: String) = { if (taskName == taskClsName || taskName == null) { val idx = taskClsName.lastIndexOf('.') -- 2.1.2