You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by pr...@apache.org on 2015/08/11 14:20:39 UTC
[16/50] [abbrv] incubator-lens git commit: LENS-16 : Add command to
show current sessionId from lens-cli
LENS-16 : Add command to show current sessionId from lens-cli
Project: http://git-wip-us.apache.org/repos/asf/incubator-lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-lens/commit/3ce889fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-lens/tree/3ce889fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-lens/diff/3ce889fc
Branch: refs/heads/current-release-line
Commit: 3ce889fcb4c350b4c306c6b84a15b2b21fbba2aa
Parents: 211ef3b
Author: Rajat Khandelwal <pr...@apache.org>
Authored: Mon Jul 27 16:57:28 2015 +0530
Committer: arshad-matin <ar...@apache.org>
Committed: Mon Jul 27 16:57:28 2015 +0530
----------------------------------------------------------------------
.../cli/commands/LensConnectionCommands.java | 33 ++++++++++++++------
.../lens/cli/TestLensConnectionCliCommands.java | 21 +++++++++++--
src/site/apt/user/cli.apt | 2 ++
3 files changed, 43 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/3ce889fc/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
index 8b4face..c059f30 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
@@ -24,8 +24,8 @@ import java.util.List;
import javax.ws.rs.ProcessingException;
import org.apache.lens.api.APIResult;
+import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.cli.commands.annotations.UserDocumentation;
-
import org.apache.lens.client.LensClient;
import org.apache.log4j.*;
@@ -36,7 +36,6 @@ import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
import com.google.common.base.Joiner;
-
import lombok.extern.slf4j.Slf4j;
@@ -158,14 +157,28 @@ public class LensConnectionCommands extends BaseLensCommand {
}
/**
+ * Get the current session handle
+ */
+ @CliCommand(value = {"session"}, help = "Print the current session handle")
+ public String getSessionHandle() {
+ LensSessionHandle sessionHandle = getClient().getConnection().getSessionHandle();
+ if (sessionHandle != null) {
+ return "Session Handle: " + sessionHandle.getPublicId();
+ } else {
+ return "Session not established";
+ }
+ }
+
+ /**
* Enables to show all class level logs on cli
* @param enable
*/
- @CliCommand(value = {"debug"}, help = "prints all class level logs and verbose logs on cli for debugging purpose."
- + " 'debug false' to turn off all class level logging and verbose level logging ")
+ @CliCommand(value = {"debug"},
+ help = "prints all class level logs and verbose logs on cli for debugging purpose."
+ + " 'debug false' to turn off all class level logging and verbose level logging ")
public void debug(@CliOption(key = {"", "enable"},
- mandatory = false, unspecifiedDefaultValue = "true",
- help = "To print all logs on cli for debugging purpose") boolean enable) {
+ mandatory = false, unspecifiedDefaultValue = "true",
+ help = "To print all logs on cli for debugging purpose") boolean enable) {
Logger logger = LoggerUtil.getRootLogger();
Logger cliLogger = LoggerUtil.getCliLogger();
if (enable) {
@@ -181,11 +194,11 @@ public class LensConnectionCommands extends BaseLensCommand {
* Enables to show only cliLogger(verbose) logs on cli
* @param enable
*/
- @CliCommand(value = {"verbose"}, help = "Show cliLogger logs on cli"
- + "'verbose false' turns off the cliLogger logs on console")
+ @CliCommand(value = {"verbose"},
+ help = "Show cliLogger logs on cli. 'verbose false' turns off the cliLogger logs on console")
public void verbose(@CliOption(key = {"", "enable"},
- mandatory = false, unspecifiedDefaultValue = "true",
- help = "Print the clilogger logs on cli") boolean enable) {
+ mandatory = false, unspecifiedDefaultValue = "true",
+ help = "Print the clilogger logs on cli") boolean enable) {
Logger cliLogger = LoggerUtil.getCliLogger();
if (enable) {
LoggerUtil.addConsoleAppenderIfNotPresent(cliLogger);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/3ce889fc/lens-cli/src/test/java/org/apache/lens/cli/TestLensConnectionCliCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensConnectionCliCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensConnectionCliCommands.java
index 7503221..ae04b3f 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensConnectionCliCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensConnectionCliCommands.java
@@ -24,6 +24,7 @@ import java.net.URI;
import javax.ws.rs.BadRequestException;
+import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.cli.commands.LensConnectionCommands;
import org.apache.lens.client.LensClient;
@@ -89,10 +90,10 @@ public class TestLensConnectionCliCommands extends LensCliApplicationTest {
return f;
}
- private String getFilePathFromUri(String uripath){
+ private String getFilePathFromUri(String uripath) {
try {
return new URI(uripath).getPath();
- } catch (Exception e){
+ } catch (Exception e) {
return null;
}
}
@@ -172,7 +173,7 @@ public class TestLensConnectionCliCommands extends LensCliApplicationTest {
/* Tests input file pattern file: and file:// */
String filenameA = "file:" + projectdir + "/target/tempdata_a.txt";
- String filenameB = "file://" + projectdir +"/target/tempdata_b.txt";
+ String filenameB = "file://" + projectdir + "/target/tempdata_b.txt";
String fileRegex = "file:" + projectdir + "/target/tempdata_*.txt";
@@ -327,4 +328,18 @@ public class TestLensConnectionCliCommands extends LensCliApplicationTest {
commands.quitShell();
}
}
+
+ /**
+ * Test CLI command to get session handle
+ */
+ @Test
+ public void testGetSessionHandle() {
+ LensClient client = new LensClient();
+ LensConnectionCommands commands = new LensConnectionCommands();
+ commands.setClient(client);
+ LensSessionHandle sessionHandle = client.getConnection().getSessionHandle();
+ Assert.assertNotNull(sessionHandle);
+ String output = commands.getSessionHandle();
+ Assert.assertTrue(output.contains(sessionHandle.getPublicId().toString()), "session handle output: " + output);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/3ce889fc/src/site/apt/user/cli.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/user/cli.apt b/src/site/apt/user/cli.apt
index 51257e0..a28d8a4 100644
--- a/src/site/apt/user/cli.apt
+++ b/src/site/apt/user/cli.apt
@@ -102,6 +102,8 @@ User CLI Commands
*--+--+
|remove jar [--path] \<path-to-jar-on-server-side\>|Removes a jar resource from session|
*--+--+
+|session|Print the current session handle|
+*--+--+
|set \<key\>=\<value\>|Assign <<<value>>> to session parameter specified with <<<key>>> on lens server|
*--+--+
|show params|Fetches and prints all session parameter from lens server|