001/*
002 * #%L
003 * Netarchivesuite - harvester
004 * %%
005 * Copyright (C) 2005 - 2018 The Royal Danish Library, 
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.harvester.scheduler.jobgen;
024
025import dk.netarkivet.common.exceptions.ArgumentNotValid;
026import dk.netarkivet.harvester.datamodel.DomainConfiguration;
027import dk.netarkivet.harvester.datamodel.HarvestDefinition;
028import dk.netarkivet.harvester.datamodel.Job;
029
030/**
031 * This interface defines the core methods that should be provided by a job generator. It is designed to allow alternate
032 * implementations of job generation, depending on curators and/or production engineers specific needs.
033 */
034public interface JobGenerator {
035
036    /**
037     * Generates a series of jobs for the given harvest definition. Note that a job generator is expected to follow the
038     * singleton pattern, so implementations of this method should be thread-safe.
039     *
040     * @param harvest the harvest definition to process.
041     * @return the number of jobs that were generated.
042     */
043    int generateJobs(HarvestDefinition harvest);
044
045    /**
046     * Tests if a configuration fits into this Job. First tests if it's the right type of order-template and bytelimit,
047     * and whether the bytelimit is right for the job. The Job limits are compared against the configuration estimates
048     * and if no limits are exceeded true is returned otherwise false is returned.
049     *
050     * @param job the job being built.
051     * @param cfg the configuration to check
052     * @param previousCfg if not null, the configuration added to this job immediately prior
053     * @return true if adding the configuration to this Job does not exceed any of the Job limits.
054     * @throws ArgumentNotValid if cfg is null
055     */
056    boolean canAccept(Job job, DomainConfiguration cfg, DomainConfiguration previousCfg);
057    
058    /**
059     * Test if this configuration should be ignored
060     * @param cfg a domain configuration
061     * @return true if we should ignore this configuration (It could be that it is disabled in some way, or all seeds are prefixed with a '#' and so there are no active seeds
062     */
063    boolean ignoreConfiguration(DomainConfiguration cfg);
064}