1 /* 2 * Copyright (c) 2005, London e-Science Centre, Imperial College London, UK 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 * 7 * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 * - Neither the name of the London e-Science Centre nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 * 11 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 */ 13 package org.icenigrid.gridsam.core.plugin; 14 15 import java.text.ParseException; 16 17 import org.icenigrid.gridsam.core.JobInstance; 18 import org.icenigrid.gridsam.core.JobManagerException; 19 20 /** 21 * Context interface for DRMConnector to take advantage of services provided by 22 * the JobManager 23 */ 24 public interface JobManagerContext { 25 26 /** 27 * get the named DRMConnector from the context 28 * 29 * @param pName 30 * the name of the DRMConnector to retrieve 31 * @return DRMConnector the DRMConnector associated with the name, or null 32 * if the it is not found 33 */ 34 public DRMConnector getDRMConnector(String pName); 35 36 /** 37 * get the job instance store 38 * 39 * @return String the schedule identifier, which can be used to unschedule 40 * the execution 41 * 42 * @return JobInstanceStore 43 */ 44 public JobInstanceStore getJobInstanceStore(); 45 46 /** 47 * schedule the given DRMConnector for immediate execution in this job 48 * context for the given job 49 * 50 * @param pJobInstance 51 * the job instance to run through the DRMConnector 52 * @param pConnector 53 * the DRMConnector 54 * @throws org.icenigrid.gridsam.core.JobManagerException 55 * if the DRMConnector cannot be scheduled 56 */ 57 public void schedule(JobInstance pJobInstance, DRMConnector pConnector) 58 throws JobManagerException; 59 60 /** 61 * schedule the given named DRMConnector for immediate execution in this job 62 * context for the given job 63 * 64 * @param pJobInstance 65 * the job instance to run through the DRMConnector 66 * @param pConnectorName 67 * the name of the DRMConnector resolvable by the context 68 * @throws JobManagerException 69 * if the DRMConnector cannot be scheduled 70 */ 71 public void schedule(JobInstance pJobInstance, String pConnectorName) 72 throws JobManagerException; 73 74 /** 75 * schedule the given DRMConnector for repeated execution in this job 76 * context for the given job 77 * 78 * @param pJobInstance 79 * the job instance to run through the DRMConnector 80 * @param pConnector 81 * the DRMConnector 82 * @param pRepeatInterval 83 * the period between repeated execution 84 * @throws JobManagerException 85 * if the DRMConnector cannot be scheduled 86 */ 87 public void schedule(JobInstance pJobInstance, DRMConnector pConnector, 88 long pRepeatInterval) throws JobManagerException; 89 90 /** 91 * schedule the given named DRMConnector for immediate execution in this job 92 * context for the given job 93 * 94 * @param pJobInstance 95 * the job instance to run through the DRMConnector 96 * @param pConnectorName 97 * the name of the DRMConnector resolvable by the context 98 * @param pRepeatInterval 99 * the period between repeated execution 100 * @throws JobManagerException 101 * if the DRMConnector cannot be scheduled 102 */ 103 public void schedule(JobInstance pJobInstance, String pConnectorName, 104 long pRepeatInterval) throws JobManagerException; 105 106 /** 107 * schedule the given DRMConnector for repeated execution in this job 108 * context for the given job 109 * 110 * @param pJobInstance 111 * the job instance to run through the DRMConnector 112 * @param pConnector 113 * the DRMConnector 114 * @param pCronExpression 115 * the CRON job expression to specify the schedule 116 * @throws java.text.ParseException 117 * if the cron expression is invalid 118 * @throws JobManagerException 119 * if the DRMConnector cannot be scheduled 120 */ 121 public void schedule(JobInstance pJobInstance, DRMConnector pConnector, 122 String pCronExpression) throws ParseException, JobManagerException; 123 124 /** 125 * schedule the given named DRMConnector for immediate execution in this job 126 * context for the given job 127 * 128 * @param pJobInstance 129 * the job instance to run through the DRMConnector 130 * @param pConnectorName 131 * the name of the DRMConnector resolvable by the context 132 * @param pCronExpression 133 * the CRON job expression to specify the schedule 134 * @throws ParseException 135 * if the cron expression is invalid 136 * @throws JobManagerException 137 * if the DRMConnector cannot be scheduled 138 */ 139 public void schedule(JobInstance pJobInstance, String pConnectorName, 140 String pCronExpression) throws ParseException, JobManagerException; 141 142 /** 143 * get the DRMConnector that has been added by the schedule operations to be 144 * scheduled immediately. Otherwise they will be scheduled by the managing 145 * system at a convenient time. 146 */ 147 public void scheduleImmediately() throws JobManagerException; 148 149 /** 150 * unschedule the currently executing DRMConnector task this context is 151 * associated with. No further execution of this recurrent DRMConnector will 152 * be executed. 153 */ 154 public void unschedule(); 155 156 }