@Override
public void execute() {
Timer timer = new Timer("Db Migration Progress");
timer.schedule(progressTask, MassUpdate.ProgressTask.PERIOD_MS, MassUpdate.ProgressTask.PERIOD_MS);
final DbSession readSession = db.openSession(false);
final DbSession writeSession = db.openSession(true);
try {
readSession.select("org.sonar.core.persistence.migration.v50.Migration50Mapper.selectRootProjects", new ResultHandler() {
@Override
public void handleResult(ResultContext context) {
Component project = (Component) context.getResultObject();
Map<Long, String> uuidByComponentId = newHashMap();
migrateEnabledComponents(readSession, writeSession, project, uuidByComponentId);
migrateDisabledComponents(readSession, writeSession, project, uuidByComponentId);
}
});
writeSession.commit();
readSession.commit();
migrateComponentsWithoutUuid(readSession, writeSession);
writeSession.commit();
// log the total number of process rows
progressTask.log();
} finally {
readSession.close();
writeSession.close();
timer.cancel();
timer.purge();
}
}