use of com.google.copybara.monitor.EventMonitor.EventMonitors in project copybara by google.
the class Workflow method run.
@Override
public void run(Path workdir, ImmutableList<String> sourceRefs) throws RepoException, IOException, ValidationException {
if (sourceRefs.size() > 1) {
throw new CommandLineException(String.format("Workflow does not support multiple source_ref arguments yet: %s", ImmutableList.copyOf(sourceRefs)));
}
@Nullable String sourceRef = sourceRefs.size() == 1 ? sourceRefs.get(0) : null;
validateFlags();
try (ProfilerTask ignore = profiler().start("run/" + name)) {
console.progress("Getting last revision: " + "Resolving " + ((sourceRef == null) ? "origin reference" : sourceRef));
O resolvedRef = generalOptions.repoTask("origin.resolve_source_ref", () -> origin.resolve(sourceRef));
logger.log(Level.INFO, String.format("Running Copybara for workflow '%s' and ref '%s': %s", name, resolvedRef.asString(), this.toString()));
logger.log(Level.INFO, String.format("Using working directory : %s", workdir));
ImmutableList.Builder<DestinationEffect> allEffects = ImmutableList.builder();
WorkflowRunHelper<O, D> helper = newRunHelper(workdir, resolvedRef, sourceRef, event -> {
allEffects.addAll(event.getDestinationEffects());
eventMonitors().dispatchEvent(m -> m.onChangeMigrationFinished(event));
});
try (ProfilerTask ignored = profiler().start(mode.toString().toLowerCase())) {
mode.run(helper);
} finally {
if (!getGeneralOptions().dryRunMode) {
try (ProfilerTask ignored = profiler().start("after_all_migration")) {
ImmutableList<DestinationEffect> effects = allEffects.build();
ImmutableList<DestinationEffect> resultEffects = runHooks(effects, getAfterAllMigrationActions(), // Only do this once for all the actions
memoized(c -> helper.getOriginReader().getFeedbackEndPoint(c)), // Only do this once for all the actions
memoized(c -> helper.getDestinationWriter().getFeedbackEndPoint(c)), resolvedRef);
if (effects.size() != resultEffects.size()) {
console.warn("Effects where created in after_all_migrations, but they are ignored.");
}
}
}
}
}
}
Aggregations