001/* 002 * JPPF. 003 * Copyright (C) 2005-2019 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.event; 020 021import java.util.EventListener; 022 023/** 024 * Interface for all listeners to the node's life cycle events. 025 * @author Laurent Cohen 026 */ 027public interface NodeLifeCycleListener extends EventListener { 028 /** 029 * Called when the node has finished initializing, and before it starts processing jobs. 030 * @param event encapsulates information about the node. 031 */ 032 void nodeStarting(NodeLifeCycleEvent event); 033 034 /** 035 * Called when the node is terminating. 036 * @param event encapsulates information about the node. 037 */ 038 void nodeEnding(NodeLifeCycleEvent event); 039 040 /** 041 * Called when the node has loaded a job header and before the {@code DataProvider} or any of the tasks have been loaded. 042 * <p>Note that {@code event.getTasks()} and {@code event.getDataProvider()} will return {@code null} at this point. 043 * @param event encapsulates information about the job. 044 */ 045 void jobHeaderLoaded(NodeLifeCycleEvent event); 046 047 /** 048 * Called before the node starts processing a job. 049 * @param event encapsulates information about the job. 050 */ 051 void jobStarting(NodeLifeCycleEvent event); 052 053 /** 054 * Called after the node finishes processing a job. 055 * @param event encapsulates information about the job. 056 */ 057 void jobEnding(NodeLifeCycleEvent event); 058 059 /** 060 * Called <i>after</i> the node has sent the results of a job to the server, and <i>before</i> it receives the next job. 061 * It is guranteed that the node is idle when this method is called. 062 * <p>Note that {@code event.getJob()}, {@code event.getTasks()}, {@code event.getTaskClassLoader()} and {@code event.getDataProvider()} will return {@code null} at this point. 063 * @param event encapsulates information about the job. 064 */ 065 void beforeNextJob(NodeLifeCycleEvent event); 066}