001/*
002 * JPPF.
003 * Copyright (C) 2005-2015 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.node.protocol;
020
021import org.jppf.scheduling.JPPFSchedule;
022
023
024/**
025 * This interface represents the Service Level Agreement between a JPPF job and a server.
026 * It determines the state, conditions and order in which a job will be executed.
027 * @author Laurent Cohen
028 */
029public interface JobSLA extends JobCommonSLA {
030  /**
031   * Get the priority of this job.
032   * @return the priority as an int.
033   */
034  int getPriority();
035
036  /**
037   * Set the priority of this job.
038   * @param priority the priority as an int.
039   */
040  void setPriority(int priority);
041
042  /**
043   * Get the maximum number of nodes this job can run on.
044   * @return the number of nodes as an int value.
045   */
046  int getMaxNodes();
047
048  /**
049   * Set the maximum number of nodes this job can run on.
050   * @param maxNodes the number of nodes as an int value. A value <= 0 means no limit on the number of nodes.
051   */
052  void setMaxNodes(int maxNodes);
053
054  /**
055   * Get the maximum number of groups of master/slaves nodes the job can be executed on at any given time.
056   * <p>This setting means that the job can only be executed on at most {@code maxMasterNodeGroups} master nodes and all their slaves.
057   * @return the number of nodes as an int value.
058   * @since 5.1
059   */
060  int getMaxNodeProvisioningGroupss();
061
062  /**
063   * Set the maximum number of groups of master/slaves nodes the job can be executed on at any given time.
064   * <p>This setting means that the job can only be executed on at most {@code maxMasterNodeGroups} master nodes and all their slaves.
065   * @param maxNodeProvisioningGroups the number of nodes as an int value. A value <= 0 means no limit on the number of nodes.
066   * Any value <= 0 will be ignored.
067   * @since 5.1
068   */
069  void setMaxNodeProvisioningGroups(int maxNodeProvisioningGroups);
070
071  /**
072   * Determine whether this job is initially suspended.
073   * @return true if the job is suspended, false otherwise.
074   */
075  boolean isSuspended();
076
077  /**
078   * Specify whether this job is initially suspended.
079   * @param suspended true if the job is suspended, false otherwise.
080   */
081  void setSuspended(boolean suspended);
082
083  /**
084   * Determine whether the job is a broadcast job.
085   * @return true for a broadcast job, false otherwise.
086   */
087  boolean isBroadcastJob();
088
089  /**
090   * Specify whether the job is a broadcast job.
091   * @param broadcastJob true for a broadcast job, false otherwise.
092   */
093  void setBroadcastJob(boolean broadcastJob);
094
095  /**
096   * Determine whether the job should be canceled by the driver if the client gets disconnected.
097   * @return <code>true</code> if the job should be canceled (this is the default), <code>false</code> otherwise.
098   */
099  boolean isCancelUponClientDisconnect();
100
101  /**
102   * Specify whether the job should be canceled by the driver if the client gets disconnected.
103   * @param cancelUponClientDisconnect <code>true</code> if the job should be canceled, <code>false</code> otherwise.
104   */
105  void setCancelUponClientDisconnect(boolean cancelUponClientDisconnect);
106
107  /**
108   * Get the strategy used to return the results back to the client.
109   * @return the name of the strategy to use.
110   * @exclude
111   */
112  String getResultsStrategy();
113
114  /**
115   * Set the strategy used to return the results back to the client.
116   * @param name the name of the strategy to use.
117   * @exclude
118   */
119  void setResultsStrategy(String name);
120
121  /**
122   * Get the class path associated with the job.
123   * @return an instance of {@link ClassPath}.
124   */
125  ClassPath getClassPath();
126
127  /**
128   * Set the class path associated with the job.
129   * @param classpath an instance of {@link ClassPath}.
130   */
131  void setClassPath(ClassPath classpath);
132
133  /**
134   * Get the expiration schedule for any subset of the job dispatched to a node.
135   * @return a {@link JPPFSchedule} instance.
136   */
137  JPPFSchedule getDispatchExpirationSchedule();
138
139  /**
140   * Set the expiration schedule for any subset of the job dispatched to a node.
141   * @param schedule a {@link JPPFSchedule} instance.
142   */
143  void setDispatchExpirationSchedule(JPPFSchedule schedule);
144
145  /**
146   * Get the number of times a dispatched task can expire before it is finally cancelled.
147   * @return the number of expirations as an int.
148   */
149  int getMaxDispatchExpirations();
150
151  /**
152   * Set the number of times a dispatched task can expire before it is finally cancelled.
153   * @param max the number of expirations as an int.
154   */
155  void setMaxDispatchExpirations(int max);
156
157  /**
158   * Get the naximum number of times a task can resubmit itself via {@link org.jppf.node.protocol.AbstractTask#setResubmit(boolean) AbstractTask.setResubmit(boolean)}.
159   * The default value is 1, meaning that a task can resubmit itself at most once.
160   * @return the maximum number of resubmits; a value of 0 or less means tasks in the job cannot be resubmitted.
161   */
162  int getMaxTaskResubmits();
163
164  /**
165   * Set the naximum number of times a task can resubmit itself via {@link org.jppf.node.protocol.AbstractTask#setResubmit(boolean) AbstractTask.setResubmit(boolean)}.
166   * @param maxResubmits the maximum number of resubmits; a value of 0 or less means tasks in the job cannot be resubmitted.
167   */
168  void setMaxTaskResubmits(int maxResubmits);
169
170  /**
171   * Determine whether the max resubmits limit for tasks is also applied when tasks are resubmitted due to a node error.
172   * This flag is false by default.
173   * @return {@code true} if the max resubmits count is applied upon node errors, {@code false} otherwise.
174   * @since 4.2
175   */
176  boolean isApplyMaxResubmitsUponNodeError();
177
178  /**
179   * Specify whether the max resubmits limit for tasks should also be applied when tasks are resubmitted due to a node error.
180   * @param applyMaxResubmitsUponNodeError {@code true} to specify that the max resubmits count is applied upon node errors, {@code false} otherwise.
181   * @since 4.2
182   */
183  void setApplyMaxResubmitsUponNodeError(boolean applyMaxResubmitsUponNodeError);
184
185  /**
186   * Determine whether remote class loading is enabled for the job.
187   * The default value, when not specified via {@link #setRemoteClassLoadingEnabled(boolean)}, is {@code true}.
188   * @return {@code true} is remote class loading is enabled, {@code false} otherwise.
189   * @since 4.2
190   */
191  boolean isRemoteClassLoadingEnabled();
192
193  /**
194   * Specify whether remote class loading is enabled for the job.
195   * @param enabled {@code true} to enable remote class loading, {@code false} to disable it.
196   * @since 4.2
197   */
198  void setRemoteClassLoadingEnabled(boolean enabled);
199}