001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.broker.scheduler;
018
019import java.io.File;
020
021import org.apache.activemq.Service;
022
023/**
024 * A Job Scheduler Store interface use to manage delay processing of Messaging
025 * related jobs.
026 */
027public interface JobSchedulerStore extends Service {
028
029    /**
030     * Gets the location where the Job Scheduler will write the persistent data used
031     * to preserve and recover scheduled Jobs.
032     *
033     * If the scheduler implementation does not utilize a file system based store this
034     * method returns null.
035     *
036     * @return the directory where persistent store data is written.
037     */
038    File getDirectory();
039
040    /**
041     * Sets the directory where persistent store data will be written.  This method
042     * must be called before the scheduler store is started to have any effect.
043     *
044     * @param directory
045     *      The directory where the job scheduler store is to be located.
046     */
047    void setDirectory(File directory);
048
049    /**
050     * The size of the current store on disk if the store utilizes a disk based store
051     * mechanism.
052     *
053     * @return the current store size on disk.
054     */
055    long size();
056
057    /**
058     * Returns the JobScheduler instance identified by the given name.
059     *
060     * @param name
061     *        the name of the JobScheduler instance to lookup.
062     *
063     * @return the named JobScheduler or null if none exists with the given name.
064     *
065     * @throws Exception if an error occurs while loading the named scheduler.
066     */
067    JobScheduler getJobScheduler(String name) throws Exception;
068
069    /**
070     * Removes the named JobScheduler if it exists, purging all scheduled messages
071     * assigned to it.
072     *
073     * @param name
074     *        the name of the scheduler instance to remove.
075     *
076     * @return true if there was a scheduler with the given name to remove.
077     *
078     * @throws Exception if an error occurs while removing the scheduler.
079     */
080    boolean removeJobScheduler(String name) throws Exception;
081}