View Javadoc
1   //******************************************************************************
2   //
3   // File:    JobBackendRef.java
4   // Package: edu.rit.pj.cluster
5   // Unit:    Interface edu.rit.pj.cluster.JobBackendRef
6   //
7   // This Java source file is copyright (C) 2006 by Alan Kaminsky. All rights
8   // reserved. For further information, contact the author, Alan Kaminsky, at
9   // ark@cs.rit.edu.
10  //
11  // This Java source file is part of the Parallel Java Library ("PJ"). PJ is free
12  // software; you can redistribute it and/or modify it under the terms of the GNU
13  // General Public License as published by the Free Software Foundation; either
14  // version 3 of the License, or (at your option) any later version.
15  //
16  // PJ is distributed in the hope that it will be useful, but WITHOUT ANY
17  // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18  // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19  //
20  // Linking this library statically or dynamically with other modules is making a
21  // combined work based on this library. Thus, the terms and conditions of the GNU
22  // General Public License cover the whole combination.
23  //
24  // As a special exception, the copyright holders of this library give you
25  // permission to link this library with independent modules to produce an
26  // executable, regardless of the license terms of these independent modules, and
27  // to copy and distribute the resulting executable under terms of your choice,
28  // provided that you also meet, for each linked independent module, the terms
29  // and conditions of the license of that module. An independent module is a module
30  // which is not derived from or based on this library. If you modify this library,
31  // you may extend this exception to your version of the library, but you are not
32  // obligated to do so. If you do not wish to do so, delete this exception
33  // statement from your version.
34  //
35  // A copy of the GNU General Public License is provided in the file gpl.txt. You
36  // may also obtain a copy of the GNU General Public License on the World Wide
37  // Web at http://www.gnu.org/licenses/gpl.html.
38  //
39  //******************************************************************************
40  package edu.rit.pj.cluster;
41  
42  import java.io.IOException;
43  import java.net.InetSocketAddress;
44  import java.util.Properties;
45  
46  import edu.rit.util.ByteSequence;
47  
48  /**
49   * Interface JobBackendRef specifies the interface for the PJ job backend
50   * process.
51   *
52   * @author Alan Kaminsky
53   * @version 05-Nov-2006
54   */
55  public interface JobBackendRef {
56  
57  // Exported operations.
58      /**
59       * Cancel the job.
60       *
61       * @param theJobFrontend Job Frontend that is calling this method.
62       * @param errmsg Error message string.
63       * @exception IOException Thrown if an I/O error occurred.
64       * @throws java.io.IOException if any.
65       */
66      public void cancelJob(JobFrontendRef theJobFrontend,
67              String errmsg)
68              throws IOException;
69  
70      /**
71       * Commence the job.
72       *
73       * @param theJobFrontend Job Frontend that is calling this method.
74       * @param middlewareAddress Array of hosts/ports for middleware messages.
75       * The first <I>K</I>
76       * elements are for the job backend processes in rank order, the
77       * <I>K</I>+1st element is for the job frontend process. If the
78       * @param worldAddress Array of hosts/ports for the world communicator. The
79       * <I>K</I>
80       * elements are for the job backend processes in rank order.
81       * @param frontendAddress Array of hosts/ports for the frontend
82       * communicator. The first
83       * <I>K</I> elements are for the job backend processes in rank order, the
84       * <I>K</I>+1st element is for the job frontend process. If the frontend
85       * communicator does not exist, <code>frontendAddress</code> is null.
86       * @param properties Java system properties.
87       * @param mainClassName Fully qualified class name of the Java main program
88       * class to execute.
89       * @param args Array of 0 or more Java command line arguments.
90       * @exception IOException Thrown if an I/O error occurred.
91       * @throws java.io.IOException if any.
92       */
93      public void commenceJob(JobFrontendRef theJobFrontend,
94              InetSocketAddress[] middlewareAddress,
95              InetSocketAddress[] worldAddress,
96              InetSocketAddress[] frontendAddress,
97              Properties properties,
98              String mainClassName,
99              String[] args)
100             throws IOException;
101 
102     /**
103      * Report that the job finished.
104      *
105      * @param theJobFrontend Job frontend that is calling this method.
106      * @exception IOException Thrown if an I/O error occurred.
107      * @throws java.io.IOException if any.
108      */
109     public void jobFinished(JobFrontendRef theJobFrontend)
110             throws IOException;
111 
112     /**
113      * Renew the lease on the job.
114      *
115      * @param theJobFrontend Job Frontend that is calling this method.
116      * @exception IOException Thrown if an I/O error occurred.
117      * @throws java.io.IOException if any.
118      */
119     public void renewLease(JobFrontendRef theJobFrontend)
120             throws IOException;
121 
122     /**
123      * Report the content for a previously-requested resource.
124      *
125      * @param theJobFrontend Job Frontend that is calling this method.
126      * @param resourceName Resource name.
127      * @param content Resource content, or null if resource not found.
128      * @exception IOException Thrown if an I/O error occurred.
129      * @throws java.io.IOException if any.
130      */
131     public void reportResource(JobFrontendRef theJobFrontend,
132             String resourceName,
133             byte[] content)
134             throws IOException;
135 
136     /**
137      * Report the content for a previously-requested resource.
138      *
139      * @param theJobFrontend Job Frontend that is calling this method.
140      * @param resourceName Resource name.
141      * @param content Resource content, or null if resource not found.
142      * @exception IOException Thrown if an I/O error occurred.
143      * @throws java.io.IOException if any.
144      */
145     public void reportResource(JobFrontendRef theJobFrontend,
146             String resourceName,
147             ByteSequence content)
148             throws IOException;
149 
150     /**
151      * Report the result of opening the given output file.
152      *
153      * @param theJobFrontend Job Frontend that is calling this method.
154      * @param bfd Backend file descriptor.
155      * @param ffd Frontend file descriptor if success.
156      * @param exc Null if success, exception if failure.
157      * @exception IOException Thrown if an I/O error occurred.
158      * @throws java.io.IOException if any.
159      */
160     public void outputFileOpenResult(JobFrontendRef theJobFrontend,
161             int bfd,
162             int ffd,
163             IOException exc)
164             throws IOException;
165 
166     /**
167      * Report the result of writing the given output file.
168      *
169      * @param theJobFrontend Job Frontend that is calling this method.
170      * @param ffd Frontend file descriptor.
171      * @param exc Null if success, exception if failure.
172      * @exception IOException Thrown if an I/O error occurred.
173      * @throws java.io.IOException if any.
174      */
175     public void outputFileWriteResult(JobFrontendRef theJobFrontend,
176             int ffd,
177             IOException exc)
178             throws IOException;
179 
180     /**
181      * Report the result of flushing the given output file.
182      *
183      * @param theJobFrontend Job Frontend that is calling this method.
184      * @param ffd Frontend file descriptor.
185      * @param exc Null if success, exception if failure.
186      * @exception IOException Thrown if an I/O error occurred.
187      * @throws java.io.IOException if any.
188      */
189     public void outputFileFlushResult(JobFrontendRef theJobFrontend,
190             int ffd,
191             IOException exc)
192             throws IOException;
193 
194     /**
195      * Report the result of closing the given output file.
196      *
197      * @param theJobFrontend Job Frontend that is calling this method.
198      * @param ffd Frontend file descriptor.
199      * @param exc Null if success, exception if failure.
200      * @exception IOException Thrown if an I/O error occurred.
201      * @throws java.io.IOException if any.
202      */
203     public void outputFileCloseResult(JobFrontendRef theJobFrontend,
204             int ffd,
205             IOException exc)
206             throws IOException;
207 
208     /**
209      * Report the result of opening the given input file.
210      *
211      * @param theJobFrontend Job Frontend that is calling this method.
212      * @param bfd Backend file descriptor.
213      * @param ffd Frontend file descriptor if success.
214      * @param exc Null if success, exception if failure.
215      * @exception IOException Thrown if an I/O error occurred.
216      * @throws java.io.IOException if any.
217      */
218     public void inputFileOpenResult(JobFrontendRef theJobFrontend,
219             int bfd,
220             int ffd,
221             IOException exc)
222             throws IOException;
223 
224     /**
225      * Report the result of reading the given input file.
226      *
227      * @param theJobFrontend Job Frontend that is calling this method.
228      * @param ffd Frontend file descriptor.
229      * @param buf Bytes read.
230      * @param len Number of bytes read, or -1 if EOF.
231      * @param exc Null if success, exception if failure.
232      * @exception IOException Thrown if an I/O error occurred.
233      * @throws java.io.IOException if any.
234      */
235     public void inputFileReadResult(JobFrontendRef theJobFrontend,
236             int ffd,
237             byte[] buf,
238             int len,
239             IOException exc)
240             throws IOException;
241 
242     /**
243      * Report the result of skipping the given input file.
244      *
245      * @param theJobFrontend Job Frontend that is calling this method.
246      * @param ffd Frontend file descriptor.
247      * @param len Number of bytes skipped.
248      * @param exc Null if success, exception if failure.
249      * @exception IOException Thrown if an I/O error occurred.
250      * @throws java.io.IOException if any.
251      */
252     public void inputFileSkipResult(JobFrontendRef theJobFrontend,
253             int ffd,
254             long len,
255             IOException exc)
256             throws IOException;
257 
258     /**
259      * Report the result of closing the given input file.
260      *
261      * @param theJobFrontend Job Frontend that is calling this method.
262      * @param ffd Frontend file descriptor.
263      * @param exc Null if success, exception if failure.
264      * @exception IOException Thrown if an I/O error occurred.
265      * @throws java.io.IOException if any.
266      */
267     public void inputFileCloseResult(JobFrontendRef theJobFrontend,
268             int ffd,
269             IOException exc)
270             throws IOException;
271 
272     /**
273      * Close communication with this Job Backend.
274      */
275     public void close();
276 
277 }