Search in sources :

Example 1 with LocalDiskRepositoryManager

use of com.google.gerrit.server.git.LocalDiskRepositoryManager in project gerrit by GerritCodeReview.

the class Schema_106 method migrateData.

@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
    if (!(repoManager instanceof LocalDiskRepositoryManager)) {
        return;
    }
    ui.message("listing all repositories ...");
    SortedSet<Project.NameKey> repoList = repoManager.list();
    ui.message("done");
    ui.message(String.format("creating reflog files for %s branches ...", RefNames.REFS_CONFIG));
    ExecutorService executorPool = createExecutor(ui, repoList.size());
    List<Future<Void>> futures = new ArrayList<>();
    for (Project.NameKey project : repoList) {
        Callable<Void> callable = new ReflogCreator(project);
        futures.add(executorPool.submit(callable));
    }
    executorPool.shutdown();
    try {
        for (Future<Void> future : futures) {
            try {
                future.get();
            } catch (ExecutionException e) {
                ui.message(e.getCause().getMessage());
            }
        }
        ui.message("done");
    } catch (InterruptedException ex) {
        String msg = String.format("Migration step 106 was interrupted. " + "Reflog created in %d of %d repositories only.", countDone(futures), repoList.size());
        ui.message(msg);
    }
}
Also used : ArrayList(java.util.ArrayList) Project(com.google.gerrit.reviewdb.client.Project) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) LocalDiskRepositoryManager(com.google.gerrit.server.git.LocalDiskRepositoryManager)

Aggregations

Project (com.google.gerrit.reviewdb.client.Project)1 LocalDiskRepositoryManager (com.google.gerrit.server.git.LocalDiskRepositoryManager)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1