}
private synchronized void registerConnectors(boolean autoUpgrade) {
Repository repository = RepositoryManager.getInstance().getRepository();
RepositoryTransaction rtx = null;
try {
rtx = repository.getTransaction();
rtx.begin();
for (String name : handlerMap.keySet()) {
ConnectorHandler handler = handlerMap.get(name);
MConnector connectorMetadata = handler.getMetadata();
MConnector registeredMetadata =
repository.registerConnector(connectorMetadata, autoUpgrade);
// Set registered metadata instead of connector metadata as they will
// have filled persistent ids. We should be confident at this point that
// there are no differences between those two structures.
handler.setMetadata(registeredMetadata);
String connectorName = handler.getUniqueName();
if (!handler.getMetadata().hasPersistenceId()) {
throw new SqoopException(ConnectorError.CONN_0010, connectorName);
}
nameMap.put(handler.getMetadata().getPersistenceId(), connectorName);
LOG.debug("Registered connector: " + handler.getMetadata());
}
rtx.commit();
} catch (Exception ex) {
if (rtx != null) {
rtx.rollback();
}
throw new SqoopException(ConnectorError.CONN_0007, ex);
} finally {
if (rtx != null) {
rtx.close();
}
}
}