sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1346742 - in /sqoop/branches/sqoop2: client/src/main/java/org/apache/sqoop/client/request/ client/src/main/java/org/apache/sqoop/client/shell/ common/src/main/java/org/apache/sqoop/json/ core/src/main/java/org/apache/sqoop/connector/ serve...
Date Wed, 06 Jun 2012 05:57:27 GMT
Author: blee
Date: Wed Jun  6 05:57:26 2012
New Revision: 1346742

URL: http://svn.apache.org/viewvc?rev=1346742&view=rev
Log:
SQOOP-365  Show connector command

Added:
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
  (with props)
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
  (with props)
    sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java  
(with props)
    sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
  (with props)
Modified:
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java
    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/ShowVersionFunction.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorError.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
    sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
    sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
    sqoop/branches/sqoop2/server/src/main/webapp/WEB-INF/web.xml

Added: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java?rev=1346742&view=auto
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
(added)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
Wed Jun  6 05:57:26 2012
@@ -0,0 +1,40 @@
+/**
+ * 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.client.request;
+
+import org.apache.sqoop.json.ConnectorBean;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+public class ConnectorRequest extends Request
+{
+  public ConnectorBean doGet(String serverUrl, String cid) {
+    String response = null;
+    if (cid == null) {
+      response = super.get(serverUrl + "v1/connector/all");
+    } else {
+      response = super.get(serverUrl + "v1/connector/" + cid);
+    }
+    JSONObject jsonObject = (JSONObject)JSONValue.parse(response);
+
+    ConnectorBean connectorBean = new ConnectorBean();
+    connectorBean.restore(jsonObject);
+
+    return connectorBean;
+  }
+}
\ No newline at end of file

Propchange: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java
Wed Jun  6 05:57:26 2012
@@ -23,8 +23,8 @@ import org.json.simple.JSONValue;
 
 public class VersionRequest extends Request
 {
-  public VersionBean version(String url) {
-    String response = get(url + "version");
+  public VersionBean doGet(String serverUrl) {
+    String response = super.get(serverUrl + "version");
     JSONObject jsonObject = (JSONObject)JSONValue.parse(response);
 
     VersionBean versionBean = new VersionBean();

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=1346742&r1=1346741&r2=1346742&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
Wed Jun  6 05:57:26 2012
@@ -27,6 +27,7 @@ public class ShowCommand extends SqoopCo
 {
   private ShowServerFunction serverFunction;
   private ShowVersionFunction versionFunction;
+  private ShowConnectorFunction connectorFunction;
 
   protected ShowCommand(Shell shell) {
     super(shell, "show", "\\sh",
@@ -57,7 +58,10 @@ public class ShowCommand extends SqoopCo
       return versionFunction.execute(args);
 
     } else if (func.equals("connector")) {
-      return null;
+      if (connectorFunction == null) {
+        connectorFunction = new ShowConnectorFunction(io);
+      }
+      return connectorFunction.execute(args);
 
     } else if (func.equals("connection")) {
       return null;
@@ -70,4 +74,4 @@ public class ShowCommand extends SqoopCo
       throw new SqoopException(ClientError.CLIENT_0002, msg);
     }
   }
-}
+}
\ No newline at end of file

Added: 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=1346742&view=auto
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
(added)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
Wed Jun  6 05:57:26 2012
@@ -0,0 +1,114 @@
+/**
+ * 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.client.shell;
+
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.client.core.Environment;
+import org.apache.sqoop.client.request.ConnectorRequest;
+import org.apache.sqoop.json.ConnectorBean;
+import org.codehaus.groovy.tools.shell.IO;
+
+@SuppressWarnings("serial")
+public class ShowConnectorFunction extends SqoopFunction
+{
+  public static final String ALL = "all";
+  public static final String CID = "cid";
+
+  private IO io;
+  private ConnectorRequest conntectorRequest;
+
+  @SuppressWarnings("static-access")
+  protected ShowConnectorFunction(IO io) {
+    this.io = io;
+
+    this.addOption(OptionBuilder
+        .withDescription("Display all connectors")
+        .withLongOpt(ALL)
+        .create(ALL.charAt(0)));
+    this.addOption(OptionBuilder.hasArg().withArgName("cid")
+        .withDescription(  "Display the connector with cid" )
+        .withLongOpt(CID)
+        .create(CID.charAt(0)));
+  }
+
+  public void printHelp(PrintWriter out) {
+    out.println("Usage: show connector");
+    super.printHelp(out);
+  }
+
+  public Object execute(List<String> args) {
+    if (args.size() == 1) {
+      printHelp(io.out);
+      io.out.println();
+      return null;
+    }
+
+    CommandLine line = parseOptions(this, 1, args);
+    if (line.hasOption(ALL)) {
+      showConnector(null);
+
+    } else if (line.hasOption(CID)) {
+      showConnector(line.getOptionValue(CID));
+    }
+
+    return null;
+  }
+
+  private void showConnector(String cid) {
+    if (conntectorRequest == null) {
+      conntectorRequest = new ConnectorRequest();
+    }
+    ConnectorBean connectorBean =
+      conntectorRequest.doGet(Environment.getServerUrl(), cid);
+    long[] ids = connectorBean.getIds();
+    String[] names = connectorBean.getNames();
+    String[] classes = connectorBean.getClasses();
+
+    if (cid == null) {
+      io.out.println("@|bold Metadata for all connectors:|@");  
+      int size = ids.length;
+      for (int i = 0; i < size; i++) {
+        io.out.print("Connector ");
+        io.out.print(i+1);
+        io.out.println(":");
+  
+        io.out.print("  Id: ");
+        io.out.println(ids[i]);
+        io.out.print("  Name: ");
+        io.out.println(names[i]);
+        io.out.print("  Class: ");
+        io.out.println(classes[i]);
+      }
+
+    } else {
+      io.out.println("@|bold Metadata for the connector:|@");
+      io.out.print("  Id: ");
+      io.out.println(ids[0]);
+      io.out.print("  Name: ");
+      io.out.println(names[0]);
+      io.out.print("  Class: ");
+      io.out.println(classes[0]);
+    }
+
+    io.out.println();
+  }
+}
\ No newline at end of file

Propchange: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
Wed Jun  6 05:57:26 2012
@@ -101,7 +101,7 @@ public class ShowVersionFunction extends
       versionRequest = new VersionRequest();
     }
     VersionBean versionBean =
-        versionRequest.version(Environment.getServerUrl());
+        versionRequest.doGet(Environment.getServerUrl());
 
     if (server) {
       io.out.println("@|bold Server version:|@");

Added: 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=1346742&view=auto
==============================================================================
--- sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java (added)
+++ sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java Wed
Jun  6 05:57:26 2012
@@ -0,0 +1,103 @@
+/**
+ * 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.json;
+
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+
+public class ConnectorBean implements JsonBean {
+
+  public static final String IDS = "ids";
+  public static final String NAMES = "names";
+  public static final String CLASSES = "classes";
+
+  private long[] ids;
+  private String[] names;
+  private String[] classes;
+
+  // for "extract"
+  public ConnectorBean(long[] ids, String[] names, String[] classes) {
+    this.ids = new long[ids.length];
+    System.arraycopy(ids, 0, this.ids, 0, ids.length);
+    this.names = new String[names.length];
+    System.arraycopy(names, 0, this.names, 0, names.length);
+    this.classes = new String[classes.length];
+    System.arraycopy(classes, 0, this.classes, 0, classes.length);
+  }
+
+  // for "restore"
+  public ConnectorBean() {
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public JSONObject extract() {
+    JSONObject result = new JSONObject();
+    JSONArray idsArray = new JSONArray();
+    for (long id : ids) {
+      idsArray.add(id);
+    }
+    result.put(IDS, idsArray);
+    JSONArray namesArray = new JSONArray();
+    for (String name : names) {
+      namesArray.add(name);
+    }
+    result.put(NAMES, namesArray);
+    JSONArray classesArray = new JSONArray();
+    for (String clz : classes) {
+      classesArray.add(clz);
+    }
+    result.put(CLASSES, classesArray);
+    return result;
+  }
+
+  @Override
+  public void restore(JSONObject jsonObject) {
+    JSONArray idsArray = (JSONArray) jsonObject.get(IDS);
+    int idsSize = idsArray.size();
+    ids = new long[idsSize];
+    for (int i = 0; i<idsSize; i++) {
+      ids[i] = (Long) idsArray.get(i);
+    }
+    JSONArray namesArray = (JSONArray) jsonObject.get(NAMES);
+    int namesSize = namesArray.size();
+    names = new String[namesSize];
+    for (int i = 0; i<namesSize; i++) {
+      names[i] = (String) namesArray.get(i);
+    }
+    JSONArray classesArray = (JSONArray) jsonObject.get(CLASSES);
+    int classeSize = classesArray.size();
+    classes = new String[classeSize];
+    for (int i = 0; i<classeSize; i++) {
+      classes[i] = (String) classesArray.get(i);
+    }
+  }
+
+  public long[] getIds() {
+    return this.ids;
+  }
+
+  public String[] getNames() {
+    return this.names;
+  }
+
+  public String[] getClasses() {
+    return this.classes;
+  }
+
+}

Propchange: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sqoop/branches/sqoop2/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorError.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorError.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorError.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorError.java
Wed Jun  6 05:57:26 2012
@@ -56,7 +56,10 @@ public enum ConnectorError implements Er
    */
   CONN_0009("Attempt to register connector with a name associated with a "
       + "previously registered connector; or the connector metadata has "
-      + "changed since it was registered previously.");
+      + "changed since it was registered previously."),
+
+  /** A connector is found with an invalid id. */
+  CONN_0010("A connector is found with an invalid id");
 
   private final String message;
 

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
Wed Jun  6 05:57:26 2012
@@ -19,13 +19,11 @@ package org.apache.sqoop.connector;
 
 import java.io.IOException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Properties;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.core.ConfigurationConstants;
 import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 

