sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1377752 - in /sqoop/branches/sqoop2: client/src/main/java/org/apache/sqoop/client/shell/ common/src/main/java/org/apache/sqoop/json/ core/src/main/java/org/apache/sqoop/framework/ server/src/main/webapp/WEB-INF/
Date Mon, 27 Aug 2012 17:16:19 GMT
Author: blee
Date: Mon Aug 27 17:16:19 2012
New Revision: 1377752

URL: http://svn.apache.org/viewvc?rev=1377752&view=rev
Log:
SQOOP-576 Implement command show framework

Modified:
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
    sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java?rev=1377752&r1=1377751&r2=1377752&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
Mon Aug 27 17:16:19 2012
@@ -28,10 +28,11 @@ public class ShowCommand extends SqoopCo
   private ShowServerFunction serverFunction;
   private ShowVersionFunction versionFunction;
   private ShowConnectorFunction connectorFunction;
+  private ShowFrameworkFunction frameworkFunction;
 
   protected ShowCommand(Shell shell) {
     super(shell, "show", "\\sh",
-        new String[] {"server", "version", "connector"},
+        new String[] {"server", "version", "connector", "framework"},
         "Show", "info");
   }
 
@@ -63,6 +64,12 @@ public class ShowCommand extends SqoopCo
       }
       return connectorFunction.execute(args);
 
+    } else if (func.equals("framework")) {
+      if (frameworkFunction == null) {
+        frameworkFunction = new ShowFrameworkFunction(io);
+      }
+      return frameworkFunction.execute(args);
+
     } else if (func.equals("connection")) {
       return null;
 
@@ -74,4 +81,4 @@ public class ShowCommand extends SqoopCo
       throw new SqoopException(ClientError.CLIENT_0002, msg);
     }
   }
-}
\ No newline at end of file
+}

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java?rev=1377752&r1=1377751&r2=1377752&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
Mon Aug 27 17:16:19 2012
@@ -18,7 +18,6 @@
 package org.apache.sqoop.client.shell;
 
 import java.io.PrintWriter;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.cli.CommandLine;
@@ -27,13 +26,11 @@ import org.apache.sqoop.client.core.Envi
 import org.apache.sqoop.client.request.ConnectorRequest;
 import org.apache.sqoop.json.ConnectorBean;
 import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MInputType;
 import org.apache.sqoop.model.MJobForms;
-import org.apache.sqoop.model.MStringInput;
 import org.codehaus.groovy.tools.shell.IO;
 
+import static org.apache.sqoop.client.display.FormDisplayer.*;
+
 @SuppressWarnings("serial")
 public class ShowConnectorFunction extends SqoopFunction
 {
@@ -100,57 +97,11 @@ public class ShowConnectorFunction exten
       io.out.println(connector.getUniqueName());
       io.out.print("  Class: ");
       io.out.println(connector.getClassName());
-      io.out.print("  Supported job types: ");
-      io.out.println(connector.getAllJobsForms().keySet().toString());
-
-      displayForms(connector.getConnectionForms().getForms(), "Connection");
 
-      for (MJobForms jobForms : connector.getAllJobsForms().values()) {
-        io.out.print("  Forms for jobForms type ");
-        io.out.print(jobForms.getType().name());
-        io.out.println(":");
+      displayFormDetails(io, connector);
 
-        displayForms(jobForms.getForms(), "Job");
-      }
     }
 
     io.out.println();
   }
-
-  private void displayForms(List<MForm> forms, String type) {
-    Iterator<MForm> fiter = forms.iterator();
-    int findx = 1;
-    while (fiter.hasNext()) {
-      io.out.print("    ");
-      io.out.print(type);
-      io.out.print(" form ");
-      io.out.print(findx++);
-      io.out.println(":");
-
-      MForm form = fiter.next();
-      io.out.print("      Name: ");
-      io.out.println(form.getName());
-
-      List<MInput<?>> inputs = form.getInputs();
-      Iterator<MInput<?>> iiter = inputs.iterator();
-      int iindx = 1;
-      while (iiter.hasNext()) {
-        io.out.print("      Input ");
-        io.out.print(iindx++);
-        io.out.println(":");
-
-        MInput<?> input = iiter.next();
-        io.out.print("        Name: ");
-        io.out.println(input.getName());
-        io.out.print("        Type: ");
-        io.out.println(input.getType());
-        if (input.getType() == MInputType.STRING) {
-          io.out.print("        Mask: ");
-          io.out.println(((MStringInput)input).isMasked());
-          io.out.print("        Size: ");
-          io.out.println(((MStringInput)input).getMaxLength());
-        }
-      }
-    }
-  }
 }

Modified: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java?rev=1377752&r1=1377751&r2=1377752&view=diff
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java (original)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java Mon
Aug 27 17:16:19 2012
@@ -27,29 +27,12 @@ import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MJobForms;
 import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MFormType;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
