001/*
002 * JPPF.
003 * Copyright (C) 2005-2016 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.job;
020
021import java.util.*;
022
023import org.jppf.management.JPPFManagementInfo;
024
025/**
026 * Instances of this class encapsulate information on job dispatches to nodes.
027 * @author Laurent Cohen
028 * @since 5.0
029 * @deprecated {@link JobTasksEvent} should be used instead, in conjunction with {@link JobTasksListener}s.
030 */
031public class TaskReturnEvent extends EventObject {
032  /**
033   * The name of the job whose tasks were dispatched.
034   */
035  private final String jobName;
036  /**
037   * The list of tasks that were disptached.
038   */
039  private final List<ServerTaskInformation> serverTasks;
040  /**
041   * The reason why the set of tasks wass returned by a node.
042   */
043  private final JobReturnReason returnReason;
044  /**
045   * Info on the node to which the job was dispatched.
046   */
047  private final JPPFManagementInfo nodeInfo;
048
049  /**
050   * Intialize this job dispatch event with the specified information.
051   * @param jobUuid the uuid of the job whose tasks were dispatched.
052   * @param jobName the name of the job whose tasks were dispatched.
053   * @param serverTasks the list of tasks that were disptached.
054   * @param returnReason the reason why the set of tasks wass returned by a node.
055   * @param nodeInfo info on the node to which the job was dispatched.
056   * @exclude
057   */
058  public TaskReturnEvent(final String jobUuid, final String jobName, final List<ServerTaskInformation> serverTasks, final JobReturnReason returnReason, final JPPFManagementInfo nodeInfo) {
059    super(jobUuid);
060    this.jobName = jobName;
061    this.serverTasks = serverTasks;
062    this.returnReason = returnReason;
063    this.nodeInfo = nodeInfo;
064  }
065
066  /**
067   * Get the uuid of the job to which the tasks belong.
068   * @return the uuid as a {@code String}.
069   */
070  public String getJobUuid() {
071    return (String) getSource();
072  }
073
074  /**
075   * Get the name of the job to which the tasks belong.
076   * @return the name as a {@code String}.
077   */
078  public String getJobName() {
079    return jobName;
080  }
081
082  /**
083   * Get the list of tasks that were disptached.
084   * @return a {@code List} of {@code ServerTaskInformation} objects.
085   */
086  public List<ServerTaskInformation> getReturnedTasks() {
087    return serverTasks;
088  }
089
090  /**
091   * Get the reason why the set of tasks was returned by a node.
092   * @return the return reason as a {@code JobReturnReason} element.
093   */
094  public JobReturnReason getReturnReason() {
095    return returnReason;
096  }
097
098  /**
099   * Get the information on the node to which the job was dispatched.
100   * @return a {@link JPPFManagementInfo} object.
101   */
102  public JPPFManagementInfo getNodeInfo() {
103    return nodeInfo;
104  }
105}