View Javadoc

1   package fr.in2p3.jsaga.impl.resource.description;
2   
3   import org.apache.log4j.Logger;
4   import org.ogf.saga.error.AuthenticationFailedException;
5   import org.ogf.saga.error.AuthorizationFailedException;
6   import org.ogf.saga.error.BadParameterException;
7   import org.ogf.saga.error.DoesNotExistException;
8   import org.ogf.saga.error.IncorrectStateException;
9   import org.ogf.saga.error.NoSuccessException;
10  import org.ogf.saga.error.NotImplementedException;
11  import org.ogf.saga.error.PermissionDeniedException;
12  import org.ogf.saga.error.TimeoutException;
13  import org.ogf.saga.resource.description.ComputeDescription;
14  import org.ogf.saga.resource.description.ResourceDescription;
15  
16  import java.util.ArrayList;
17  import java.util.Collection;
18  import java.util.Properties;
19  
20  /* ***************************************************
21   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
22   * ***             http://cc.in2p3.fr/             ***
23   * ***************************************************/
24  public class ComputeDescriptionImpl extends AbstractResourceDescriptionImpl implements ComputeDescription {
25      
26      private Logger m_logger = Logger.getLogger(ComputeDescriptionImpl.class);
27      public final static String DEFAULT_SIZE = "1";
28      public final static String DEFAULT_OS = "ANY";
29      public final static String DEFAULT_ARCH = "ANY";
30      public final static String DEFAULT_ADMINUSER = "root";
31      
32      /**
33       * The admin username on the compute resource
34       * This attribute is outside the SAGA specification.
35       */
36      public final static String ADMINUSER = "AdminUser";
37      
38      /** constructor for ResourceFactory.createDescription() */
39      public ComputeDescriptionImpl() {
40          super();
41          try {
42              this.setAttribute(ComputeDescription.SIZE, DEFAULT_SIZE);
43          } catch (Exception e) {
44              m_logger.error("Could not set attribute " + ComputeDescription.SIZE, e);
45          }
46          try {
47              this.setAttribute(ComputeDescription.MACHINE_ARCH, DEFAULT_ARCH);
48          } catch (Exception e) {
49              m_logger.error("Could not set attribute " + ComputeDescription.MACHINE_ARCH, e);
50          }
51          try {
52              this.setAttribute(ComputeDescription.MACHINE_OS, DEFAULT_OS);
53          } catch (Exception e) {
54              m_logger.error("Could not set attribute " + ComputeDescription.MACHINE_OS, e);
55          }
56          try {
57              this.setAttribute(ADMINUSER, DEFAULT_ADMINUSER);
58          } catch (Exception e) {
59              m_logger.error("Could not set attribute " + ADMINUSER, e);
60          }
61      }
62  
63      /** constructor for ResourceManager.getTemplate() */
64      public ComputeDescriptionImpl(Properties properties) {
65          super(properties);
66      }
67      
68      @Override
69      protected Collection<String> getScalarAttributes() {
70          Collection<String> c = super.getScalarAttributes();
71          c.add(ComputeDescription.MACHINE_ARCH);
72          c.add(ComputeDescription.MACHINE_OS);
73          c.add(ComputeDescription.ACCESS);
74          c.add(ComputeDescription.SIZE);
75          c.add(ComputeDescription.MEMORY);
76          c.add(ADMINUSER);
77          return c;
78      }
79  
80      @Override
81      protected Collection<String> getVectorAttributes() {
82          Collection<String> c = super.getVectorAttributes();
83          c.add(ComputeDescription.HOST_NAMES);
84          return c;
85      }
86      
87  }