Modified: sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
(original)
+++ sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
Wed Jun  6 05:57:26 2012
@@ -37,9 +37,21 @@ public class ConnectorManager {
 
   private static final Logger LOG = Logger.getLogger(ConnectorManager.class);
 
+  // key: connector id, value: connector name
+  private static Map<Long, String> nameMap = new HashMap<Long, String>();
+
+  // key: connector name, value: connector handler
   private static Map<String, ConnectorHandler> handlerMap =
       new HashMap<String, ConnectorHandler>();
 
+  public static ConnectorHandler[] getHandlers() {
+    return handlerMap.values().toArray(new ConnectorHandler[]{});
+  }
+
+  public static ConnectorHandler getHandler(long connectorId) {
+    return handlerMap.get(nameMap.get(connectorId));
+  }
+
   public static synchronized void initialize() {
     if (LOG.isTraceEnabled()) {
       LOG.trace("Begin connector manager initialization");
@@ -116,6 +128,13 @@ public class ConnectorManager {
                 + registeredMetadata);
           }
         }
+
+        long connectorId = handler.getMetadata().getPersistenceId();
+        String connectorName = handler.getUniqueName();
+        if (connectorId == -1) {
+          throw new SqoopException(ConnectorError.CONN_0010, connectorName);
+        }
+        nameMap.put(connectorId, connectorName);
       }
       rtx.commit();
     } catch (Exception ex) {

Added: sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java?rev=1346742&view=auto
==============================================================================
--- sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
(added)
+++ sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
Wed Jun  6 05:57:26 2012
@@ -0,0 +1,81 @@
+/**
+ * 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.handler;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.connector.ConnectorHandler;
+import org.apache.sqoop.connector.ConnectorManager;
+import org.apache.sqoop.json.JsonBean;
+import org.apache.sqoop.json.ConnectorBean;
+import org.apache.sqoop.server.RequestContext;
+import org.apache.sqoop.server.RequestHandler;
+
+public class ConnectorRequestHandler implements RequestHandler {
+
+  private static final Logger LOG =
+      Logger.getLogger(ConnectorRequestHandler.class);
+
+  /** The API version supported by this server */
+  public static final String PROTOCOL_V1 = "1";
+
+
+  private ConnectorBean connectors;
+
+  public ConnectorRequestHandler() {
+    LOG.info("ConnectorRequestHandler initialized");
+  }
+
+
+  @Override
+  public JsonBean handleEvent(RequestContext ctx) throws SqoopException {
+    ConnectorBean connectorBean;
+
+    String uri = ctx.getRequest().getRequestURI();
+    int slash = uri.lastIndexOf("/");
+    String cid = uri.substring(slash + 1);
+    LOG.info("ConnectorRequestHandler handles cid: " + cid);
+    if (cid.equals("all")) {
+      // display all connectors
+      if (connectors == null) {
+        ConnectorHandler[] handlers = ConnectorManager.getHandlers();
+        long[] ids = new long[handlers.length];
+        String[] names = new String[handlers.length];
+        String[] classes = new String[handlers.length];
+        for (int i = 0; i < handlers.length; i++) {
+          ids[i] = handlers[i].getMetadata().getPersistenceId();
+          names[i] = handlers[i].getUniqueName();
+          classes[i] = handlers[i].getConnectorClassName();
+        }
+        connectors = new ConnectorBean(ids, names, classes);
+      }
+      connectorBean = connectors;
+
+    } else {
+      // display one connector
+      ConnectorHandler handler =
+          ConnectorManager.getHandler(Long.parseLong(cid));
+      long[] ids = new long[] { handler.getMetadata().getPersistenceId() };
+      String[] names = new String[] { handler.getUniqueName() };
+      String[] classes = new String[] { handler.getConnectorClassName() };
+      connectorBean = new ConnectorBean(ids, names, classes);
+    }
+
+    return connectorBean;
+  }
+}