-public class ConnectorBean implements JsonBean {
+import static org.apache.sqoop.json.util.FormSerialization.*;
 
-  public static final String ID = "id";
-  public static final String NAME = "name";
-  public static final String CLASS = "class";
-  public static final String CON_FORMS = "con_forms";
-  public static final String JOB_FORMS = "job_forms";
-
-  public static final String FORM_NAME = "name";
-  public static final String FORM_TYPE = "type";
-  public static final String FORM_INPUTS = "inputs";
-  public static final String FORM_INPUT_NAME = "name";
-  public static final String FORM_INPUT_TYPE = "type";
-  public static final String FORM_INPUT_MASK = "mask";
-  public static final String FORM_INPUT_SIZE = "size";
+public class ConnectorBean implements JsonBean {
 
   private MConnector[] connectors;
 
@@ -98,42 +81,6 @@ public class ConnectorBean implements Js
     return result;
   }
 
-  @SuppressWarnings("unchecked")
-  private JSONArray extractForms(List<MForm> mForms) {
-    JSONArray forms = new JSONArray();
-
-    for (MForm mForm : mForms) {
-      forms.add(extractForm(mForm));
-    }
-
-    return forms;
-  }
-
-  @SuppressWarnings("unchecked")
-  private JSONObject extractForm(MForm mForm) {
-    JSONObject form = new JSONObject();
-    form.put(FORM_NAME, mForm.getName());
-    form.put(FORM_TYPE, MFormType.CONNECTION.toString());
-    JSONArray mInputs = new JSONArray();
-    form.put(FORM_INPUTS, mInputs);
-
-    for (MInput<?> mInput : mForm.getInputs()) {
-      JSONObject input = new JSONObject();
-      mInputs.add(input);
-
-      input.put(FORM_INPUT_NAME, mInput.getName());
-      input.put(FORM_INPUT_TYPE, mInput.getType().toString());
-      if (mInput.getType() == MInputType.STRING) {
-        input.put(FORM_INPUT_MASK,
-            ((MStringInput)mInput).isMasked());
-        input.put(FORM_INPUT_SIZE,
-            ((MStringInput)mInput).getMaxLength());
-      }
-    }
-
-    return form;
-  }
-
   @Override
   @SuppressWarnings("unchecked")
   public void restore(JSONObject jsonObject) {
@@ -172,43 +119,4 @@ public class ConnectorBean implements Js
       connectors[i] = connector;
     }
   }
-
-  private List<MForm> restoreForms(JSONArray forms) {
-    List<MForm> mForms = new ArrayList<MForm>();
-
-    for (int i = 0; i < forms.size(); i++) {
-      mForms.add(restoreForm((JSONObject) forms.get(i)));
-    }
-
-    return mForms;
-  }
-
-  private MForm restoreForm(JSONObject form) {
-    JSONArray inputs = (JSONArray) form.get(FORM_INPUTS);
-
-    List<MInput<?>> mInputs = new ArrayList<MInput<?>>();
-    for (int i = 0; i < inputs.size(); i++) {
-      JSONObject input = (JSONObject) inputs.get(i);
-      MInputType type =
-          MInputType.valueOf((String) input.get(FORM_INPUT_TYPE));
-      switch (type) {
-        case STRING: {
-          String name = (String) input.get(FORM_INPUT_NAME);
-          boolean mask = (Boolean) input.get(FORM_INPUT_MASK);
-          long size = (Long) input.get(FORM_INPUT_SIZE);
-          MInput<String> mInput = new MStringInput(name, mask, (short)size);
-          mInputs.add(mInput);
-          break;
-        }
-        case MAP: {
-          String name = (String) input.get(FORM_INPUT_NAME);
-          MInput<Map<String, String>> mInput = new MMapInput(name);
-          mInputs.add(mInput);
-          break;
-        }
-      }
-    }
-
-    return new MForm((String) form.get(FORM_NAME), mInputs);
-  }
 }

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java?rev=1377752&r1=1377751&r2=1377752&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
Mon Aug 27 17:16:19 2012
@@ -94,6 +94,10 @@ public class FrameworkManager {
     }
   }
 
+  public static MFramework getFramework() {
+    return mFramework;
+  }
+
   public static synchronized void destroy() {
     LOG.trace("Begin framework manager destroy");
   }

Modified: sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml?rev=1377752&r1=1377751&r2=1377752&view=diff
==============================================================================
--- sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml (original)
+++ sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml Mon Aug 27 17:16:19 2012
@@ -27,6 +27,7 @@ limitations under the License.
     <listener-class>org.apache.sqoop.server.ServerInitializer</listener-class>
   </listener>
 
+  <!-- Version servlet -->
   <servlet>
     <servlet-name>VersionServlet</servlet-name>
     <servlet-class>org.apache.sqoop.server.VersionServlet</servlet-class>
@@ -38,6 +39,7 @@ limitations under the License.
     <url-pattern>/version</url-pattern>
   </servlet-mapping>
 
+  <!-- Connector servlet -->
   <servlet>
     <servlet-name>v1.ConnectorServlet</servlet-name>
     <servlet-class>org.apache.sqoop.server.v1.ConnectorServlet</servlet-class>
@@ -49,5 +51,17 @@ limitations under the License.
     <url-pattern>/v1/connector/*</url-pattern>
   </servlet-mapping>
 
+  <!-- Framework servlet -->
+  <servlet>
+    <servlet-name>v1.FrameworkServlet</servlet-name>
+    <servlet-class>org.apache.sqoop.server.v1.FrameworkServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>v1.FrameworkServlet</servlet-name>
+    <url-pattern>/v1/framework/*</url-pattern>
+  </servlet-mapping>
+
 </web-app>
 



Mime
View raw message