Search in sources :

Example 1 with StringMav

use of io.datarouter.web.handler.mav.imp.StringMav in project datarouter by hotpads.

the class JobHandler method run.

@Handler
StringMav run(String name) {
    Class<? extends BaseJob> jobClass = BaseJob.parseClass(name);
    Date startTime = new Date();
    String triggeredBy = getSessionInfo().getRequiredSession().getUsername();
    var started = jobScheduler.triggerManualJob(jobClass, triggeredBy);
    String message;
    if (started.failed()) {
        message = "Could not start " + jobClass.getSimpleName() + " reason=" + started.reason();
    } else {
        Duration elapsedTime = DurationTool.sinceDate(startTime);
        message = "Finished manual trigger of " + jobClass.getSimpleName() + " in " + DurationTool.toString(elapsedTime);
        changelogRecorder.record(new DatarouterChangelogDtoBuilder("Job", name, "run", getSessionInfo().getRequiredSession().getUsername()).build());
    }
    logger.warn(message);
    return new StringMav(message);
}
Also used : StringMav(io.datarouter.web.handler.mav.imp.StringMav) Duration(java.time.Duration) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) Date(java.util.Date) LongRunningTasksHandler(io.datarouter.tasktracker.web.LongRunningTasksHandler) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)1 LongRunningTasksHandler (io.datarouter.tasktracker.web.LongRunningTasksHandler)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 StringMav (io.datarouter.web.handler.mav.imp.StringMav)1 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)1 Duration (java.time.Duration)1 Date (java.util.Date)1