de.otto.edison.jobs.repository.JobMetaRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edison-jobs Show documentation
Show all versions of edison-jobs Show documentation
Jobs library of the edison-microservice project.
package de.otto.edison.jobs.repository;
import de.otto.edison.jobs.domain.JobMeta;
import java.util.Set;
/**
* Repository used to associate meta data with job types.
*
* Some jobs may need to keep state between multiple job executions. For example, it may be necessary to store
* the position of the last successful data import, so follow-up executions of a job is able to start from
* where the last execution has finished.
*
*
* @since 1.0.0
*/
public interface JobMetaRepository {
/**
* Returns the current state of the specified job type.
*
* @param jobType the job type
* @return current state of the job type
*/
JobMeta getJobMeta(String jobType);
/**
* Create property if the document or key does not exists.
*
* Creating a value is an atomic operation that either succeeds, or fails by returning {@code false}. If
* creation fails, the job's state does not change.
*
*
* @param jobType the job type
* @param key the key of the created property
* @param value property value
* @return true if value was created, false if value already exists
*/
boolean createValue(String jobType, String key, String value);
boolean setRunningJob(String jobType, String jobId);
String getRunningJob(String jobType);
void clearRunningJob(String jobType);
/**
* Disables a job type, i.e. prevents it from being started
*
* @param jobType the disabled job type
* @param comment an optional comment
*/
void disable(String jobType, String comment);
/**
* Reenables a job type that was disabled
*
* @param jobType the enabled job type
*/
void enable(String jobType);
/**
* Atomically sets or updates a property for a job type.
*
* @param jobType the job type
* @param key the key of the property
* @param value the (new) value of the property
* @return previous value of the updated property, or null if it was created.
*/
String setValue(String jobType, String key, String value);
/**
* Returns the value of the specified property for a job type, or null if the property does not exist.
*
* @param jobType the job type
* @param key the key of the property
* @return current value or null
*/
String getValue(String jobType, String key);
/**
* Returns all job types matching the specified predicate.
*
* @return set containing matching job types.
*/
Set findAllJobTypes();
/**
* Deletes all information from the repository.
*/
void deleteAll();
}