sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject git commit: SQOOP-802 Convert main "Manager" classes to singletons (Jarek Jarcec Cecho)
Date Wed, 26 Dec 2012 22:13:02 GMT
Updated Branches:
  refs/heads/sqoop2 bca4d7812 -> 46b50e3f6


SQOOP-802 Convert main "Manager" classes to singletons
(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/46b50e3f
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/46b50e3f
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/46b50e3f

Branch: refs/heads/sqoop2
Commit: 46b50e3f68ef60939e271368d14a2119bcc82574
Parents: bca4d78
Author: Bilung Lee <blee@apache.org>
Authored: Wed Dec 26 12:38:39 2012 -0800
Committer: Bilung Lee <blee@apache.org>
Committed: Wed Dec 26 12:38:39 2012 -0800

----------------------------------------------------------------------
 .../apache/sqoop/connector/ConnectorManager.java   |   66 ++++++--
 .../org/apache/sqoop/core/SqoopConfiguration.java  |   67 ++++++--
 .../apache/sqoop/framework/FrameworkManager.java   |  122 +++++++++-----
 .../sqoop/repository/JdbcRepositoryProvider.java   |    2 +-
 .../apache/sqoop/repository/RepositoryManager.java |   52 +++++-
 .../org/apache/sqoop/core/TestConfiguration.java   |   18 +-
 .../sqoop/repository/TestRepositoryManager.java    |    4 +-
 .../sqoop/handler/ConnectionRequestHandler.java    |   24 ++--
 .../sqoop/handler/ConnectorRequestHandler.java     |   10 +-
 .../sqoop/handler/FrameworkRequestHandler.java     |    4 +-
 .../apache/sqoop/handler/JobRequestHandler.java    |   24 ++--
 .../sqoop/handler/SubmissionRequestHandler.java    |   12 +-
 .../org/apache/sqoop/server/ServerInitializer.java |   16 +-
 13 files changed, 279 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index c2342f7..2d32856 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -40,16 +40,54 @@ import org.apache.sqoop.model.MConnector;
 
 public final class ConnectorManager {
 
+  /**
+   * Logger object.
+   */
   private static final Logger LOG = Logger.getLogger(ConnectorManager.class);
 
+  /**
+   * Private instance to singleton of this class.
+   */
+  private static ConnectorManager instance;
+
+  /**
+   * Create default object by default.
+   *
+   * Every Sqoop server application needs one so this should not be performance issue.
+   */
+  static {
+    instance = new ConnectorManager();
+  }
+
+  /**
+   * Return current instance.
+   *
+   * @return Current instance
+   */
+  public static ConnectorManager getInstance() {
+    return instance;
+  }
+
+  /**
+   * Allows to set instance in case that it's need.
+   *
+   * This method should not be normally used as the default instance should be sufficient.
One target
+   * user use case for this method are unit tests.
+   *
+   * @param newInstance New instance
+   */
+  public static void setInstance(ConnectorManager newInstance) {
+    instance = newInstance;
+  }
+
   // key: connector id, value: connector name
-  private static Map<Long, String> nameMap = new HashMap<Long, String>();
+  private Map<Long, String> nameMap = new HashMap<Long, String>();
 
   // key: connector name, value: connector handler
-  private static Map<String, ConnectorHandler> handlerMap =
+  private Map<String, ConnectorHandler> handlerMap =
       new HashMap<String, ConnectorHandler>();
 
-  public static List<MConnector> getConnectorsMetadata() {
+  public List<MConnector> getConnectorsMetadata() {
     List<MConnector> connectors = new LinkedList<MConnector>();
     for(ConnectorHandler handler : handlerMap.values()) {
       connectors.add(handler.getMetadata());
@@ -57,11 +95,11 @@ public final class ConnectorManager {
     return connectors;
   }
 
-  public static Set<Long> getConnectorIds() {
+  public Set<Long> getConnectorIds() {
     return nameMap.keySet();
   }
 
-  public static Map<Long, ResourceBundle> getResourceBundles(Locale locale) {
+  public Map<Long, ResourceBundle> getResourceBundles(Locale locale) {
     Map<Long, ResourceBundle> bundles = new HashMap<Long, ResourceBundle>();
     for(ConnectorHandler handler : handlerMap.values()) {
       long id = handler.getMetadata().getPersistenceId();
@@ -71,13 +109,13 @@ public final class ConnectorManager {
     return bundles;
   }
 
-  public static ResourceBundle getResourceBundle(long connectorId,
+  public ResourceBundle getResourceBundle(long connectorId,
                                                  Locale locale) {
     ConnectorHandler handler = handlerMap.get(nameMap.get(connectorId));
     return  handler.getConnector().getBundle(locale);
   }
 
-  public static MConnector getConnectorMetadata(long connectorId) {
+  public MConnector getConnectorMetadata(long connectorId) {
     ConnectorHandler handler = handlerMap.get(nameMap.get(connectorId));
     if(handler == null) {
       return null;
@@ -86,12 +124,12 @@ public final class ConnectorManager {
     return handler.getMetadata();
   }
 
-  public static SqoopConnector getConnector(long connectorId) {
+  public SqoopConnector getConnector(long connectorId) {
     ConnectorHandler handler = handlerMap.get(nameMap.get(connectorId));
     return handler.getConnector();
   }
 
-  public static synchronized void initialize() {
+  public synchronized void initialize() {
     if (LOG.isTraceEnabled()) {
       LOG.trace("Begin connector manager initialization");
     }
@@ -147,8 +185,8 @@ public final class ConnectorManager {
     }
   }
 
-  private static synchronized void registerConnectors() {
-    Repository repository = RepositoryManager.getRepository();
+  private synchronized void registerConnectors() {
+    Repository repository = RepositoryManager.getInstance().getRepository();
 
     RepositoryTransaction rtx = null;
     try {
@@ -185,11 +223,7 @@ public final class ConnectorManager {
     }
   }
 
-  public static synchronized void destroy() {
+  public synchronized void destroy() {
     // FIXME
   }
-
-  private ConnectorManager() {
-    // Instantiation of this class is prohibited
-  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java b/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
index 043f8e6..82ef857 100644
--- a/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
+++ b/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
@@ -30,16 +30,57 @@ import org.apache.log4j.PropertyConfigurator;
 import org.apache.sqoop.common.MapContext;
 import org.apache.sqoop.common.SqoopException;
 
+/**
+ * Configuration manager that loads Sqoop configuration.
+ */
 public final class SqoopConfiguration {
 
+  /**
+   * Logger object.
+   */
   public static final Logger LOG = Logger.getLogger(SqoopConfiguration.class);
 
-  private static File configDir = null;
-  private static boolean initialized = false;
-  private static ConfigurationProvider provider = null;
-  private static Map<String, String> config = null;
+  /**
+   * Private instance to singleton of this class.
+   */
+  private static SqoopConfiguration instance;
+
+  /**
+   * Create default object by default.
+   *
+   * Every Sqoop server application needs one so this should not be performance issue.
+   */
+  static {
+    instance = new SqoopConfiguration();
+  }
+
+  /**
+   * Return current instance.
+   *
+   * @return Current instance
+   */
+  public static SqoopConfiguration getInstance() {
+    return instance;
+  }
+
+  /**
+   * Allows to set instance in case that it's need.
+   *
+   * This method should not be normally used as the default instance should be sufficient.
One target
+   * user use case for this method are unit tests.
+   *
+   * @param newInstance New instance
+   */
+  public static void setInstance(SqoopConfiguration newInstance) {
+    instance = newInstance;
+  }
+
+  private File configDir = null;
+  private boolean initialized = false;
+  private ConfigurationProvider provider = null;
+  private Map<String, String> config = null;
 
-  public static synchronized void initialize() {
+  public synchronized void initialize() {
     if (initialized) {
       LOG.warn("Attempt to reinitialize the system, ignoring");
       return;
@@ -130,7 +171,7 @@ public final class SqoopConfiguration {
     initialized = true;
   }
 
-  public static synchronized MapContext getContext() {
+  public synchronized MapContext getContext() {
     if (!initialized) {
       throw new SqoopException(CoreError.CORE_0007);
     }
@@ -141,7 +182,7 @@ public final class SqoopConfiguration {
     return new MapContext(parameters);
   }
 
-  public static synchronized void destroy() {
+  public synchronized void destroy() {
     if (provider != null) {
       try {
         provider.destroy();
@@ -155,7 +196,7 @@ public final class SqoopConfiguration {
     initialized = false;
   }
 
-  private static synchronized void configureLogging() {
+  private synchronized void configureLogging() {
     Properties props = new Properties();
     for (String key : config.keySet()) {
       if (key.startsWith(ConfigurationConstants.PREFIX_LOG_CONFIG)) {
@@ -168,18 +209,12 @@ public final class SqoopConfiguration {
     PropertyConfigurator.configure(props);
   }
 
-  private static synchronized void refreshConfiguration()
-  {
+  private synchronized void refreshConfiguration() {
     config = provider.getConfiguration();
     configureLogging();
   }
 
-  private SqoopConfiguration() {
-    // Disable explicit object creation
-  }
-
-  public static class CoreConfigurationListener implements ConfigurationListener
-  {
+  public class CoreConfigurationListener implements ConfigurationListener {
     @Override
     public void configurationChanged() {
       refreshConfiguration();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
index a5ac74f..40e1f0b 100644
--- a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
@@ -66,9 +66,47 @@ import java.util.ResourceBundle;
  */
 public final class FrameworkManager {
 
+  /**
+   * Logger object.
+   */
   private static final Logger LOG = Logger.getLogger(FrameworkManager.class);
 
   /**
+   * Private instance to singleton of this class.
+   */
+  private static FrameworkManager instance;
+
+  /**
+   * Create default object by default.
+   *
+   * Every Sqoop server application needs one so this should not be performance issue.
+   */
+  static {
+    instance = new FrameworkManager();
+  }
+
+  /**
+   * Return current instance.
+   *
+   * @return Current instance
+   */
+  public static FrameworkManager getInstance() {
+    return instance;
+  }
+
+  /**
+   * Allows to set instance in case that it's need.
+   *
+   * This method should not be normally used as the default instance should be sufficient.
One target
+   * user use case for this method are unit tests.
+   *
+   * @param newInstance New instance
+   */
+  public static void setInstance(FrameworkManager newInstance) {
+    instance = newInstance;
+  }
+
+  /**
    * Default interval for purging old submissions from repository.
    */
   private static final long DEFAULT_PURGE_THRESHOLD = 24*60*60*1000;
@@ -86,72 +124,72 @@ public final class FrameworkManager {
   /**
    * Framework metadata structures in MForm format
    */
-  private static MFramework mFramework;
+  private MFramework mFramework;
 
   /**
    * Validator instance
    */
-  private static final Validator validator;
+  private final Validator validator;
 
   /**
    * Configured submission engine instance
    */
-  private static SubmissionEngine submissionEngine;
+  private SubmissionEngine submissionEngine;
 
   /**
    * Configured execution engine instance
    */
-  private static ExecutionEngine executionEngine;
+  private ExecutionEngine executionEngine;
 
   /**
    * Purge thread that will periodically remove old submissions from repository.
    */
-  private static PurgeThread purgeThread = null;
+  private PurgeThread purgeThread = null;
 
   /**
    * Update thread that will periodically check status of running submissions.
    */
-  private static UpdateThread updateThread = null;
+  private UpdateThread updateThread = null;
 
   /**
    * Synchronization variable between threads.
    */
-  private static boolean running = true;
+  private boolean running = true;
 
   /**
    * Specifies how old submissions should be removed from repository.
    */
-  private static long purgeThreshold;
+  private long purgeThreshold;
 
   /**
    * Number of milliseconds for purge thread to sleep.
    */
-  private static long purgeSleep;
+  private long purgeSleep;
 
   /**
    * Number of milliseconds for update thread to slepp.
    */
-  private static long updateSleep;
+  private long updateSleep;
 
   /**
    * Mutex for creating new submissions. We're not allowing more then one
    * running submission for one job.
    */
-  private static final Object submissionMutex = new Object();
+  private final Object submissionMutex = new Object();
 
   /**
    * Base notification URL.
    *
    * Framework manager will always add job id.
    */
-  private static String notificationBaseUrl;
+  private String notificationBaseUrl;
 
   /**
    * Set notification base URL.
    *
    * @param url Base URL
    */
-  public static void setNotificationBaseUrl(String url) {
+  public void setNotificationBaseUrl(String url) {
     LOG.debug("Setting notification base URL to " + url);
     notificationBaseUrl = url;
   }
@@ -161,11 +199,11 @@ public final class FrameworkManager {
    *
    * @return String representation of the URL
    */
-  public static String getNotificationBaseUrl() {
+  public String getNotificationBaseUrl() {
     return notificationBaseUrl;
   }
 
-  static {
+  public FrameworkManager() {
     MConnectionForms connectionForms = new MConnectionForms(
       FormUtils.toForms(getConnectionConfigurationClass())
     );
@@ -180,12 +218,12 @@ public final class FrameworkManager {
     validator = new Validator();
   }
 
-  public static synchronized void initialize() {
+  public synchronized void initialize() {
     LOG.trace("Begin submission engine manager initialization");
-    MapContext context = SqoopConfiguration.getContext();
+    MapContext context = SqoopConfiguration.getInstance().getContext();
 
     // Register framework metadata in repository
-    mFramework = RepositoryManager.getRepository().registerFramework(mFramework);
+    mFramework = RepositoryManager.getInstance().getRepository().registerFramework(mFramework);
 
     // Let's load configured submission engine
     String submissionEngineClassName =
@@ -241,7 +279,7 @@ public final class FrameworkManager {
     LOG.info("Submission manager initialized: OK");
   }
 
-  public static synchronized void destroy() {
+  public  synchronized void destroy() {
     LOG.trace("Begin submission engine manager destroy");
 
     running = false;
@@ -271,15 +309,15 @@ public final class FrameworkManager {
     }
   }
 
-  public static Validator getValidator() {
+  public Validator getValidator() {
     return validator;
   }
 
-  public static Class getConnectionConfigurationClass() {
+  public Class getConnectionConfigurationClass() {
     return ConnectionConfiguration.class;
   }
 
-  public static Class getJobConfigurationClass(MJob.Type jobType) {
+  public Class getJobConfigurationClass(MJob.Type jobType) {
     switch (jobType) {
       case IMPORT:
         return ImportJobConfiguration.class;
@@ -290,17 +328,17 @@ public final class FrameworkManager {
     }
   }
 
-  public static MFramework getFramework() {
+  public MFramework getFramework() {
     return mFramework;
   }
 
-  public static ResourceBundle getBundle(Locale locale) {
+  public ResourceBundle getBundle(Locale locale) {
     return ResourceBundle.getBundle(
         FrameworkConstants.RESOURCE_BUNDLE_NAME, locale);
   }
 
-  public static MSubmission submit(long jobId) {
-    Repository repository = RepositoryManager.getRepository();
+  public MSubmission submit(long jobId) {
+    Repository repository = RepositoryManager.getInstance().getRepository();
 
     MJob job = repository.findJob(jobId);
     if(job == null) {
@@ -309,7 +347,7 @@ public final class FrameworkManager {
     }
     MConnection connection = repository.findConnection(job.getConnectionId());
     SqoopConnector connector =
-      ConnectorManager.getConnector(job.getConnectorId());
+      ConnectorManager.getInstance().getConnector(job.getConnectorId());
 
     // Transform forms to connector specific classes
     Object connectorConnection = ClassUtils.instantiate(
@@ -434,7 +472,7 @@ public final class FrameworkManager {
     return summary;
   }
 
-  private static void prepareImportSubmission(SubmissionRequest request) {
+  private void prepareImportSubmission(SubmissionRequest request) {
     ImportJobConfiguration jobConfiguration = (ImportJobConfiguration) request.getConfigFrameworkJob();
 
     // Initialize the map-reduce part (all sort of required classes, ...)
@@ -450,7 +488,7 @@ public final class FrameworkManager {
     executionEngine.prepareImportSubmission(request);
   }
 
-  private static void prepareExportSubmission(SubmissionRequest request) {
+  private void prepareExportSubmission(SubmissionRequest request) {
     ExportJobConfiguration jobConfiguration = (ExportJobConfiguration) request.getConfigFrameworkJob();
 
     // We're directly moving configured number of extractors and loaders to
@@ -467,7 +505,7 @@ public final class FrameworkManager {
    * Callback that will be called only if we failed to submit the job to the
    * remote cluster.
    */
-  private static void destroySubmission(SubmissionRequest request) {
+  private void destroySubmission(SubmissionRequest request) {
     CallbackBase baseCallbacks = request.getConnectorCallbacks();
 
     Class<? extends Destroyer> destroyerClass = baseCallbacks.getDestroyer();
@@ -483,8 +521,8 @@ public final class FrameworkManager {
       request.getConfigConnectorConnection(), request.getConfigConnectorJob());
   }
 
-  public static MSubmission stop(long jobId) {
-    Repository repository = RepositoryManager.getRepository();
+  public MSubmission stop(long jobId) {
+    Repository repository = RepositoryManager.getInstance().getRepository();
     MSubmission submission = repository.findSubmissionLastForJob(jobId);
 
     if(!submission.getStatus().isRunning()) {
@@ -502,8 +540,8 @@ public final class FrameworkManager {
     return submission;
   }
 
-  public static MSubmission status(long jobId) {
-    Repository repository = RepositoryManager.getRepository();
+  public MSubmission status(long jobId) {
+    Repository repository = RepositoryManager.getInstance().getRepository();
     MSubmission submission = repository.findSubmissionLastForJob(jobId);
 
     if(submission == null) {
@@ -518,7 +556,7 @@ public final class FrameworkManager {
     return submission;
   }
 
-  private static void update(MSubmission submission) {
+  private void update(MSubmission submission) {
     double progress  = -1;
     Counters counters = null;
     String externalId = submission.getExternalId();
@@ -537,10 +575,10 @@ public final class FrameworkManager {
     submission.setExternalLink(externalLink);
     submission.setLastUpdateDate(new Date());
 
-    RepositoryManager.getRepository().updateSubmission(submission);
+    RepositoryManager.getInstance().getRepository().updateSubmission(submission);
   }
 
-  private static class PurgeThread extends Thread {
+  private class PurgeThread extends Thread {
     public PurgeThread() {
       super("PurgeThread");
     }
@@ -552,7 +590,7 @@ public final class FrameworkManager {
         try {
           LOG.info("Purging old submissions");
           Date threshold = new Date((new Date()).getTime() - purgeThreshold);
-          RepositoryManager.getRepository().purgeSubmissions(threshold);
+          RepositoryManager.getInstance().getRepository().purgeSubmissions(threshold);
           Thread.sleep(purgeSleep);
         } catch (InterruptedException e) {
           LOG.debug("Purge thread interrupted", e);
@@ -563,7 +601,7 @@ public final class FrameworkManager {
     }
   }
 
-  private static class UpdateThread extends Thread {
+  private class UpdateThread extends Thread {
      public UpdateThread() {
       super("UpdateThread");
     }
@@ -577,7 +615,7 @@ public final class FrameworkManager {
 
           // Let's get all running submissions from repository to check them out
           List<MSubmission> unfinishedSubmissions =
-            RepositoryManager.getRepository().findSubmissionsUnfinished();
+            RepositoryManager.getInstance().getRepository().findSubmissionsUnfinished();
 
           for(MSubmission submission : unfinishedSubmissions) {
             update(submission);
@@ -592,8 +630,4 @@ public final class FrameworkManager {
       LOG.info("Ending submission manager update thread");
     }
   }
-
-  private FrameworkManager() {
-    // Instantiation of this class is prohibited
-  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryProvider.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryProvider.java
index eb7ed5b..3339c59 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryProvider.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryProvider.java
@@ -61,7 +61,7 @@ public class JdbcRepositoryProvider implements RepositoryProvider {
 
   @Override
   public synchronized void initialize(MapContext context) {
-    repoContext = new JdbcRepositoryContext(SqoopConfiguration.getContext());
+    repoContext = new JdbcRepositoryContext(SqoopConfiguration.getInstance().getContext());
 
     initializeRepositoryHandler();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
index 632bc60..50bad30 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
@@ -27,12 +27,50 @@ import org.apache.sqoop.utils.ClassUtils;
 
 public final class RepositoryManager {
 
+  /**
+   * Logger object.
+   */
   private static final Logger LOG = Logger.getLogger(RepositoryManager.class);
 
-  private static RepositoryProvider provider;
+  /**
+   * Private instance to singleton of this class.
+   */
+  private static RepositoryManager instance;
+
+  /**
+   * Create default object by default.
+   *
+   * Every Sqoop server application needs one so this should not be performance issue.
+   */
+  static {
+    instance = new RepositoryManager();
+  }
+
+  /**
+   * Return current instance.
+   *
+   * @return Current instance
+   */
+  public static RepositoryManager getInstance() {
+    return instance;
+  }
+
+  /**
+   * Allows to set instance in case that it's need.
+   *
+   * This method should not be normally used as the default instance should be sufficient.
One target
+   * user use case for this method are unit tests.
+   *
+   * @param newInstance New instance
+   */
+  public static void setInstance(RepositoryManager newInstance) {
+    instance = newInstance;
+  }
+
+  private RepositoryProvider provider;
 
-  public static synchronized void initialize() {
-    MapContext context = SqoopConfiguration.getContext();
+  public synchronized void initialize() {
+    MapContext context = SqoopConfiguration.getInstance().getContext();
 
     Map<String, String> repoSysProps = context.getNestedProperties(
         RepoConfigurationConstants.SYSCFG_REPO_SYSPROP_PREFIX);
@@ -76,7 +114,7 @@ public final class RepositoryManager {
     LOG.info("Repository initialized: OK");
   }
 
-  public static synchronized void destroy() {
+  public synchronized void destroy() {
     try {
       provider.destroy();
     } catch (Exception ex) {
@@ -84,11 +122,7 @@ public final class RepositoryManager {
     }
   }
 
-  public static synchronized Repository getRepository() {
+  public synchronized Repository getRepository() {
     return provider.getRepository();
   }
-
-  private RepositoryManager() {
-    // Instantiation of this class is prohibited
-  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/test/java/org/apache/sqoop/core/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/core/TestConfiguration.java b/core/src/test/java/org/apache/sqoop/core/TestConfiguration.java
index bd912ea..e7fe370 100644
--- a/core/src/test/java/org/apache/sqoop/core/TestConfiguration.java
+++ b/core/src/test/java/org/apache/sqoop/core/TestConfiguration.java
@@ -30,14 +30,14 @@ public class TestConfiguration {
   public void setUp() throws Exception {
     // Unset any configuration dir if it is set by another test
     System.getProperties().remove(ConfigurationConstants.SYSPROP_CONFIG_DIR);
-    SqoopConfiguration.destroy();
+    SqoopConfiguration.getInstance().destroy();
   }
 
   @Test
   public void testConfigurationInitFailure() {
     boolean success = false;
     try {
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -55,7 +55,7 @@ public class TestConfiguration {
       String configDirPath = TestUtils.createEmptyConfigDirectory();
       System.setProperty(ConfigurationConstants.SYSPROP_CONFIG_DIR,
           configDirPath);
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -73,7 +73,7 @@ public class TestConfiguration {
     bootProps.setProperty("foo", "bar");
     TestUtils.setupTestConfigurationUsingProperties(bootProps, null);
     try {
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -92,7 +92,7 @@ public class TestConfiguration {
         "foobar");
     TestUtils.setupTestConfigurationUsingProperties(bootProps, null);
     try {
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -112,7 +112,7 @@ public class TestConfiguration {
         MockInvalidConfigurationProvider.class.getCanonicalName());
     TestUtils.setupTestConfigurationUsingProperties(bootProps, null);
     try {
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -131,7 +131,7 @@ public class TestConfiguration {
         PropertiesConfigurationProvider.class.getCanonicalName());
     TestUtils.setupTestConfigurationUsingProperties(bootProps, null);
     try {
-      SqoopConfiguration.initialize();
+      SqoopConfiguration.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -146,7 +146,7 @@ public class TestConfiguration {
   public void testSystemNotInitialized() throws Exception {
     boolean success = false;
     try {
-      SqoopConfiguration.getContext();
+      SqoopConfiguration.getInstance().getContext();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),
@@ -160,6 +160,6 @@ public class TestConfiguration {
   @Test
   public void testConfigurationInitSuccess() throws Exception {
     TestUtils.setupTestConfigurationWithExtraConfig(null, null);
-    SqoopConfiguration.initialize();
+    SqoopConfiguration.getInstance().initialize();
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java b/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java
index a95c285..7cec536 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java
@@ -39,8 +39,8 @@ public class TestRepositoryManager {
     Properties configProps = new Properties();
     TestUtils.setupTestConfigurationUsingProperties(bootProps, configProps);
     try {
-      SqoopConfiguration.initialize();
-      RepositoryManager.initialize();
+      SqoopConfiguration.getInstance().initialize();
+      RepositoryManager.getInstance().initialize();
     } catch (Exception ex) {
       Assert.assertTrue(ex instanceof SqoopException);
       Assert.assertSame(((SqoopException) ex).getErrorCode(),

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/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 b77c5d7..2d7419d 100644
--- a/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/ConnectionRequestHandler.java
@@ -98,7 +98,7 @@ public class ConnectionRequestHandler implements RequestHandler {
     String sxid = ctx.getLastURLElement();
     long xid = Long.valueOf(sxid);
 
-    Repository repository = RepositoryManager.getRepository();
+    Repository repository = RepositoryManager.getInstance().getRepository();
     repository.deleteConnection(xid);
 
     return JsonBean.EMPTY_BEAN;
@@ -138,9 +138,9 @@ public class ConnectionRequestHandler implements RequestHandler {
 
     // Verify that user is not trying to spoof us
     MConnectionForms connectorForms =
-      ConnectorManager.getConnectorMetadata(connection.getConnectorId())
+      ConnectorManager.getInstance().getConnectorMetadata(connection.getConnectorId())
       .getConnectionForms();
-    MConnectionForms frameworkForms = FrameworkManager.getFramework()
+    MConnectionForms frameworkForms = FrameworkManager.getInstance().getFramework()
       .getConnectionForms();
 
     if(!connectorForms.equals(connection.getConnectorPart())
@@ -151,17 +151,17 @@ public class ConnectionRequestHandler implements RequestHandler {
 
     // Responsible connector for this session
     SqoopConnector connector =
-      ConnectorManager.getConnector(connection.getConnectorId());
+      ConnectorManager.getInstance().getConnector(connection.getConnectorId());
 
     // Get validator objects
     Validator connectorValidator = connector.getValidator();
-    Validator frameworkValidator = FrameworkManager.getValidator();
+    Validator frameworkValidator = FrameworkManager.getInstance().getValidator();
 
     // We need translate forms to configuration objects
     Object connectorConfig = ClassUtils.instantiate(
       connector.getConnectionConfigurationClass());
     Object frameworkConfig = ClassUtils.instantiate(
-      FrameworkManager.getConnectionConfigurationClass());
+      FrameworkManager.getInstance().getConnectionConfigurationClass());
 
     FormUtils.fromForms(
       connection.getConnectorPart().getForms(), connectorConfig);
@@ -184,9 +184,9 @@ public class ConnectionRequestHandler implements RequestHandler {
     // If we're good enough let's perform the action
     if(finalStatus.canProceed()) {
       if(update) {
-        RepositoryManager.getRepository().updateConnection(connection);
+        RepositoryManager.getInstance().getRepository().updateConnection(connection);
       } else {
-        RepositoryManager.getRepository().createConnection(connection);
+        RepositoryManager.getInstance().getRepository().createConnection(connection);
         outputBean.setId(connection.getPersistenceId());
       }
     }
@@ -199,7 +199,7 @@ public class ConnectionRequestHandler implements RequestHandler {
     ConnectionBean bean;
 
     Locale locale = ctx.getAcceptLanguageHeader();
-    Repository repository = RepositoryManager.getRepository();
+    Repository repository = RepositoryManager.getInstance().getRepository();
 
     if (sxid.equals("all")) {
 
@@ -211,7 +211,7 @@ public class ConnectionRequestHandler implements RequestHandler {
         long connectorId = connection.getConnectorId();
         if(!bean.hasConnectorBundle(connectorId)) {
           bean.addConnectorBundle(connectorId,
-            ConnectorManager.getResourceBundle(connectorId, locale));
+            ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
         }
       }
     } else {
@@ -223,11 +223,11 @@ public class ConnectionRequestHandler implements RequestHandler {
       bean = new ConnectionBean(connection);
 
       bean.addConnectorBundle(connectorId,
-        ConnectorManager.getResourceBundle(connectorId, locale));
+        ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
     }
 
     // Sent framework resource bundle in all cases
-    bean.setFrameworkBundle(FrameworkManager.getBundle(locale));
+    bean.setFrameworkBundle(FrameworkManager.getInstance().getBundle(locale));
 
     return bean;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
index 6dee70c..39b73e7 100644
--- a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
@@ -55,21 +55,21 @@ public class ConnectorRequestHandler implements RequestHandler {
     LOG.info("ConnectorRequestHandler handles cid: " + cid);
     if (cid.equals("all")) {
       // display all connectors
-      connectors = ConnectorManager.getConnectorsMetadata();
-      bundles = ConnectorManager.getResourceBundles(locale);
+      connectors = ConnectorManager.getInstance().getConnectorsMetadata();
+      bundles = ConnectorManager.getInstance().getResourceBundles(locale);
     } else {
       Long id = Long.parseLong(cid);
 
       // Check that user is not asking for non existing connector id
-      if(!ConnectorManager.getConnectorIds().contains(id)) {
+      if(!ConnectorManager.getInstance().getConnectorIds().contains(id)) {
         throw new SqoopException(ServerError.SERVER_0004, "Invalid id " + id);
       }
 
       connectors = new LinkedList<MConnector>();
       bundles = new HashMap<Long, ResourceBundle>();
 
-      connectors.add(ConnectorManager.getConnectorMetadata(id));
-      bundles.put(id, ConnectorManager.getResourceBundle(id, locale));
+      connectors.add(ConnectorManager.getInstance().getConnectorMetadata(id));
+      bundles.put(id, ConnectorManager.getInstance().getResourceBundle(id, locale));
     }
 
     return new ConnectorBean(connectors, bundles);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java
index 45a2d42..f635c35 100644
--- a/server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java
@@ -39,7 +39,7 @@ public class FrameworkRequestHandler  implements RequestHandler {
 
   @Override
   public JsonBean handleEvent(RequestContext ctx) {
-    return new FrameworkBean(FrameworkManager.getFramework(),
-      FrameworkManager.getBundle(ctx.getAcceptLanguageHeader()));
+    return new FrameworkBean(FrameworkManager.getInstance().getFramework(),
+      FrameworkManager.getInstance().getBundle(ctx.getAcceptLanguageHeader()));
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/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 6dea45f..41af657 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -98,7 +98,7 @@ public class JobRequestHandler implements RequestHandler {
     String sxid = ctx.getLastURLElement();
     long jid = Long.valueOf(sxid);
 
-    Repository repository = RepositoryManager.getRepository();
+    Repository repository = RepositoryManager.getInstance().getRepository();
     repository.deleteJob(jid);
 
     return JsonBean.EMPTY_BEAN;
@@ -139,9 +139,9 @@ public class JobRequestHandler implements RequestHandler {
 
     // Verify that user is not trying to spoof us
     MJobForms connectorForms
-      = ConnectorManager.getConnectorMetadata(job.getConnectorId())
+      = ConnectorManager.getInstance().getConnectorMetadata(job.getConnectorId())
       .getJobForms(job.getType());
-    MJobForms frameworkForms = FrameworkManager.getFramework()
+    MJobForms frameworkForms = FrameworkManager.getInstance().getFramework()
       .getJobForms(job.getType());
 
     if(!connectorForms.equals(job.getConnectorPart())
@@ -152,17 +152,17 @@ public class JobRequestHandler implements RequestHandler {
 
     // Responsible connector for this session
     SqoopConnector connector =
-      ConnectorManager.getConnector(job.getConnectorId());
+      ConnectorManager.getInstance().getConnector(job.getConnectorId());
 
     // Get validator objects
     Validator connectorValidator = connector.getValidator();
-    Validator frameworkValidator = FrameworkManager.getValidator();
+    Validator frameworkValidator = FrameworkManager.getInstance().getValidator();
 
     // We need translate forms to configuration objects
     Object connectorConfig = ClassUtils.instantiate(
       connector.getJobConfigurationClass(job.getType()));
     Object frameworkConfig = ClassUtils.instantiate(
-      FrameworkManager.getJobConfigurationClass(job.getType()));
+      FrameworkManager.getInstance().getJobConfigurationClass(job.getType()));
 
     FormUtils.fromForms(job.getConnectorPart().getForms(), connectorConfig);
     FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkConfig);
@@ -183,9 +183,9 @@ public class JobRequestHandler implements RequestHandler {
     // If we're good enough let's perform the action
     if(finalStatus.canProceed()) {
       if(update) {
-        RepositoryManager.getRepository().updateJob(job);
+        RepositoryManager.getInstance().getRepository().updateJob(job);
       } else {
-        RepositoryManager.getRepository().createJob(job);
+        RepositoryManager.getInstance().getRepository().createJob(job);
         outputBean.setId(job.getPersistenceId());
       }
 
@@ -199,7 +199,7 @@ public class JobRequestHandler implements RequestHandler {
     JobBean bean;
 
     Locale locale = ctx.getAcceptLanguageHeader();
-    Repository repository = RepositoryManager.getRepository();
+    Repository repository = RepositoryManager.getInstance().getRepository();
 
     if (sjid.equals("all")) {
 
@@ -211,7 +211,7 @@ public class JobRequestHandler implements RequestHandler {
         long connectorId = job.getConnectorId();
         if(!bean.hasConnectorBundle(connectorId)) {
           bean.addConnectorBundle(connectorId,
-            ConnectorManager.getResourceBundle(connectorId, locale));
+            ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
         }
       }
     } else {
@@ -223,11 +223,11 @@ public class JobRequestHandler implements RequestHandler {
       bean = new JobBean(job);
 
       bean.addConnectorBundle(connectorId,
-        ConnectorManager.getResourceBundle(connectorId, locale));
+        ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
     }
 
     // Sent framework resource bundle in all cases
-    bean.setFrameworkBundle(FrameworkManager.getBundle(locale));
+    bean.setFrameworkBundle(FrameworkManager.getInstance().getBundle(locale));
 
     return bean;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
index 6e541d5..de9a24b 100644
--- a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
@@ -78,7 +78,7 @@ public class SubmissionRequestHandler implements RequestHandler {
 
   private JsonBean handleNotification(RequestContext ctx, String sjid) {
     logger.debug("Received notification request for job " + sjid);
-    FrameworkManager.status(Long.parseLong(sjid));
+    FrameworkManager.getInstance().status(Long.parseLong(sjid));
     return JsonBean.EMPTY_BEAN;
   }
 
@@ -90,9 +90,9 @@ public class SubmissionRequestHandler implements RequestHandler {
         return submissionStatus(jid);
       case POST:
         // TODO: This should be outsourced somewhere more suitable than here
-        if(FrameworkManager.getNotificationBaseUrl() == null) {
+        if(FrameworkManager.getInstance().getNotificationBaseUrl() == null) {
           String url = ctx.getRequest().getRequestURL().toString();
-          FrameworkManager.setNotificationBaseUrl(
+          FrameworkManager.getInstance().setNotificationBaseUrl(
             url.split("v1")[0] + "/v1/submission/notification/");
         }
         return submissionSubmit(jid);
@@ -104,17 +104,17 @@ public class SubmissionRequestHandler implements RequestHandler {
   }
 
   private JsonBean submissionStop(long jid) {
-    MSubmission submission = FrameworkManager.stop(jid);
+    MSubmission submission = FrameworkManager.getInstance().stop(jid);
     return new SubmissionBean(submission);
   }
 
   private JsonBean submissionSubmit(long jid) {
-    MSubmission submission = FrameworkManager.submit(jid);
+    MSubmission submission = FrameworkManager.getInstance().submit(jid);
     return new SubmissionBean(submission);
   }
 
   private JsonBean submissionStatus(long jid) {
-    MSubmission submission = FrameworkManager.status(jid);
+    MSubmission submission = FrameworkManager.getInstance().status(jid);
     return new SubmissionBean(submission);
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/46b50e3f/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
index 256262b..5998e01 100644
--- a/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
+++ b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
@@ -37,20 +37,20 @@ public class ServerInitializer implements ServletContextListener {
 
   public void contextDestroyed(ServletContextEvent arg0) {
     LOG.info("Shutting down Sqoop server");
-    FrameworkManager.destroy();
-    ConnectorManager.destroy();
-    RepositoryManager.destroy();
-    SqoopConfiguration.destroy();
+    FrameworkManager.getInstance().destroy();
+    ConnectorManager.getInstance().destroy();
+    RepositoryManager.getInstance().destroy();
+    SqoopConfiguration.getInstance().destroy();
     LOG.info("Sqoop server has been correctly terminated");
   }
 
   public void contextInitialized(ServletContextEvent arg0) {
     try {
       LOG.info("Booting up Sqoop server");
-      SqoopConfiguration.initialize();
-      RepositoryManager.initialize();
-      ConnectorManager.initialize();
-      FrameworkManager.initialize();
+      SqoopConfiguration.getInstance().initialize();
+      RepositoryManager.getInstance().initialize();
+      ConnectorManager.getInstance().initialize();
+      FrameworkManager.getInstance().initialize();
       LOG.info("Sqoop server has successfully boot up");
     } catch (Exception ex) {
       LOG.error("Server startup failure", ex);


Mime
View raw message