All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.singularity.executor.models.LogrotateCronTemplateContext Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package com.hubspot.singularity.executor.models;

import java.nio.file.Paths;

import com.hubspot.singularity.executor.SingularityExecutorLogrotateFrequency;
import com.hubspot.singularity.executor.config.SingularityExecutorConfiguration;
import com.hubspot.singularity.executor.task.SingularityExecutorTaskDefinition;

public class LogrotateCronTemplateContext {
    private final String cronSchedule;
    private final String logrotateCommand;
    private final String logrotateStateFile;
    private final String logrotateConfig;
    private final String outputRedirect;

    public LogrotateCronTemplateContext(SingularityExecutorConfiguration configuration, SingularityExecutorTaskDefinition taskDefinition, SingularityExecutorLogrotateFrequency logrotateFrequency) {
        this.logrotateCommand = configuration.getLogrotateCommand();
        this.logrotateStateFile = taskDefinition.getLogrotateStateFilePath().toString();
        this.logrotateConfig = Paths.get(configuration.getLogrotateHourlyConfDirectory()).resolve(taskDefinition.getTaskId()).toString();
        this.cronSchedule = logrotateFrequency.getCronSchedule().get();
        this.outputRedirect = configuration.isIgnoreLogrotateOutput() ? "> /dev/null 2>&1" : "";
    }

    public String getLogrotateCommand() {
        return logrotateCommand;
    }

    public String getLogrotateStateFile() {
        return logrotateStateFile;
    }

    public String getLogrotateConfig() {
        return logrotateConfig;
    }

    public String getCronSchedule() {
        return cronSchedule;
    }

    public String getOutputRedirect() {
        return outputRedirect;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy