001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 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 java.io.Serializable;
022
023import org.jppf.node.policy.ExecutionPolicy;
024import org.jppf.scheduling.JPPFSchedule;
025
026/**
027 * This interface represents the Service Level Agreement between a JPPF job and a server.
028 * It determines the state, conditions and order in which a job will be executed.
029 * @param <T> the type of SLA.
030 * @author Laurent Cohen
031 */
032@SuppressWarnings("unchecked")
033public class JobCommonSLA<T extends JobCommonSLA<?>> implements Serializable {
034  /**
035   * Explicit serialVersionUID.
036   */
037  private static final long serialVersionUID = 1L;
038  /**
039   * The tasks execution policy.
040   */
041  ExecutionPolicy executionPolicy = null;
042  /**
043   * The job start schedule configuration.
044   */
045  JPPFSchedule jobSchedule = null;
046  /**
047   * The job expiration schedule configuration.
048   */
049  JPPFSchedule jobExpirationSchedule = null;
050
051  /**
052   * Default constructor.
053   * @exclude
054   */
055  public JobCommonSLA() {
056  }
057
058  /**
059   * Get the tasks execution policy.
060   * @return an <code>ExecutionPolicy</code> instance.
061   */
062  public ExecutionPolicy getExecutionPolicy() {
063    return executionPolicy;
064  }
065
066  /**
067   * Set the tasks execution policy.
068   * @param executionPolicy an <code>ExecutionPolicy</code> instance.
069   * @return this SLA, for mathod chaining.
070   */
071  public T setExecutionPolicy(final ExecutionPolicy executionPolicy) {
072    this.executionPolicy = executionPolicy;
073    return (T) this;
074  }
075
076  /**
077   * Get the job schedule.
078   * @return a <code>JPPFSchedule</code> instance.
079   */
080  public JPPFSchedule getJobSchedule() {
081    return jobSchedule;
082  }
083
084  /**
085   * Set the job schedule.
086   * @param jobSchedule a <code>JPPFSchedule</code> instance.
087   * @return this SLA, for mathod chaining.
088   */
089  public T setJobSchedule(final JPPFSchedule jobSchedule) {
090    this.jobSchedule = jobSchedule;
091    return (T) this;
092  }
093
094  /**
095   * Get the job expiration schedule configuration.
096   * @return a {@link JPPFSchedule} instance.
097   */
098  public JPPFSchedule getJobExpirationSchedule() {
099    return jobExpirationSchedule;
100  }
101
102  /**
103   * Set the job expiration schedule configuration.
104   * @param jobExpirationSchedule a {@link JPPFSchedule} instance.
105   * @return this SLA, for mathod chaining.
106   */
107  public T setJobExpirationSchedule(final JPPFSchedule jobExpirationSchedule) {
108    this.jobExpirationSchedule = jobExpirationSchedule;
109    return (T) this;
110  }
111
112  /**
113   * Create a copy of this job SLA.
114   * @param sla a {@link JobCommonSLA} into which to copy the attributes of this instance.
115   * @return a {@link JobCommonSLA} instance.
116   * @exclude
117   */
118  protected T copyTo(final T sla) {
119    sla.setExecutionPolicy(executionPolicy);
120    sla.setJobExpirationSchedule(jobExpirationSchedule);
121    sla.setJobSchedule(jobSchedule);
122    //sla.setPriority(priority);
123    return sla;
124  }
125}