View Javadoc

1   package fr.in2p3.jsaga.impl.resource;
2   
3   import fr.in2p3.jsaga.adaptor.resource.ResourceAdaptor;
4   import fr.in2p3.jsaga.engine.factories.ResourceAdaptorFactory;
5   import fr.in2p3.jsaga.impl.context.ContextImpl;
6   import fr.in2p3.jsaga.impl.resource.description.ComputeDescriptionImpl;
7   import fr.in2p3.jsaga.impl.resource.description.NetworkDescriptionImpl;
8   import fr.in2p3.jsaga.impl.resource.description.StorageDescriptionImpl;
9   import fr.in2p3.jsaga.impl.resource.manager.ResourceManagerImpl;
10  import fr.in2p3.jsaga.impl.session.SessionImpl;
11  import fr.in2p3.jsaga.sync.resource.SyncResourceFactory;
12  import org.ogf.saga.error.*;
13  import org.ogf.saga.resource.ResourceFactory;
14  import org.ogf.saga.resource.description.ComputeDescription;
15  import org.ogf.saga.resource.description.NetworkDescription;
16  import org.ogf.saga.resource.description.StorageDescription;
17  import org.ogf.saga.resource.manager.ResourceManager;
18  import org.ogf.saga.session.Session;
19  import org.ogf.saga.url.URL;
20  
21  import java.util.Map;
22  
23  /* ***************************************************
24   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
25   * ***             http://cc.in2p3.fr/             ***
26   * ***************************************************/
27  public abstract class AbstractSyncResourceFactoryImpl extends ResourceFactory implements SyncResourceFactory {
28      private ResourceAdaptorFactory m_adaptorFactory;
29  
30      /** constructor */
31      public AbstractSyncResourceFactoryImpl(ResourceAdaptorFactory adaptorFactory) {
32          m_adaptorFactory = adaptorFactory;
33      }
34  
35      public ComputeDescription doCreateComputeDescription() throws NotImplementedException, NoSuccessException {
36          return new ComputeDescriptionImpl();
37      }
38  
39      public NetworkDescription doCreateNetworkDescription() throws NotImplementedException, NoSuccessException {
40          return new NetworkDescriptionImpl();
41      }
42  
43      public StorageDescription doCreateStorageDescription() throws NotImplementedException, NoSuccessException {
44          return new StorageDescriptionImpl();
45      }
46  
47      public ResourceManager doCreateManagerSync(Session session, URL rm) throws NotImplementedException, BadParameterException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, TimeoutException, NoSuccessException {
48          if (rm!=null && !rm.toString().equals("")) {
49              // get context (security + config)
50              ContextImpl context;
51              try {
52                  context = ((SessionImpl) session).getBestMatchingContext(rm);
53              } catch (DoesNotExistException e) {
54                  throw new NoSuccessException(e);
55              } catch (PermissionDeniedException e) {
56                  throw new NoSuccessException(e);
57              }
58  
59              // create adaptor instance
60              ResourceAdaptor adaptor = m_adaptorFactory.getAdaptor(rm, context);
61  
62              // get attributes
63              Map attributes = m_adaptorFactory.getAttribute(rm, context);
64  
65              // connect to control/monitor services
66              m_adaptorFactory.connect(rm, adaptor, attributes, context);
67  
68              // create manager
69              return new ResourceManagerImpl(session, rm, adaptor);
70          } else {
71              throw new NotImplementedException("Resource discovery not yet implemented");
72          }
73      }
74  }