View Javadoc

1   /* 
2    * Copyright (c) 2007, Fraunhofer-Gesellschaft
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are
7    * met:
8    * 
9    * (1) Redistributions of source code must retain the above copyright
10   *     notice, this list of conditions and the disclaimer at the end.
11   *     Redistributions in binary form must reproduce the above copyright
12   *     notice, this list of conditions and the following disclaimer in
13   *     the documentation and/or other materials provided with the
14   *     distribution.
15   * 
16   * (2) Neither the name of Fraunhofer nor the names of its
17   *     contributors may be used to endorse or promote products derived
18   *     from this software without specific prior written permission.
19   * 
20   * DISCLAIMER
21   * 
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33   *  
34   */
35  package org.ogf.graap.wsag.api.sla;
36  
37  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
38  
39  /**
40   * ComputeJobTemplate
41   * 
42   * <pre>
43   * {@code
44   * <wsag:Template wsag:TemplateId="1"
45   *  xmlns:wsag="http://schemas.ggf.org/graap/2007/03/ws-agreement">
46   *  <wsag:Name>COMPUTE-JOB</wsag:Name>
47   *  <wsag:Context>
48   *      <wsag:ServiceProvider>AgreementResponder</wsag:ServiceProvider>
49   *      <wsag:TemplateId>1</wsag:TemplateId>
50   *      <wsag:TemplateName>COMPUTE-JOB</wsag:TemplateName>
51   *  </wsag:Context>
52   *  <wsag:Terms>
53   *      <wsag:All>
54   *          <wsag:ExactlyOne>
55   *              <wsag:ServiceDescriptionTerm wsag:Name="APPLICATION_SDT"
56   *                  wsag:ServiceName="COMPUTE_SERVICE">
57   *                  <jsdl:JobDefinition xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl">
58   *                      <jsdl:JobDescription>
59   *                          <jsdl:Application>
60   *                              <jsdl:ApplicationName>Application_1</jsdl:ApplicationName>
61   *                              <jsdl:ApplicationVersion>1</jsdl:ApplicationVersion>
62   *                              <jsdl:Description>Description</jsdl:Description>
63   *                          </jsdl:Application>
64   *                      </jsdl:JobDescription>
65   *                  </jsdl:JobDefinition>
66   *              </wsag:ServiceDescriptionTerm>
67   *              <wsag:ServiceDescriptionTerm wsag:Name="APPLICATION_SDT"
68   *                  wsag:ServiceName="COMPUTE_SERVICE">
69   *                  <jsdl:JobDefinition xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl">
70   *                      <jsdl:JobDescription>
71   *                          <jsdl:Application>
72   *                              <jsdl:ApplicationName>Application_2</jsdl:ApplicationName>
73   *                              <jsdl:ApplicationVersion>2</jsdl:ApplicationVersion>
74   *                              <jsdl:Description>Description</jsdl:Description>
75   *                          </jsdl:Application>
76   *                      </jsdl:JobDescription>
77   *                  </jsdl:JobDefinition>
78   *              </wsag:ServiceDescriptionTerm>
79   *          </wsag:ExactlyOne>
80   *          <wsag:ServiceDescriptionTerm wsag:Name="RESOURCE_SDT"
81   *              wsag:ServiceName="RESOURCE_PROVISIONING_SERVICE">
82   *              <jsdl:JobDefinition xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl">
83   *                  <jsdl:JobDescription>
84   *                      <jsdl:Resources>
85   *                          <jsdl:IndividualCPUTime>
86   *                              <jsdl:Exact>$RESOURCES.getIndividualCPUTime().
87   *                              getExactArray(0).getDoubleValue()</jsdl:Exact>
88   *                          </jsdl:IndividualCPUTime>
89   *                          <jsdl:IndividualCPUCount>
90   *                              <jsdl:Exact>$RESOURCES.getIndividualCPUCount().
91   *                              getExactArray(0).getDoubleValue()</jsdl:Exact>
92   *                          </jsdl:IndividualCPUCount>
93   *                          <jsdl:TotalResourceCount>
94   *                              <jsdl:Exact>$RESOURCES.getTotalResourceCount().
95   *                              getExactArray(0).getDoubleValue()</jsdl:Exact>
96   *                          </jsdl:TotalResourceCount>
97   *                      </jsdl:Resources>
98   *                  </jsdl:JobDescription>
99   *              </jsdl:JobDefinition>
100  *          </wsag:ServiceDescriptionTerm>
101  *      </wsag:All>
102  *  </wsag:Terms>
103  *  <wsag:CreationConstraints> 
104  *     ...
105  *     </wsag:CreationConstraints>
106  * </wsag:Template>
107  * }
108  * </pre>
109  * 
110  * @author Oliver Waeldrich
111  * 
112  */
113 public class ComputeJobTemplate extends AbstractComputeJobTemplate
114 {
115 
116     private static final String DEFAULT_TEMPLATE_NAME = "COMPUTE-JOB";
117 
118     private static final String DEFAULT_TEMPLATE_ID = "1";
119 
120     /**
121      * @param template
122      *            the agreement template XML representation
123      */
124     public ComputeJobTemplate( AgreementTemplateType template )
125     {
126         super( template );
127     }
128 
129     /**
130      * Creates an offer based on this template.
131      * 
132      * @return the new offer
133      * @throws Exception
134      *             failed to create the offer object
135      */
136     public ComputeJobOffer getOffer() throws Exception
137     {
138         return new ComputeJobOffer( getXMLObject() );
139     }
140 
141     /**
142      * @return the template name to which this pattern applies
143      */
144     public static String getDefaultTemplateName()
145     {
146         return DEFAULT_TEMPLATE_NAME;
147     }
148 
149     /**
150      * @return the template id to which this pattern applies
151      */
152     public static String getDefaultTemplateId()
153     {
154         return DEFAULT_TEMPLATE_ID;
155     }
156 
157 }