View Javadoc

1   package fr.in2p3.jsaga.impl.job.staging.mgr;
2   
3   import fr.in2p3.jsaga.adaptor.job.control.staging.StagingJobAdaptorTwoPhase;
4   import fr.in2p3.jsaga.adaptor.job.control.staging.StagingTransfer;
5   import fr.in2p3.jsaga.impl.job.instance.AbstractSyncJobImpl;
6   import org.ogf.saga.error.*;
7   import org.ogf.saga.file.Directory;
8   import org.ogf.saga.file.FileFactory;
9   import org.ogf.saga.namespace.Flags;
10  import org.ogf.saga.url.URL;
11  import org.ogf.saga.url.URLFactory;
12  
13  /* ***************************************************
14   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
15   * ***             http://cc.in2p3.fr/             ***
16   * ***************************************************
17   * File:   DataStagingManagerThroughSandboxTwoPhase
18   * Author: sreynaud (sreynaud@in2p3.fr)
19   * Date:   18 mars 2010
20   * ***************************************************
21   * Description:                                      */
22  /**
23   *
24   */
25  public class DataStagingManagerThroughSandboxTwoPhase extends DataStagingManagerThroughSandbox {
26      public DataStagingManagerThroughSandboxTwoPhase(StagingJobAdaptorTwoPhase adaptor, String uniqId) throws NotImplementedException, BadParameterException, NoSuccessException {
27          super(adaptor, uniqId);
28      }
29  
30      public void preStaging(AbstractSyncJobImpl job, String nativeJobId) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, IncorrectStateException, NoSuccessException {
31          StagingJobAdaptorTwoPhase adaptor = (StagingJobAdaptorTwoPhase) m_adaptor;
32  
33          // create intermediary directory
34          String stagingDir = adaptor.getStagingDirectory(nativeJobId);
35          if (stagingDir != null) {
36              URL url = URLFactory.createURL(JSAGA_FACTORY, stagingDir);
37              Directory dir = null;
38              try {
39                  dir = FileFactory.createDirectory(JSAGA_FACTORY, job.getSession(), url, Flags.CREATE.getValue());
40              } catch (IncorrectURLException e) {
41                  throw new NoSuccessException(e);
42              } catch (AlreadyExistsException e) {
43                  throw new NoSuccessException(e);
44              }finally{
45                  if(dir != null){
46      	        	try{
47      	        		dir.close();
48      	        	}catch (Exception e) {
49      					// Ignore it: A problem during the close should not be a problem.
50      				}
51              	}
52              }
53          }
54  
55          // for each input file
56          for (StagingTransfer transfer : adaptor.getInputStagingTransfer(nativeJobId)) {
57              transfer(job.getSession(), transfer);
58          }
59      }
60  }