sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-1141: Sqoop2: Provide ability to enable/disable connections and jobs
Date Sun, 28 Jul 2013 00:43:23 GMT
Updated Branches:
  refs/heads/sqoop2 9f8ac6b6b -> 69ecc93d4


SQOOP-1141: Sqoop2: Provide ability to enable/disable connections and jobs

(Mengwei Ding via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/69ecc93d
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/69ecc93d
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/69ecc93d

Branch: refs/heads/sqoop2
Commit: 69ecc93d4a0870c83d548903c07cd80642c2ff61
Parents: 9f8ac6b
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Sat Jul 27 17:42:34 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Sat Jul 27 17:42:34 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/SqoopClient.java    | 20 ++++++
 .../org/apache/sqoop/client/core/Constants.java | 24 ++++++++
 .../sqoop/client/request/ConnectionRequest.java | 11 ++++
 .../apache/sqoop/client/request/JobRequest.java | 11 ++++
 .../sqoop/client/request/SqoopRequests.java     |  8 +++
 .../sqoop/client/shell/DisableCommand.java      | 64 ++++++++++++++++++++
 .../client/shell/DisableConnectionFunction.java | 51 ++++++++++++++++
 .../sqoop/client/shell/DisableJobFunction.java  | 59 ++++++++++++++++++
 .../sqoop/client/shell/EnableCommand.java       | 64 ++++++++++++++++++++
 .../client/shell/EnableConnectionFunction.java  | 51 ++++++++++++++++
 .../sqoop/client/shell/EnableJobFunction.java   | 59 ++++++++++++++++++
 .../client/shell/ShowConnectionFunction.java    |  6 +-
 .../sqoop/client/shell/ShowJobFunction.java     |  6 +-
 .../apache/sqoop/client/shell/SqoopShell.java   |  2 +
 .../main/resources/client-resource.properties   | 17 +++++-
 .../org/apache/sqoop/json/ConnectionBean.java   |  2 +
 .../java/org/apache/sqoop/json/JobBean.java     |  2 +
 .../sqoop/json/util/FormSerialization.java      |  1 +
 .../apache/sqoop/model/MAccountableEntity.java  | 16 +++++
 .../apache/sqoop/json/TestConnectionBean.java   |  3 +
 .../java/org/apache/sqoop/json/TestJobBean.java |  2 +
 .../sqoop/model/TestMAccountableEntity.java     |  2 +
 .../apache/sqoop/framework/FrameworkError.java  |  4 ++
 .../org/apache/sqoop/framework/JobManager.java  | 12 ++++
 .../apache/sqoop/repository/JdbcRepository.java | 38 ++++++++++++
 .../sqoop/repository/JdbcRepositoryHandler.java | 17 ++++++
 .../org/apache/sqoop/repository/Repository.java | 16 +++++
 .../sqoop/repository/derby/DerbyRepoError.java  |  6 ++
 .../derby/DerbyRepositoryHandler.java           | 42 +++++++++++++
 .../repository/derby/DerbySchemaConstants.java  |  4 ++
 .../repository/derby/DerbySchemaQuery.java      | 54 ++++++++++++++---
 .../sqoop/repository/derby/DerbyTestCase.java   |  2 +
 .../derby/TestConnectionHandling.java           | 19 ++++++
 .../sqoop/repository/derby/TestJobHandling.java | 18 ++++++
 .../sqoop/handler/ConnectionRequestHandler.java | 30 ++++++++-
 .../apache/sqoop/handler/JobRequestHandler.java | 30 ++++++++-
 36 files changed, 755 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index 4ca71a4..158e46c 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -280,6 +280,16 @@ public class SqoopClient {
   }
 
   /**
+   * Enable/disable connection with given id
+   *
+   * @param xid Connection id
+   * @param enabled Enable or disable
+   */
+  public void enableConnection(long xid, boolean enabled) {
+    requests.enableConnection(xid, enabled);
+  }
+
+  /**
    * Delete connection with given id.
    *
    * @param xid Connection id
@@ -346,6 +356,16 @@ public class SqoopClient {
   }
 
   /**
+   * Enable/disable job with given id
+   *
+   * @param jid Job that is going to be enabled/disabled
+   * @param enabled Enable or disable
+   */
+  public void enableJob(long jid, boolean enabled) {
+    requests.enableJob(jid, enabled);
+  }
+
+  /**
    * Delete job with given id.
    *
    * @param jid Job id

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
index b7b0436..999790d 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Constants.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -103,6 +103,12 @@ public class Constants {
   public static final String CMD_STATUS = "status";
   public static final String CMD_STATUS_SC = "\\stu";
 
+  public static final String CMD_ENABLE = "enable";
+  public static final String CMD_ENABLE_SC = "\\en";
+
+  public static final String CMD_DISABLE = "disable";
+  public static final String CMD_DISABLE_SC = "\\di";
+
   public static final String FN_CONNECTION = "connection";
   public static final String FN_JOB = "job";
   public static final String FN_SUBMISSION = "submission";
@@ -121,6 +127,8 @@ public class Constants {
   public static final String PRE_START = "Start";
   public static final String PRE_STATUS = "Status";
   public static final String PRE_STOP = "Stop";
+  public static final String PRE_ENABLE = "Enable";
+  public static final String PRE_DISABLE = "Disable";
   public static final String SUF_INFO = "Info";
 
 
@@ -188,6 +196,20 @@ public class Constants {
   public static final String RES_DELETE_USAGE =
       "delete.usage";
 
+  public static final String RES_DISABLE_USAGE =
+      "disable.usage";
+  public static final String RES_DISABLE_CONNECTION_SUCCESSFUL =
+      "disable.conn_successful";
+  public static final String RES_DISABLE_JOB_SUCCESSFUL =
+      "disable.job_successful";
+
+  public static final String RES_ENABLE_USAGE =
+      "enable.usage";
+  public static final String RES_ENABLE_CONNECTION_SUCCESSFUL =
+      "enable.conn_successful";
+  public static final String RES_ENABLE_JOB_SUCCESSFUL =
+      "enable.job_successful";
+
   public static final String RES_HELP_USAGE =
       "help.usage";
   public static final String RES_HELP_DESCRIPTION =
@@ -365,6 +387,8 @@ public class Constants {
       "table.header.status";
   public static final String RES_TABLE_HEADER_DATE =
       "table.header.date";
+  public static final String RES_TABLE_HEADER_ENABLED =
+      "table.header.enabled";
 
   public static final String RES_FORMDISPLAYER_SUPPORTED_JOBTYPE =
       "formdisplayer.supported_job_types";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java
index a69e009..f523abb 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java
@@ -31,6 +31,9 @@ public class ConnectionRequest extends Request {
 
   public static final String RESOURCE = "v1/connection/";
 
+  private static final String ENABLE = "/enable";
+  private static final String DISABLE = "/disable";
+
   public ConnectionBean read(String serverUrl, Long xid) {
     String response;
     if (xid == null) {
@@ -82,4 +85,12 @@ public class ConnectionRequest extends Request {
   public void delete(String serverUrl, Long id) {
      super.delete(serverUrl + RESOURCE + id);
   }
+
+  public void enable(String serverUrl, Long id, Boolean enabled) {
+    if (enabled) {
+      super.put(serverUrl + RESOURCE + id + ENABLE, null);
+    } else {
+      super.put(serverUrl + RESOURCE + id + DISABLE, null);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java b/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java
index 55ba9db..6dee2c8 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java
@@ -31,6 +31,9 @@ public class JobRequest extends Request {
 
   public static final String RESOURCE = "v1/job/";
 
+  private static final String ENABLE = "/enable";
+  private static final String DISABLE = "/disable";
+
   public JobBean read(String serverUrl, Long xid) {
     String response;
     if (xid == null) {
@@ -81,4 +84,12 @@ public class JobRequest extends Request {
   public void delete(String serverUrl, Long id) {
      super.delete(serverUrl + RESOURCE + id);
   }
+
+  public void enable(String serverUrl, Long id, Boolean enabled) {
+    if (enabled) {
+      super.put(serverUrl + RESOURCE + id + ENABLE, null);
+    } else {
+      super.put(serverUrl + RESOURCE + id + DISABLE, null);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java b/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
index f102c8f..ffaa84f 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java
@@ -106,6 +106,10 @@ public class SqoopRequests {
     return getConnectionRequest().update(serverUrl, connection);
   }
 
+  public void enableConnection(Long xid, Boolean enabled) {
+    getConnectionRequest().enable(serverUrl, xid, enabled);
+  }
+
   public void deleteConnection(Long xid) {
     getConnectionRequest().delete(serverUrl, xid);
   }
@@ -122,6 +126,10 @@ public class SqoopRequests {
     return getJobRequest().update(serverUrl, job);
   }
 
+  public void enableJob(Long jid, Boolean enabled) {
+    getJobRequest().enable(serverUrl, jid, enabled);
+  }
+
   public void deleteJob(Long jid) {
     getJobRequest().delete(serverUrl, jid);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/DisableCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/DisableCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/DisableCommand.java
new file mode 100644
index 0000000..5cbd6db
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/DisableCommand.java
@@ -0,0 +1,64 @@
+/**
+ * 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 org.apache.sqoop.client.core.Constants;
+import org.codehaus.groovy.tools.shell.Shell;
+import java.util.List;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ *
+ */
+public class DisableCommand extends SqoopCommand {
+
+  private DisableConnectionFunction connectionFunction;
+  private DisableJobFunction jobFunction;
+
+  public DisableCommand(Shell shell) {
+    super(shell, Constants.CMD_DISABLE, Constants.CMD_DISABLE_SC,
+      new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
+      Constants.PRE_DISABLE, Constants.SUF_INFO);
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public Object executeCommand(List args) {
+    if (args.size() == 0) {
+      printlnResource(Constants.RES_DISABLE_USAGE, getUsage());
+      return null;
+    }
+
+    String func = (String)args.get(0);
+    if (func.equals(Constants.FN_CONNECTION)) {
+      if (connectionFunction == null) {
+        connectionFunction = new DisableConnectionFunction();
+      }
+      return connectionFunction.execute(args);
+    } else if (func.equals(Constants.FN_JOB)) {
+      if (jobFunction == null) {
+        jobFunction = new DisableJobFunction();
+      }
+      return jobFunction.execute(args);
+    } else {
+      printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/DisableConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/DisableConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/DisableConnectionFunction.java
new file mode 100644
index 0000000..e04292a
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/DisableConnectionFunction.java
@@ -0,0 +1,51 @@
+/**
+ * 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 org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.validation.Status;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ * Handles enabling of a connection object
+ */
+public class DisableConnectionFunction extends SqoopFunction {
+  @SuppressWarnings("static-access")
+  public DisableConnectionFunction() {
+    this.addOption(OptionBuilder
+      .withDescription(resourceString(Constants.RES_PROMPT_CONN_ID))
+      .withLongOpt(Constants.OPT_XID)
+      .hasArg()
+      .create('x'));
+  }
+
+  public Object executeFunction(CommandLine line) {
+    if (!line.hasOption(Constants.OPT_XID)) {
+      printlnResource(Constants.RES_ARGS_XID_MISSING);
+      return null;
+    }
+
+    client.enableConnection(getLong(line, Constants.OPT_XID), false);
+
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/DisableJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/DisableJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/DisableJobFunction.java
new file mode 100644
index 0000000..5962cd2
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/DisableJobFunction.java
@@ -0,0 +1,59 @@
+/**
+ * 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 org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.request.JobRequest;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.validation.Status;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ * Handles disabling of a job object.
+ */
+public class DisableJobFunction extends SqoopFunction {
+
+  private JobRequest jobRequest;
+
+  @SuppressWarnings("static-access")
+  public DisableJobFunction() {
+    this.addOption(OptionBuilder
+      .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
+      .withLongOpt(Constants.OPT_JID)
+      .hasArg()
+      .create('j'));
+  }
+
+  public Object executeFunction(CommandLine line) {
+    if (!line.hasOption(Constants.OPT_JID)) {
+      printlnResource(Constants.RES_ARGS_JID_MISSING);
+      return null;
+    }
+
+    if (jobRequest == null) {
+      jobRequest = new JobRequest();
+    }
+
+    client.enableJob(getLong(line, Constants.OPT_JID), false);
+
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/EnableCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/EnableCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/EnableCommand.java
new file mode 100644
index 0000000..8a2c1c7
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/EnableCommand.java
@@ -0,0 +1,64 @@
+/**
+ * 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 org.apache.sqoop.client.core.Constants;
+import org.codehaus.groovy.tools.shell.Shell;
+import java.util.List;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ *
+ */
+public class EnableCommand extends SqoopCommand {
+
+  private EnableConnectionFunction connectionFunction;
+  private EnableJobFunction jobFunction;
+
+  public EnableCommand(Shell shell) {
+    super(shell, Constants.CMD_ENABLE, Constants.CMD_ENABLE_SC,
+      new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
+      Constants.PRE_ENABLE, Constants.SUF_INFO);
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public Object executeCommand(List args) {
+    if (args.size() == 0) {
+      printlnResource(Constants.RES_ENABLE_USAGE, getUsage());
+      return null;
+    }
+
+    String func = (String)args.get(0);
+    if (func.equals(Constants.FN_CONNECTION)) {
+      if (connectionFunction == null) {
+        connectionFunction = new EnableConnectionFunction();
+      }
+      return connectionFunction.execute(args);
+    } else if (func.equals(Constants.FN_JOB)) {
+      if (jobFunction == null) {
+        jobFunction = new EnableJobFunction();
+      }
+      return jobFunction.execute(args);
+    } else {
+      printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/EnableConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/EnableConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/EnableConnectionFunction.java
new file mode 100644
index 0000000..ed6dc3c
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/EnableConnectionFunction.java
@@ -0,0 +1,51 @@
+/**
+ * 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 org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.model.MConnection;
+import org.apache.sqoop.validation.Status;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ * Handles enabling of a connection object
+ */
+public class EnableConnectionFunction extends SqoopFunction {
+  @SuppressWarnings("static-access")
+  public EnableConnectionFunction() {
+    this.addOption(OptionBuilder
+      .withDescription(resourceString(Constants.RES_PROMPT_CONN_ID))
+      .withLongOpt(Constants.OPT_XID)
+      .hasArg()
+      .create('x'));
+  }
+
+  public Object executeFunction(CommandLine line) {
+    if (!line.hasOption(Constants.OPT_XID)) {
+      printlnResource(Constants.RES_ARGS_XID_MISSING);
+      return null;
+    }
+
+    client.enableConnection(getLong(line, Constants.OPT_XID), true);
+
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/EnableJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/EnableJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/EnableJobFunction.java
new file mode 100644
index 0000000..9e4e320
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/EnableJobFunction.java
@@ -0,0 +1,59 @@
+/**
+ * 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 org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.client.core.Constants;
+import org.apache.sqoop.client.request.JobRequest;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.validation.Status;
+
+import static org.apache.sqoop.client.shell.ShellEnvironment.*;
+
+/**
+ * Handles disabling of a job object.
+ */
+public class EnableJobFunction extends SqoopFunction {
+
+  private JobRequest jobRequest;
+
+  @SuppressWarnings("static-access")
+  public EnableJobFunction() {
+    this.addOption(OptionBuilder
+      .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
+      .withLongOpt(Constants.OPT_JID)
+      .hasArg()
+      .create('j'));
+  }
+
+  public Object executeFunction(CommandLine line) {
+    if (!line.hasOption(Constants.OPT_JID)) {
+      printlnResource(Constants.RES_ARGS_JID_MISSING);
+      return null;
+    }
+
+    if (jobRequest == null) {
+      jobRequest = new JobRequest();
+    }
+
+    client.enableJob(getLong(line, Constants.OPT_JID), true);
+
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
index 32bca71..94f92b3 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
@@ -65,18 +65,21 @@ public class ShowConnectionFunction extends SqoopFunction {
     header.add(resourceString(Constants.RES_TABLE_HEADER_ID));
     header.add(resourceString(Constants.RES_TABLE_HEADER_NAME));
     header.add(resourceString(Constants.RES_TABLE_HEADER_CONNECTOR));
+    header.add(resourceString(Constants.RES_TABLE_HEADER_ENABLED));
 
     List<String> ids = new LinkedList<String>();
     List<String> names = new LinkedList<String>();
     List<String> connectors = new LinkedList<String>();
+    List<String> availabilities = new LinkedList<String>();
 
     for(MConnection connection : connections) {
       ids.add(String.valueOf(connection.getPersistenceId()));
       names.add(connection.getName());
       connectors.add(String.valueOf(connection.getConnectorId()));
+      availabilities.add(String.valueOf(connection.getEnabled()));
     }
 
-    TableDisplayer.display(header, ids, names, connectors);
+    TableDisplayer.display(header, ids, names, connectors, availabilities);
   }
 
   private void showConnections() {
@@ -103,6 +106,7 @@ public class ShowConnectionFunction extends SqoopFunction {
     printlnResource(Constants.RES_SHOW_PROMPT_CONN_INFO,
       connection.getPersistenceId(),
       connection.getName(),
+      connection.getEnabled(),
       formatter.format(connection.getCreationDate()),
       formatter.format(connection.getLastUpdateDate())
     );

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
index 590e4e7..97a240b 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
@@ -66,20 +66,23 @@ public class ShowJobFunction extends SqoopFunction {
     header.add(resourceString(Constants.RES_TABLE_HEADER_NAME));
     header.add(resourceString(Constants.RES_TABLE_HEADER_TYPE));
     header.add(resourceString(Constants.RES_TABLE_HEADER_CONNECTOR));
+    header.add(resourceString(Constants.RES_TABLE_HEADER_ENABLED));
 
     List<String> ids = new LinkedList<String>();
     List<String> names = new LinkedList<String>();
     List<String> types = new LinkedList<String>();
     List<String> connectors = new LinkedList<String>();
+    List<String> availabilities = new LinkedList<String>();
 
     for(MJob job : jobs) {
       ids.add(String.valueOf(job.getPersistenceId()));
       names.add(job.getName());
       types.add(job.getType().toString());
       connectors.add(String.valueOf(job.getConnectorId()));
+      availabilities.add(String.valueOf(job.getEnabled()));
     }
 
-    TableDisplayer.display(header, ids, names, types, connectors);
+    TableDisplayer.display(header, ids, names, types, connectors, availabilities);
   }
 
   private void showJobs() {
@@ -105,6 +108,7 @@ public class ShowJobFunction extends SqoopFunction {
       Constants.RES_SHOW_PROMPT_JOB_INFO,
       job.getPersistenceId(),
       job.getName(),
+      job.getEnabled(),
       formatter.format(job.getCreationDate()),
       formatter.format(job.getLastUpdateDate())
     );

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java b/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
index aa87f20..f4ea3be 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
@@ -97,6 +97,8 @@ public final class SqoopShell {
     shell.register(new StartCommand(shell));
     shell.register(new StopCommand(shell));
     shell.register(new StatusCommand(shell));
+    shell.register(new EnableCommand(shell));
+    shell.register(new DisableCommand(shell));
 
     // Configure shared shell io object
     setIo(shell.getIo());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/client/src/main/resources/client-resource.properties
----------------------------------------------------------------------
diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties
index 5537a8e..1a8f963 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -86,6 +86,18 @@ create.creating_job = Creating job for connection with id {0}
 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
@@ -124,7 +136,7 @@ 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} (Created {2}, Updated {3})
+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
@@ -141,7 +153,7 @@ 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} (Created {2}, Updated {3})
+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
@@ -187,6 +199,7 @@ 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

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/main/java/org/apache/sqoop/json/ConnectionBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ConnectionBean.java b/common/src/main/java/org/apache/sqoop/json/ConnectionBean.java
index b4e986a..a014ddd 100644
--- a/common/src/main/java/org/apache/sqoop/json/ConnectionBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ConnectionBean.java
@@ -106,6 +106,7 @@ public class ConnectionBean implements JsonBean {
       object.put(NAME, connection.getName());
       object.put(CREATED, connection.getCreationDate().getTime());
       object.put(UPDATED, connection.getLastUpdateDate().getTime());
+      object.put(ENABLED, connection.getEnabled());
       object.put(CONNECTOR_ID, connection.getConnectorId());
       object.put(CONNECTOR_PART,
         extractForms(connection.getConnectorPart().getForms(), skipSensitive));
@@ -159,6 +160,7 @@ public class ConnectionBean implements JsonBean {
       connection.setName((String) object.get(NAME));
       connection.setCreationDate(new Date((Long) object.get(CREATED)));
       connection.setLastUpdateDate(new Date((Long) object.get(UPDATED)));
+      connection.setEnabled((Boolean) object.get(ENABLED));
 
       connections.add(connection);
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/main/java/org/apache/sqoop/json/JobBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/JobBean.java b/common/src/main/java/org/apache/sqoop/json/JobBean.java
index a830646..4685797 100644
--- a/common/src/main/java/org/apache/sqoop/json/JobBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/JobBean.java
@@ -109,6 +109,7 @@ public class JobBean implements JsonBean {
       object.put(TYPE, job.getType().name());
       object.put(CREATED, job.getCreationDate().getTime());
       object.put(UPDATED, job.getLastUpdateDate().getTime());
+      object.put(ENABLED, job.getEnabled());
       object.put(CONNECTION_ID, job.getConnectionId());
       object.put(CONNECTOR_ID, job.getConnectorId());
       object.put(CONNECTOR_PART,
@@ -171,6 +172,7 @@ public class JobBean implements JsonBean {
       job.setName((String) object.get(NAME));
       job.setCreationDate(new Date((Long) object.get(CREATED)));
       job.setLastUpdateDate(new Date((Long) object.get(UPDATED)));
+      job.setEnabled((Boolean) object.get(ENABLED));
 
       jobs.add(job);
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
index f01bc57..978789b 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
@@ -47,6 +47,7 @@ public final class FormSerialization {
   public static final String CLASS = "class";
   public static final String CREATED = "created";
   public static final String UPDATED = "updated";
+  public static final String ENABLED = "enabled";
   public static final String CON_FORMS = "con-forms";
   public static final String JOB_FORMS = "job-forms";
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java b/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java
index 137e71c..5524983 100644
--- a/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java
+++ b/common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java
@@ -25,6 +25,8 @@ import java.util.Date;
  */
 abstract public class MAccountableEntity extends MPersistableEntity {
 
+  private final boolean DEFAULT_ENABLED = true;
+
   /**
    * Date when the entity was created.
    */
@@ -35,9 +37,15 @@ abstract public class MAccountableEntity extends MPersistableEntity {
    */
   private Date lastUpdateDate;
 
+  /**
+   * Whether enabled
+   */
+  private boolean enabled;
+
   public MAccountableEntity() {
     this.creationDate = new Date();
     this.lastUpdateDate = this.creationDate;
+    this.enabled = DEFAULT_ENABLED;
   }
 
   public void setCreationDate(Date createDate) {
@@ -55,4 +63,12 @@ abstract public class MAccountableEntity extends MPersistableEntity {
   public Date getLastUpdateDate() {
     return lastUpdateDate;
   }
+
+  public void setEnabled(boolean enable) {
+    this.enabled = enable;
+  }
+
+  public boolean getEnabled() {
+    return this.enabled;
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
index dd1d75b..2f2b974 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
@@ -43,6 +43,7 @@ public class TestConnectionBean {
     connection.setPersistenceId(666);
     connection.setCreationDate(created);
     connection.setLastUpdateDate(updated);
+    connection.setEnabled(false);
 
     // Fill some data at the beginning
     MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
@@ -77,6 +78,7 @@ public class TestConnectionBean {
     assertEquals("Connection", target.getName());
     assertEquals(created, target.getCreationDate());
     assertEquals(updated, target.getLastUpdateDate());
+    assertEquals(false, target.getEnabled());
 
     // Test that value was correctly moved
     MStringInput targetInput = (MStringInput) target.getConnectorPart()
@@ -93,6 +95,7 @@ public class TestConnectionBean {
     connection.setPersistenceId(666);
     connection.setCreationDate(created);
     connection.setLastUpdateDate(updated);
+    connection.setEnabled(true);
 
     // Fill some data at the beginning
     MStringInput input = (MStringInput) connection.getConnectorPart().getForms()

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
index 6af1d8b..e42b7df 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
@@ -42,6 +42,7 @@ public class TestJobBean {
     job.setPersistenceId(666);
     job.setCreationDate(created);
     job.setLastUpdateDate(updated);
+    job.setEnabled(false);
 
     // Fill some data at the beginning
     MStringInput input = (MStringInput) job.getConnectorPart().getForms()
@@ -67,6 +68,7 @@ public class TestJobBean {
     assertEquals("The big job", target.getName());
     assertEquals(created, target.getCreationDate());
     assertEquals(updated, target.getLastUpdateDate());
+    assertEquals(false, target.getEnabled());
 
     // Test that value was correctly moved
     MStringInput targetInput = (MStringInput) target.getConnectorPart()

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
index 4ea42b1..bf103e4 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -49,7 +49,9 @@ public class TestMAccountableEntity {
     Date testLastUpdateDate = new Date();
     connection.setCreationDate(testCreationDate);
     connection.setLastUpdateDate(testLastUpdateDate);
+    connection.setEnabled(false);
     assertEquals(testCreationDate, connection.getCreationDate());
     assertEquals(testLastUpdateDate, connection.getLastUpdateDate());
+    assertEquals(false, connection.getEnabled());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/core/src/main/java/org/apache/sqoop/framework/FrameworkError.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkError.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkError.java
index 4277311..f7a6b67 100644
--- a/core/src/main/java/org/apache/sqoop/framework/FrameworkError.java
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkError.java
@@ -42,6 +42,10 @@ public enum FrameworkError implements ErrorCode {
 
   FRAMEWORK_0008("Invalid combination of submission and execution engines"),
 
+  FRAMEWORK_0009("Job has been disabled. Cannot submit this job."),
+
+  FRAMEWORK_0010("Connection for this job has been disabled. Cannot submit this job."),
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/core/src/main/java/org/apache/sqoop/framework/JobManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/JobManager.java b/core/src/main/java/org/apache/sqoop/framework/JobManager.java
index 9f09982..d0a087d 100644
--- a/core/src/main/java/org/apache/sqoop/framework/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/framework/JobManager.java
@@ -270,7 +270,19 @@ public class JobManager implements Reconfigurable {
       throw new SqoopException(FrameworkError.FRAMEWORK_0004,
         "Unknown job id " + jobId);
     }
+
+    if (!job.getEnabled()) {
+      throw new SqoopException(FrameworkError.FRAMEWORK_0009,
+        "Job id: " + job.getPersistenceId());
+    }
+
     MConnection connection = repository.findConnection(job.getConnectionId());
+
+    if (!connection.getEnabled()) {
+      throw new SqoopException(FrameworkError.FRAMEWORK_0010,
+        "Connection id: " + connection.getPersistenceId());
+    }
+
     SqoopConnector connector =
       ConnectorManager.getInstance().getConnector(job.getConnectorId());
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
index 095f3e9..7768b13 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -285,6 +285,25 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
+  public void enableConnection(final long connectionId, final boolean enabled) {
+    doWithConnection(new DoWithConnection() {
+      @Override
+      public Object doIt(Connection conn) {
+        if(!handler.existsConnection(connectionId, conn)) {
+          throw new SqoopException(RepositoryError.JDBCREPO_0017,
+            "Invalid id: " + connectionId);
+        }
+
+        handler.enableConnection(connectionId, enabled, conn);
+        return null;
+      }
+    });
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public void deleteConnection(final long connectionId) {
     doWithConnection(new DoWithConnection() {
       @Override
@@ -383,6 +402,25 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
+  public void enableJob(final long id, final boolean enabled) {
+    doWithConnection(new DoWithConnection() {
+      @Override
+      public Object doIt(Connection conn) {
+        if(!handler.existsJob(id, conn)) {
+          throw new SqoopException(RepositoryError.JDBCREPO_0020,
+            "Invalid id: " + id);
+        }
+
+        handler.enableJob(id, enabled, conn);
+        return null;
+      }
+    });
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public void deleteJob(final long id) {
     doWithConnection(new DoWithConnection() {
       @Override

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
index d468b79..9299484 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
@@ -211,6 +211,15 @@ public abstract class JdbcRepositoryHandler {
   public abstract boolean inUseConnection(long connectionId, Connection conn);
 
   /**
+   * Enable or disable connection with given id from metadata repository
+   *
+   * @param connectionId Connection object that is going to be enabled or disabled
+   * @param enabled Enable or disable
+   * @param conn Connection to metadata repository
+   */
+  public abstract void enableConnection(long connectionId, boolean enabled, Connection conn);
+
+  /**
    * Delete connection with given id from metadata repository.
    *
    * @param connectionId Connection object that should be removed from repository
@@ -282,6 +291,14 @@ public abstract class JdbcRepositoryHandler {
    */
   public abstract boolean inUseJob(long jobId, Connection conn);
 
+  /**
+   * Enable or disable job with given id from the repository
+   *
+   * @param jobId Job id
+   * @param enabled Enable or disable
+   * @param conn Connection to metadata repository
+   */
+  public abstract void enableJob(long jobId, boolean enabled, Connection conn);
 
   /**
    * Delete the input values for the job with given id from the repository.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/core/src/main/java/org/apache/sqoop/repository/Repository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java
index 92e11d2..7c7673f 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -143,6 +143,14 @@ public abstract class Repository {
     RepositoryTransaction tx);
 
   /**
+   * Enable or disable connection with given id from metadata repository
+   *
+   * @param id Connection object that is going to be enabled or disabled
+   * @param enabled enable or disable
+   */
+  public abstract void enableConnection(long id, boolean enabled);
+
+  /**
    * Delete connection with given id from metadata repository.
    *
    * @param id Connection object that should be removed from repository
@@ -193,6 +201,14 @@ public abstract class Repository {
   public abstract void updateJob(MJob job, RepositoryTransaction tx);
 
   /**
+   * Enable or disable job with given id from metadata repository
+   *
+   * @param id Job object that is going to be enabled or disabled
+   * @param enabled Enable or disable
+   */
+  public abstract void enableJob(long id, boolean enabled);
+
+  /**
    * Delete job with given id from metadata repository.
    *
    * @param id Job id that should be removed

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
index aeb7533..455eb64 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
@@ -172,6 +172,12 @@ public enum DerbyRepoError implements ErrorCode {
   /** Can't detect version of the database structures **/
   DERBYREPO_0041("Can't detect version of repository storage"),
 
+  /** Can't enable/disable connection **/
+  DERBYREPO_0042("Can't enable/disable connection"),
+
+  /** Can't enable/disable job **/
+  DERBYREPO_0043("Can't enable/disable job"),
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index f717abf..771673d 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -332,6 +332,8 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     }
     if(version <= 1) {
       runQuery(QUERY_CREATE_TABLE_SQ_SYSTEM, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED, conn);
     }
 
     ResultSet rs = null;
@@ -545,6 +547,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       stmt.setLong(2, connection.getConnectorId());
       stmt.setTimestamp(3, new Timestamp(connection.getCreationDate().getTime()));
       stmt.setTimestamp(4, new Timestamp(connection.getLastUpdateDate().getTime()));
+      stmt.setBoolean(5, connection.getEnabled());
 
       result = stmt.executeUpdate();
       if (result != 1) {
@@ -667,6 +670,23 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     }
   }
 
+  @Override
+  public void enableConnection(long connectionId, boolean enabled, Connection conn) {
+    PreparedStatement enableConn = null;
+
+    try {
+      enableConn = conn.prepareStatement(STMT_ENABLE_CONNECTION);
+      enableConn.setBoolean(1, enabled);
+      enableConn.setLong(2, connectionId);
+      enableConn.executeUpdate();
+    } catch (SQLException ex) {
+      logException(ex, connectionId);
+      throw new SqoopException(DerbyRepoError.DERBYREPO_0042, ex);
+    } finally {
+      closeStatements(enableConn);
+    }
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -849,6 +869,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       stmt.setString(3, job.getType().name());
       stmt.setTimestamp(4, new Timestamp(job.getCreationDate().getTime()));
       stmt.setTimestamp(5, new Timestamp(job.getLastUpdateDate().getTime()));
+      stmt.setBoolean(6, job.getEnabled());
 
       result = stmt.executeUpdate();
       if (result != 1) {
@@ -964,6 +985,23 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     return false;
   }
 
+  @Override
+  public void enableJob(long jobId, boolean enabled, Connection conn) {
+    PreparedStatement enableConn = null;
+
+    try {
+      enableConn = conn.prepareStatement(STMT_ENABLE_JOB);
+      enableConn.setBoolean(1, enabled);
+      enableConn.setLong(2, jobId);
+      enableConn.executeUpdate();
+    } catch (SQLException ex) {
+      logException(ex, jobId);
+      throw new SqoopException(DerbyRepoError.DERBYREPO_0043, ex);
+    } finally {
+      closeStatements(enableConn);
+    }
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -1510,6 +1548,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
         long connectorId = rsConnection.getLong(3);
         Date creationDate = rsConnection.getTimestamp(4);
         Date lastUpdateDate = rsConnection.getTimestamp(5);
+        boolean enabled = rsConnection.getBoolean(6);
 
         formConnectorFetchStmt.setLong(1, connectorId);
 
@@ -1538,6 +1577,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
         connection.setName(name);
         connection.setCreationDate(creationDate);
         connection.setLastUpdateDate(lastUpdateDate);
+        connection.setEnabled(enabled);
 
         connections.add(connection);
       }
@@ -1574,6 +1614,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
         String stringType = rsJob.getString(5);
         Date creationDate = rsJob.getTimestamp(6);
         Date lastUpdateDate = rsJob.getTimestamp(7);
+        boolean enabled = rsJob.getBoolean(8);
 
         MJob.Type type = MJob.Type.valueOf(stringType);
 
@@ -1604,6 +1645,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
         job.setName(name);
         job.setCreationDate(creationDate);
         job.setLastUpdateDate(lastUpdateDate);
+        job.setEnabled(enabled);
 
         jobs.add(job);
       }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
index 68cb1c0..49bf607 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
@@ -123,6 +123,8 @@ public final class DerbySchemaConstants {
 
   public static final String COLUMN_SQN_UPDATE_DATE = "SQN_UPDATE_DATE";
 
+  public static final String COLUMN_SQN_ENABLED = "SQN_ENABLED";
+
   public static final String CONSTRAINT_SQN_SQC_NAME = CONSTRAINT_PREFIX + "SQN_SQC";
 
   public static final String CONSTRAINT_SQN_SQC = SCHEMA_PREFIX + CONSTRAINT_SQN_SQC_NAME;
@@ -146,6 +148,8 @@ public final class DerbySchemaConstants {
 
   public static final String COLUMN_SQB_UPDATE_DATE = "SQB_UPDATE_DATE";
 
+  public static final String COLUMN_SQB_ENABLED = "SQB_ENABLED";
+
   public static final String CONSTRAINT_SQB_SQN_NAME = CONSTRAINT_PREFIX + "SQB_SQN";
 
   public static final String CONSTRAINT_SQB_SQN = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_NAME;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
index b2cd6cc..b08f7ab 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
@@ -90,6 +90,7 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
  *    | SQN_CONNECTOR: BIGINT        | FK SQ_CONNECTOR(SQC_ID)
  *    | SQN_CREATION_DATE: TIMESTAMP |
  *    | SQN_UPDATE_DATE: TIMESTAMP   |
+ *    | SQN_ENABLED: BOOLEAN         |
  *    +------------------------------+
  * </pre>
  * </p>
@@ -105,6 +106,7 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
  *    | SQB_CONNECTION: BIGINT       | FK SQ_CONNECTION(SQN_ID)
  *    | SQB_CREATION_DATE: TIMESTAMP |
  *    | SQB_UPDATE_DATE: TIMESTAMP   |
+ *    | SQB_ENABLED: BOOLEAN         |
  *    +------------------------------+
  * </pre>
  * </p>
@@ -256,6 +258,12 @@ public final class DerbySchemaQuery {
           + " REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
       + ")";
 
+  // DDL: Add enabled column to table SQ_CONNECTION
+  public static final String QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED =
+      "ALTER TABLE " + TABLE_SQ_CONNECTION + " ADD "
+      + COLUMN_SQN_ENABLED + " BOOLEAN "
+      + "DEFAULT TRUE";
+
   // DDL: Create table SQ_JOB
   public static final String QUERY_CREATE_TABLE_SQ_JOB =
       "CREATE TABLE " + TABLE_SQ_JOB + " ("
@@ -270,6 +278,12 @@ public final class DerbySchemaQuery {
           + "REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")"
       + ")";
 
+  // DDL: Add enabled column to table SQ_JOB
+  public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED =
+      "ALTER TABLE " + TABLE_SQ_JOB + " ADD "
+      + COLUMN_SQB_ENABLED + " BOOLEAN "
+      + "DEFAULT TRUE";
+
   // DDL: Create table SQ_CONNECTION_INPUT
   public static final String QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT =
       "CREATE TABLE " + TABLE_SQ_CONNECTION_INPUT + " ("
@@ -545,8 +559,9 @@ public final class DerbySchemaQuery {
     + COLUMN_SQN_NAME + ", "
     + COLUMN_SQN_CONNECTOR + ", "
     + COLUMN_SQN_CREATION_DATE + ", "
-    + COLUMN_SQN_UPDATE_DATE
-    + ") VALUES (?, ?, ?, ?)";
+    + COLUMN_SQN_UPDATE_DATE + ", "
+    + COLUMN_SQN_ENABLED
+    + ") VALUES (?, ?, ?, ?, ?)";
 
   // DML: Insert new connection inputs
   public static final String STMT_INSERT_CONNECTION_INPUT =
@@ -563,6 +578,12 @@ public final class DerbySchemaQuery {
     + COLUMN_SQN_UPDATE_DATE + " = ? "
     + " WHERE " + COLUMN_SQN_ID + " = ?";
 
+  // DML: Enable or disable connection
+  public static final String STMT_ENABLE_CONNECTION =
+    "UPDATE " + TABLE_SQ_CONNECTION + " SET "
+    + COLUMN_SQN_ENABLED + " = ? "
+    + " WHERE " + COLUMN_SQN_ID + " = ?";
+
   // DML: Delete rows from connection input table
   public static final String STMT_DELETE_CONNECTION_INPUT =
     "DELETE FROM " + TABLE_SQ_CONNECTION_INPUT
@@ -580,7 +601,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQN_NAME + ", "
     + COLUMN_SQN_CONNECTOR + ", "
     + COLUMN_SQN_CREATION_DATE + ", "
-    + COLUMN_SQN_UPDATE_DATE
+    + COLUMN_SQN_UPDATE_DATE + ", "
+    + COLUMN_SQN_ENABLED
     + " FROM " + TABLE_SQ_CONNECTION
     + " WHERE " + COLUMN_SQN_ID + " = ?";
 
@@ -591,7 +613,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQN_NAME + ", "
     + COLUMN_SQN_CONNECTOR + ", "
     + COLUMN_SQN_CREATION_DATE + ", "
-    + COLUMN_SQN_UPDATE_DATE
+    + COLUMN_SQN_UPDATE_DATE + ", "
+    + COLUMN_SQN_ENABLED
     + " FROM " + TABLE_SQ_CONNECTION;
 
   // DML: Select all connections for a specific connector.
@@ -601,7 +624,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQN_NAME + ", "
     + COLUMN_SQN_CONNECTOR + ", "
     + COLUMN_SQN_CREATION_DATE + ", "
-    + COLUMN_SQN_UPDATE_DATE
+    + COLUMN_SQN_UPDATE_DATE + ", "
+    + COLUMN_SQN_ENABLED
     + " FROM " + TABLE_SQ_CONNECTION
     + " WHERE " + COLUMN_SQN_CONNECTOR + " = ?";
 
@@ -617,8 +641,9 @@ public final class DerbySchemaQuery {
     + COLUMN_SQB_CONNECTION + ", "
     + COLUMN_SQB_TYPE + ", "
     + COLUMN_SQB_CREATION_DATE + ", "
-    + COLUMN_SQB_UPDATE_DATE
-    + ") VALUES (?, ?, ?, ?, ?)";
+    + COLUMN_SQB_UPDATE_DATE + ", "
+    + COLUMN_SQB_ENABLED
+    + ") VALUES (?, ?, ?, ?, ?, ?)";
 
   // DML: Insert new job inputs
   public static final String STMT_INSERT_JOB_INPUT =
@@ -634,6 +659,12 @@ public final class DerbySchemaQuery {
     + COLUMN_SQB_UPDATE_DATE + " = ? "
     + " WHERE " + COLUMN_SQB_ID + " = ?";
 
+  // DML: Enable or disable job
+  public static final String STMT_ENABLE_JOB =
+    "UPDATE " + TABLE_SQ_JOB + " SET "
+    + COLUMN_SQB_ENABLED + " = ? "
+    + " WHERE " + COLUMN_SQB_ID + " = ?";
+
   // DML: Delete rows from job input table
   public static final String STMT_DELETE_JOB_INPUT =
     "DELETE FROM " + TABLE_SQ_JOB_INPUT
@@ -667,7 +698,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQB_CONNECTION + ", "
     + COLUMN_SQB_TYPE + ", "
     + COLUMN_SQB_CREATION_DATE + ", "
-    + COLUMN_SQB_UPDATE_DATE
+    + COLUMN_SQB_UPDATE_DATE + ", "
+    + COLUMN_SQB_ENABLED
     + " FROM " + TABLE_SQ_JOB
     + " LEFT JOIN " + TABLE_SQ_CONNECTION
     + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID
@@ -682,7 +714,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQB_CONNECTION + ", "
     + COLUMN_SQB_TYPE + ", "
     + COLUMN_SQB_CREATION_DATE + ", "
-    + COLUMN_SQB_UPDATE_DATE
+    + COLUMN_SQB_UPDATE_DATE + ", "
+    + COLUMN_SQB_ENABLED
     + " FROM " + TABLE_SQ_JOB
     + " LEFT JOIN " + TABLE_SQ_CONNECTION
       + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID;
@@ -696,7 +729,8 @@ public final class DerbySchemaQuery {
     + COLUMN_SQB_CONNECTION + ", "
     + COLUMN_SQB_TYPE + ", "
     + COLUMN_SQB_CREATION_DATE + ", "
-    + COLUMN_SQB_UPDATE_DATE
+    + COLUMN_SQB_UPDATE_DATE + ", "
+    + COLUMN_SQB_ENABLED
     + " FROM " + TABLE_SQ_JOB
     + " LEFT JOIN " + TABLE_SQ_CONNECTION
       + " ON " + COLUMN_SQB_CONNECTION + " = " + COLUMN_SQN_ID

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
index 677b0be..b766b09 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
@@ -99,6 +99,8 @@ abstract public class DerbyTestCase extends TestCase {
     runQuery(QUERY_CREATE_TABLE_SQ_COUNTER);
     runQuery(QUERY_CREATE_TABLE_SQ_COUNTER_SUBMISSION);
     runQuery(QUERY_CREATE_TABLE_SQ_SYSTEM);
+    runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED);
+    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED);
     runQuery("INSERT INTO SQOOP.SQ_SYSTEM(SQM_KEY, SQM_VALUE) VALUES('version', '2')");
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
index 8266b46..6959f2d 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
@@ -20,6 +20,7 @@ package org.apache.sqoop.repository.derby;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MStringInput;
 
 import java.util.List;
@@ -188,6 +189,24 @@ public class TestConnectionHandling extends DerbyTestCase {
     assertEquals("Injected", forms.get(1).getInputs().get(1).getValue());
   }
 
+  public void testEnableAndDisableConnection() throws Exception {
+    loadConnections();
+
+    // disable connection 1
+    handler.enableConnection(1, false, getDerbyConnection());
+
+    MConnection retrieved = handler.findConnection(1, getDerbyConnection());
+    assertNotNull(retrieved);
+    assertEquals(false, retrieved.getEnabled());
+
+    // enable connection 1
+    handler.enableConnection(1, true, getDerbyConnection());
+
+    retrieved = handler.findConnection(1, getDerbyConnection());
+    assertNotNull(retrieved);
+    assertEquals(true, retrieved.getEnabled());
+  }
+
   public void testDeleteConnection() throws Exception {
     loadConnections();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
index 4c97e1e..a3d804e 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
@@ -205,6 +205,24 @@ public class TestJobHandling extends DerbyTestCase {
     assertEquals("Injected", forms.get(1).getInputs().get(1).getValue());
   }
 
+  public void testEnableAndDisableJob() throws Exception {
+    loadJobs();
+
+    // disable job 1
+    handler.enableJob(1, false, getDerbyConnection());
+
+    MJob retrieved = handler.findJob(1, getDerbyConnection());
+    assertNotNull(retrieved);
+    assertEquals(false, retrieved.getEnabled());
+
+    // enable job 1
+    handler.enableJob(1, true, getDerbyConnection());
+
+    retrieved = handler.findJob(1, getDerbyConnection());
+    assertNotNull(retrieved);
+    assertEquals(true, retrieved.getEnabled());
+  }
+
   public void testDeleteJob() throws Exception {
     loadJobs();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
index 038f602..62be8f4 100644
--- a/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
@@ -57,6 +57,12 @@ import java.util.Locale;
  * PUT /v1/connection/:xid
  * Update connection with id :xid.
  *
+ * PUT /v1/connection/:xid/enable
+ * Enable connection with id :xid
+ *
+ * PUT /v1/connection/:xid/disable
+ * Disable connection with id :xid
+ *
  * DELETE /v1/connection/:xid
  * Remove connection with id :xid
  *
@@ -71,6 +77,9 @@ public class ConnectionRequestHandler implements RequestHandler {
   private static final Logger LOG =
       Logger.getLogger(ConnectionRequestHandler.class);
 
+  private static final String ENABLE = "enable";
+  private static final String DISABLE = "disable";
+
   public ConnectionRequestHandler() {
     LOG.info("ConnectionRequestHandler initialized");
   }
@@ -81,9 +90,15 @@ public class ConnectionRequestHandler implements RequestHandler {
       case GET:
         return getConnections(ctx);
       case POST:
-        return createUpdateConnection(ctx, false);
+          return createUpdateConnection(ctx, false);
       case PUT:
-        return createUpdateConnection(ctx, true);
+        if (ctx.getLastURLElement().equals(ENABLE)) {
+          return enableConnection(ctx, true);
+        } else if (ctx.getLastURLElement().equals(DISABLE)) {
+          return enableConnection(ctx, false);
+        } else {
+          return createUpdateConnection(ctx, true);
+        }
       case DELETE:
         return deleteConnection(ctx);
     }
@@ -234,4 +249,15 @@ public class ConnectionRequestHandler implements RequestHandler {
 
     return bean;
   }
+
+  private JsonBean enableConnection(RequestContext ctx, boolean enabled) {
+    String[] elements = ctx.getUrlElements();
+    String sxid = elements[elements.length - 2];
+    long xid = Long.valueOf(sxid);
+
+    Repository repository = RepositoryManager.getInstance().getRepository();
+    repository.enableConnection(xid, enabled);
+
+    return JsonBean.EMPTY_BEAN;
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/69ecc93d/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index ab3f9d0..0d15329 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -57,6 +57,12 @@ import java.util.Locale;
  * PUT /v1/job/:jid
  * Update job with id :jid.
  *
+ * PUT /v1/job/:jid/enable
+ * Enable job with id :jid
+ *
+ * PUT /v1/job/:jid/disable
+ * Disable job with id :jid
+ *
  * DELETE /v1/job/:jid
  * Remove job with id :jid
  *
@@ -71,6 +77,9 @@ public class JobRequestHandler implements RequestHandler {
   private static final Logger LOG =
       Logger.getLogger(JobRequestHandler.class);
 
+  private static final String ENABLE = "enable";
+  private static final String DISABLE = "disable";
+
   public JobRequestHandler() {
     LOG.info("JobRequestHandler initialized");
   }
@@ -81,9 +90,15 @@ public class JobRequestHandler implements RequestHandler {
       case GET:
         return getJobs(ctx);
       case POST:
-        return createUpdateJob(ctx, false);
+          return createUpdateJob(ctx, false);
       case PUT:
-        return createUpdateJob(ctx, true);
+        if (ctx.getLastURLElement().equals(ENABLE)) {
+          return enableJob(ctx, true);
+        } else if (ctx.getLastURLElement().equals(DISABLE)) {
+          return enableJob(ctx, false);
+        } else {
+          return createUpdateJob(ctx, true);
+        }
       case DELETE:
         return deleteJob(ctx);
     }
@@ -234,4 +249,15 @@ public class JobRequestHandler implements RequestHandler {
 
     return bean;
   }
+
+  private JsonBean enableJob(RequestContext ctx, boolean enabled) {
+    String[] elements = ctx.getUrlElements();
+    String sjid = elements[elements.length - 2];
+    long xid = Long.valueOf(sjid);
+
+    Repository repository = RepositoryManager.getInstance().getRepository();
+    repository.enableJob(xid, enabled);
+
+    return JsonBean.EMPTY_BEAN;
+  }
 }


Mime
View raw message