View Javadoc

1   package fr.in2p3.jsaga.impl.job.instance;
2   
3   import fr.in2p3.jsaga.impl.job.service.AbstractSyncJobServiceImpl;
4   import fr.in2p3.jsaga.impl.job.staging.mgr.DataStagingManager;
5   import fr.in2p3.jsaga.impl.task.AbstractThreadedTask;
6   import org.ogf.saga.error.*;
7   import org.ogf.saga.job.Job;
8   import org.ogf.saga.job.JobDescription;
9   import org.ogf.saga.session.Session;
10  import org.ogf.saga.task.Task;
11  import org.ogf.saga.task.TaskMode;
12  
13  import java.io.InputStream;
14  import java.io.OutputStream;
15  
16  /* ***************************************************
17  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
18  * ***             http://cc.in2p3.fr/             ***
19  * ***************************************************
20  * File:   AbstractAsyncJobImpl
21  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
22  * Date:   26 oct. 2007
23  * ***************************************************
24  * Description:                                      */
25  /**
26   *
27   */
28  public abstract class AbstractAsyncJobImpl extends AbstractSyncJobImpl implements Job {
29      /** constructor for submission */
30      protected AbstractAsyncJobImpl(Session session, String nativeJobDesc, JobDescription jobDesc, DataStagingManager stagingMgr, String uniqId, AbstractSyncJobServiceImpl service) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, TimeoutException, NoSuccessException {
31          super(session, nativeJobDesc, jobDesc, stagingMgr, uniqId, service);
32      }
33  
34      /** constructor for control and monitoring only */
35      protected AbstractAsyncJobImpl(Session session, String nativeJobId, DataStagingManager stagingMgr, AbstractSyncJobServiceImpl service) throws NotImplementedException, BadParameterException, TimeoutException, NoSuccessException {
36          super(session, nativeJobId, stagingMgr, service);
37      }
38      
39      //////////////////////////////////////////// interface Job ////////////////////////////////////////////
40  
41      public Task<Job, JobDescription> getJobDescription(TaskMode mode) throws NotImplementedException {
42          return new AbstractThreadedTask<Job,JobDescription>(mode) {
43              public JobDescription invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
44                  return AbstractAsyncJobImpl.super.getJobDescriptionSync();
45              }
46          };
47      }
48  
49      public Task<Job, OutputStream> getStdin(TaskMode mode) throws NotImplementedException {
50          return new AbstractThreadedTask<Job,OutputStream>(mode) {
51              public OutputStream invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
52                  return AbstractAsyncJobImpl.super.getStdinSync();
53              }
54          };
55      }
56  
57      public Task<Job, InputStream> getStdout(TaskMode mode) throws NotImplementedException {
58          return new AbstractThreadedTask<Job,InputStream>(mode) {
59              public InputStream invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
60                  return AbstractAsyncJobImpl.super.getStdoutSync();
61              }
62          };
63      }
64  
65      public Task<Job, InputStream> getStderr(TaskMode mode) throws NotImplementedException {
66          return new AbstractThreadedTask<Job,InputStream>(mode) {
67              public InputStream invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
68                  return AbstractAsyncJobImpl.super.getStderrSync();
69              }
70          };
71      }
72  
73      public Task<Job, Void> suspend(TaskMode mode) throws NotImplementedException {
74          return new AbstractThreadedTask<Job,Void>(mode) {
75              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
76                  AbstractAsyncJobImpl.super.suspendSync();
77                  return null;
78              }
79          };
80      }
81  
82      public Task<Job, Void> resume(TaskMode mode) throws NotImplementedException {
83          return new AbstractThreadedTask<Job,Void>(mode) {
84              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
85                  AbstractAsyncJobImpl.super.resumeSync();
86                  return null;
87              }
88          };
89      }
90  
91      public Task<Job, Void> checkpoint(TaskMode mode) throws NotImplementedException {
92          return new AbstractThreadedTask<Job,Void>(mode) {
93              public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
94                  AbstractAsyncJobImpl.super.checkpointSync();
95                  return null;
96              }
97          };
98      }
99  
100     public Task<Job, Void> migrate(TaskMode mode, final JobDescription jd) throws NotImplementedException {
101         return new AbstractThreadedTask<Job,Void>(mode) {
102             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
103                 AbstractAsyncJobImpl.super.migrateSync(jd);
104                 return null;
105             }
106         };
107     }
108 
109     public Task<Job, Void> signal(TaskMode mode, final int signum) throws NotImplementedException {
110         return new AbstractThreadedTask<Job,Void>(mode) {
111             public Void invoke() throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
112                 AbstractAsyncJobImpl.super.signalSync(signum);
113                 return null;
114             }
115         };
116     }
117 }