Propchange: sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java?rev=1346742&r1=1346741&r2=1346742&view=diff
==============================================================================
--- sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
(original)
+++ sqoop/branches/sqoop2/server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java
Wed Jun  6 05:57:26 2012
@@ -17,8 +17,10 @@
  */
 package org.apache.sqoop.server.v1;
 
+import org.apache.sqoop.handler.ConnectorRequestHandler;
 import org.apache.sqoop.json.JsonBean;
 import org.apache.sqoop.server.RequestContext;
+import org.apache.sqoop.server.RequestHandler;
 import org.apache.sqoop.server.SqoopProtocolServlet;
 
 /**
@@ -28,9 +30,14 @@ import org.apache.sqoop.server.SqoopProt
 @SuppressWarnings("serial")
 public class ConnectorServlet extends SqoopProtocolServlet {
 
+  private RequestHandler connectorRequestHandler;
+
+  public ConnectorServlet() {
+    connectorRequestHandler = new ConnectorRequestHandler();
+  }
+
   @Override
   protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
-    // TODO Auto-generated method stub
-    return super.handleGetRequest(ctx);
+    return connectorRequestHandler.handleEvent(ctx);
   }
 }

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=1346742&r1=1346741&r2=1346742&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 Wed Jun  6 05:57:26 2012
@@ -46,7 +46,7 @@ limitations under the License.
   
   <servlet-mapping>
     <servlet-name>v1.ConnectorServlet</servlet-name>
-    <url-pattern>/v1/connector</url-pattern>
+    <url-pattern>/v1/connector/*</url-pattern>
   </servlet-mapping>
 
 </web-app>



Mime
View raw message