String repoProviderClassName = context.getString(
RepoConfigurationConstants.SYSCFG_REPO_PROVIDER);
if (repoProviderClassName == null
|| repoProviderClassName.trim().length() == 0) {
throw new SqoopException(RepositoryError.REPO_0001,
RepoConfigurationConstants.SYSCFG_REPO_PROVIDER);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Repository provider: " + repoProviderClassName);
}
Class<?> repoProviderClass =
ClassUtils.loadClass(repoProviderClassName);
if (repoProviderClass == null) {
throw new SqoopException(RepositoryError.REPO_0001,
repoProviderClassName);
}
try {
provider = (RepositoryProvider) repoProviderClass.newInstance();
} catch (Exception ex) {
throw new SqoopException(RepositoryError.REPO_0001,
repoProviderClassName, ex);
}
provider.initialize(context);
if(!context.getBoolean(RepoConfigurationConstants
.SYSCFG_REPO_SCHEMA_IMMUTABLE, false)) {
LOG.info("Creating or upgrading on disk structures if necessary");
provider.getRepository().createOrUpdateInternals();
}
if(!provider.getRepository().haveSuitableInternals()) {
throw new SqoopException(RepositoryError.REPO_0002);
}
SqoopConfiguration.getInstance().getProvider().registerListener(new CoreConfigurationListener(this));
LOG.info("Repository initialized: OK");