package ru.yandex.wmconsole.periodic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import ru.yandex.common.scheduler.ExecutionContext;
import ru.yandex.wmconsole.service.MainMirrorOnlineCheckerService;
import ru.yandex.wmtools.common.util.scheduler.timetable.AbstractTaskExecutor;

/**
 * @author Alexey Zakharov
 */
public class MainMirrorOnlineCheckTask extends AbstractTaskExecutor {
    private static final Logger log = LoggerFactory.getLogger(MainMirrorOnlineCheckTask.class);

    private MainMirrorOnlineCheckerService mainMirrorOnlineCheckerService;

    @Override
    public String runWithRELogging(ExecutionContext context) {
        log.info(getClass().getName() + " task fired");
        mainMirrorOnlineCheckerService.fireCheck();
        return getClass().getName() + " task executed";
    }

    @Required
    public void setMainMirrorOnlineCheckerService(MainMirrorOnlineCheckerService mainMirrorOnlineCheckerService) {
        this.mainMirrorOnlineCheckerService = mainMirrorOnlineCheckerService;
    }
}
