sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject [1/6] SQOOP-921. Sqoop2: Create standalone shell package
Date Tue, 06 Aug 2013 23:21:59 GMT
Updated Branches:
  refs/heads/sqoop2 0d4efda17 -> 21c1207b7 (forced update)


http://git-wip-us.apache.org/repos/asf/sqoop/blob/21c1207b/shell/src/main/java/org/apache/sqoop/shell/utils/ThrowableDisplayer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ThrowableDisplayer.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ThrowableDisplayer.java
new file mode 100644
index 0000000..6026a95
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ThrowableDisplayer.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import groovy.lang.MissingPropertyException;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.shell.core.ShellError;
+
+import static org.apache.sqoop.shell.ShellEnvironment.*;
+
+/**
+ * Pretty printing of Throwable objects
+ */
+public class ThrowableDisplayer {
+
+  /**
+   * Error hook installed to Groovy shell.
+   *
+   * Will display exception that appeared during executing command. In most
+   * cases we will simply delegate the call to printing throwable method,
+   * however in case that we've received ClientError.CLIENT_0006 (server
+   * exception), we will unwrap server issue and view only that as local
+   * context shouldn't make any difference.
+   *
+   * @param t Throwable to be displayed
+   */
+  public static void errorHook(Throwable t) {
+    println("@|red Exception has occurred during processing command |@");
+
+    // If this is server exception from server
+    if(t instanceof SqoopException
+      && ((SqoopException)t).getErrorCode() == ShellError.SHELL_0006) {
+      print("@|red Server has returned exception: |@");
+      printThrowable(t.getCause(), isVerbose());
+    } else if(t.getClass() == MissingPropertyException.class) {
+      print("@|red Unknown command: |@");
+      println(t.getMessage());
+    } else {
+      printThrowable(t, isVerbose());
+    }
+  }
+
+  /**
+   * Pretty print Throwable instance including stack trace and causes.
+   *
+   * @param t Throwable to display
+   */
+  protected static void printThrowable(Throwable t, boolean verbose) {
+    print("@|red Exception: |@");
+    print(t.getClass().getName());
+    print(" @|red Message: |@");
+    print(t.getMessage());
+    println();
+
+    if(verbose) {
+      println("Stack trace:");
+      for(StackTraceElement e : t.getStackTrace()) {
+        print("\t @|bold at |@ ");
+        print(e.getClassName());
+        print(" (@|bold " + e.getFileName() + ":" + e.getLineNumber() + ") |@ ");
+        println();
+      }
+
+      Throwable cause = t.getCause();
+      if(cause != null) {
+        print("Caused by: ");
+        printThrowable(cause, verbose);
+      }
+    }
+  }
+
+  private ThrowableDisplayer() {
+    // Instantiation is prohibited
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/21c1207b/shell/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/log4j.properties b/shell/src/main/resources/log4j.properties
new file mode 100644
index 0000000..af7e9f3
--- /dev/null
+++ b/shell/src/main/resources/log4j.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=WARN, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

http://git-wip-us.apache.org/repos/asf/sqoop/blob/21c1207b/shell/src/main/resources/shell-resource.properties
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/shell-resource.properties b/shell/src/main/resources/shell-resource.properties
new file mode 100644
index 0000000..1a8f963
--- /dev/null
+++ b/shell/src/main/resources/shell-resource.properties
@@ -0,0 +1,232 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Client Resources in default language (english)
+
+############################
+# Security Form
+#
+object-name.label = Name
+object-name.help = Non unique name of the entity to help you remember \
+                   it's purpose
+
+
+#############################
+# Messages
+#
+# Argument related
+#
+args.function.unknown = The specified function "{0}" is not recognized.
+args.xid_missing = Required argument --xid is missing.
+args.jid_missing = Required argument --jid is missing.
+args.cid_missing = Required argument --cid is missing.
+args.type_missing = Required argument --type is missing.
+args.name_missing = Required argument --name is missing.
+args.value_missing = Required argument --value is missing.
+
+
+## Generic description of various ids, types etc
+prompt.conn_id = Connection ID
+prompt.connector_id = Connector ID
+prompt.job_id = Job ID
+prompt.job_type = Job type
+
+## Prompt messages for updating, filling metadata info
+
+prompt.update_conn_metadata = Please update connection metadata:
+prompt.update_job_metadata = Please update job metadata:
+prompt.fill_conn_metadata = Please fill following values to create new \
+connection object
+prompt.fill_job_metadata = Please fill following values to create new \
+job object
+
+#
+# Update command
+update.conn = Updating connection with id {0}
+update.job = Updating job with id {0}
+update.usage = Usage: update {0}
+update.conn_successful = Connection was successfully updated with status {0}
+update.job_successful = Job was successfully updated with status {0}
+
+#
+# Clone command
+clone.usage = Usage: clone {0}
+clone.conn.successful = Connection was successfully created with validation \
+  status {0} and persistent id {1}
+clone.job.successful = Job was successfully created with validation \
+  status {0} and persistent id {1}
+clone.cloning_conn = Cloning connection with id {0}
+clone.cloning_job = Cloning job with id {0}
+
+#
+# Create command
+create.usage = Usage: create {0}
+create.conn_successful = New connection was successfully created with \
+  validation status {0} and persistent id {1}
+create.job_successful = New job was successfully created with validation \
+  status {0}  and persistent id {1}
+## Creating messages
+create.creating_conn = Creating connection for connector with id {0}
+create.creating_job = Creating job for connection with id {0}
+
+#
+# Delete command
+delete.usage = Usage: delete {0}
+
+#
+# Enable command
+enable.usage = Usage: enable {0}
+enable.conn_successful = Connection {0} was successfully enabled
+enable.job_successful = Job {0} was successfully enabled
+
+#
+# Disable command
+disable.usage = Usage: disable {0}
+disable.conn_successful = Connection {0} was successfully disabled
+disable.job_successful = Job {0} was successfully disabled
+
+#
+# Help command
+help.usage = [<command>]
+help.description = Display this help message
+help.cmd_usage = Usage: @|bold {0} |@ {1}
+help.message = Display the list of commands or the help text for \
+ @|bold command|@.
+help.info = For information about @|green Sqoop|@, visit: \
+  @|cyan http://sqoop.apache.org/|@
+help.avail_commands = Available commands:
+help.cmd_description =  @|bold {0} ({1}|@) {2}
+help.specific_cmd_info = For help on a specific command type: \
+  help @|bold command|@
+
+unrecognized.cmd = Unrecognized command {0}
+
+#
+# Set command
+set.usage = Usage: set {0}
+set.prompt_opt_name = Client option name
+set.prompt_opt_value = New option value
+set.verbose_changed = Verbose option was changed to {0}
+set.poll_timeout_changed = Poll timeout option has been changed to {0}
+set.unknown_opt_ignored = Unknown option {0}. Ignoring...
+set.host_description = Host name to invoke server resources
+set.port_description = Port number to invoke server resources
+set.webapp_description = Web app to invoke server resources
+set.url_description = Url to invoke server resources
+set.server_usage = Usage: set server
+set.server_successful = Server is set successfully
+set.server_ignored = --host, --port or --webapp option is ignored, because --url option is
given.
+
+
+show.usage = Usage: show {0}
+
+show.prompt_display_all_conns = Display all connections
+show.prompt_display_conn_xid = Display the connection with xid
+show.conn_usage = Usage: show connection
+show.prompt_conns_to_show = @|bold {0} connection(s) to show: |@
+show.prompt_conn_info = Connection with id {0} and name {1} (Enabled: {2}, Created {3}, Updated
{4})
+show.prompt_conn_cid_info = Using Connector id {0}
+
+show.prompt_display_all_connectors = Display all connectors
+show.prompt_display_connector_cid = Display the connector with cid
+show.connector_usage = Usage: show connector
+show.prompt_connectors_to_show = @|bold {0} connector(s) to show: |@
+show.prompt_connector_info = Connector with id {0}:\n  Name: {1} \n \
+Class: {2}\n  Version: {3}
+
+show.framework_usage = Usage: show framework
+show.prompt_framework_opts = @|bold Framework specific options: |@\nPersistent id: {0}
+
+show.prompt_display_all_jobs = Display all jobs
+show.prompt_display_job_jid = Display jobwith given jid
+show.job_usage = Usage: show job
+show.prompt_jobs_to_show = @|bold {0} job(s) to show: |@
+show.prompt_job_info = Job with id {0} and name {1} (Enabled: {2}, Created {3}, Updated {4})
+show.prompt_job_xid_cid_info = Using Connection id {0} and Connector id {1}
+
+show.prompt_display_all_submissions = Display all submissions
+show.prompt_display_all_submissions_jid = Display all submissions given jid
+
+show.prompt_display_all_servers = Display all server information
+show.prompt_display_server_host = Display server host name
+show.prompt_display_server_port = Display server port number
+show.prompt_display_server_webapp = Display server web app name
+show.server_usage = Usage: show server
+show.prompt_server_host = @|bold Server host:|@ {0}
+show.prompt_server_port = @|bold Server port:|@ {0}
+show.prompt_server_webapp = @|bold Server webapp:|@ {0}
+
+show.prompt_display_all_versions = Display all versions
+show.prompt_display_version_server = Display server version
+show.prompt_display_version_client = Display client version
+show.prompt_display_version_protocol = Display protocol version
+show.version_usage = Usage: show version
+show.prompt_version_client_server = @|bold {0} version:|@\n  Sqoop {1} \
+revision {2} \n  Compiled by {3} on {4}
+show.prompt_version_protocol = @|bold Protocol version:|@\n  {0}
+
+sqoop.shell_banner = @|green Sqoop Shell:|@ Type '@|bold help|@' or '@|bold \\h|@' for help.
+sqoop.prompt_shell_loadrc = Loading resource file {0}
+sqoop.prompt_shell_loadedrc = Resource file loaded.
+
+start.usage = Usage: start {0}
+start.prompt_synchronous = Wait for submission to finish
+
+stop.usage = Usage: stop  {0}
+
+status.usage = Usage: status {0}
+
+# Various Table headers
+table.header.id = Id
+table.header.name = Name
+table.header.version = Version
+table.header.class = Class
+table.header.type = Type
+table.header.connector = Connector
+table.header.jid = Job Id
+table.header.eid = External Id
+table.header.status = Status
+table.header.date = Last Update Date
+table.header.enabled = Enabled
+
+#Form displayer resources
+formdisplayer.supported_job_types = Supported job types
+formdisplayer.connection = Connection
+formdisplayer.job = Job
+formdisplayer.forms_jobtype = Forms for job type
+formdisplayer.form = form
+formdisplayer.name = Name
+formdisplayer.label = Label
+formdisplayer.help = Help
+formdisplayer.input = Input
+formdisplayer.type = Type
+formdisplayer.sensitive = Sensitive
+formdisplayer.size = Size
+formdisplayer.possible_values = Possible values
+formdisplayer.unsupported_datatype = Unsupported data type
+formdisplayer.input_sensitive = This input is sensitive
+
+formdisplayer.warning_message = There were warnings while create or update, but saved successfully.
+
+submission.submission_detail = Submission details
+submission.job_id = Job ID
+submission.creation_date = Creation date
+submission.external_id = External ID
+submission.progress_not_available = Progress is not available
+submission.counters = Counters
+submission.executed_success = Job executed successfully
+submission.server_url = Server URL
+submission.connector_schema = Connector schema
+submission.hio_schema = Input/Output schema

http://git-wip-us.apache.org/repos/asf/sqoop/blob/21c1207b/shell/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/shell/src/test/resources/log4j.properties b/shell/src/test/resources/log4j.properties
new file mode 100644
index 0000000..44ffced
--- /dev/null
+++ b/shell/src/test/resources/log4j.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=DEBUG, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


Mime
View raw message