~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jgdi/templates/c_evc_type_mapping.jsp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
<%
 
33
   com.sun.grid.cull.JavaHelper jh = (com.sun.grid.cull.JavaHelper)params.get("javaHelper");
 
34
   com.sun.grid.cull.CullDefinition cullDef = (com.sun.grid.cull.CullDefinition)params.get("cullDef");
 
35
   com.sun.grid.cull.CullObject cullObj = (com.sun.grid.cull.CullObject)params.get("cullObj");
 
36
 
 
37
   if( cullObj == null ) {
 
38
     throw new IllegalStateException("param cullObj not found");
 
39
   }
 
40
 
 
41
   if( cullObj.getIdlName() == null ) {
 
42
     throw new IllegalStateException("cullObj " + cullObj.getName() + " is has no a idl name");
 
43
   }
 
44
 
 
45
 
 
46
   if( cullDef == null ) {
 
47
     throw new IllegalStateException("param cullDef not found");
 
48
   }
 
49
 
 
50
   String name = jh.getClassName(cullObj);
 
51
 
 
52
   String fullClassName = jh.getFullClassName(cullObj);
 
53
   
 
54
   fullClassName = fullClassName.replace('.', '/');
 
55
 
 
56
   String methodName = "Java_com_sun_grid_jgdi_jni_JGDI_fill" + name + "List";
 
57
 
 
58
   String listName = cullObj.getListName();
 
59
 
 
60
   if (listName == null) {
 
61
     // we not a ILISTDEF, return
 
62
     return;
 
63
   }
 
64
%>
 
65
#include <ctype.h>
 
66
#include <string.h>
 
67
#include <jni.h>
 
68
#include "basis_types.h"
 
69
#include "cull.h"
 
70
#include "commlib.h"
 
71
#include "sgermon.h"
 
72
#include "sge_all_listsL.h"
 
73
#include "sge_answer.h"
 
74
#include "sge_prog.h"
 
75
#include "sge_bootstrap.h"
 
76
#include "sge_gdi_ctx.h"
 
77
#include "cl_errors.h"
 
78
#include "sge_log.h"
 
79
#include "sge_error_class.h"
 
80
#include "jgdi_common.h"
 
81
#include "jgdi.h"
 
82
/*
 
83
   ILISTDEF(<%=cullObj.getName()%>, <%=cullObj.getIdlName()%>, <%=cullObj.getListName()%>, <%
 
84
    for(int i = 0; i < cullObj.getParamCount(); i++ ) { 
 
85
       if ( i > 0 ) { %> , <% } %> <%=cullObj.getParam(i)%> <% } %> )
 
86
*/
 
87
/* ------------------ GET --------------------------------------------------- */
 
88
/*
 
89
 * Class:     com_sun_grid_jgdi_jni_JGDI
 
90
 * Method:    get<%=jh.getClassName(cullObj)%>List
 
91
 */
 
92
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject list) {
 
93
 
 
94
   jclass cls;    
 
95
   jclass obj_class;
 
96
    
 
97
   /* receive Cull Object */
 
98
   lList *lp = NULL;
 
99
   const lDescr *descr = NULL;
 
100
   lList *alp = NULL;
 
101
   lCondition *where = NULL;
 
102
   static lEnumeration *what  = NULL;
 
103
   jmethodID add_mid = NULL;
 
104
   lListElem *ep = NULL;
 
105
   jobject obj;
 
106
   char classname[] = "<%=fullClassName%>";
 
107
   sge_gdi_ctx_class_t *ctx = NULL; 
 
108
      
 
109
   sge_error_class_t *eh = NULL;
 
110
   
 
111
   
 
112
   DENTER(TOP_LAYER, "<%=methodName%>");
 
113
   
 
114
   /* create error handler */
 
115
   eh = sge_error_class_create();
 
116
   if (!eh) {
 
117
      THROW_ERROR((env, "sge_error_class_create failed"));
 
118
      DEXIT;
 
119
      return;
 
120
   }
 
121
   
 
122
   /* create what and where */
 
123
   if (!what) {
 
124
      what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
 
125
   }   
 
126
 
 
127
   /* get context */
 
128
   ctx = getGDIContext(env, jgdi, &alp);
 
129
 
 
130
   alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_GET, &lp, where, what, NULL);
 
131
   /* if error throw exception */
 
132
   if(answer_list_has_error(&alp)) {
 
133
      dstring ds = DSTRING_INIT;
 
134
      answer_list_to_dstring(alp, &ds);
 
135
      THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
 
136
      sge_dstring_free(&ds);
 
137
      lFreeList(&alp);
 
138
      DEXIT;
 
139
      return;
 
140
   }
 
141
   
 
142
   cls = (*env)->GetObjectClass(env, list);
 
143
   obj_class = (*env)->FindClass(env, classname);
 
144
   
 
145
   if (!obj_class) {
 
146
      DEXIT;
 
147
      return;
 
148
   }
 
149
 
 
150
   add_mid = get_methodid(env, cls, "add", "(Ljava/lang/Object;)Z", &alp);
 
151
   if (add_mid == 0) {
 
152
      dstring ds = DSTRING_INIT;
 
153
      answer_list_to_dstring(alp, &ds);
 
154
      THROW_ERROR((env, "get_methodid failed: %s", sge_dstring_get_string(&ds)));
 
155
      sge_dstring_free(&ds);
 
156
      lFreeList(&alp);
 
157
      DEXIT;
 
158
      return;
 
159
   }
 
160
   
 
161
   descr = lGetListDescr(lp);
 
162
   for_each (ep, lp) {
 
163
      // convert to Java representation
 
164
      obj = listelem_to_obj(env, ep, descr, obj_class, &alp);
 
165
      if (!obj) {
 
166
         DEXIT;
 
167
         return;
 
168
      }   
 
169
      (*env)->CallVoidMethod( env, list, add_mid, obj );
 
170
   }
 
171
 
 
172
   // if error throw exception
 
173
   if(answer_list_has_error(&alp)) {
 
174
      dstring ds = DSTRING_INIT;
 
175
      answer_list_to_dstring(alp, &ds);
 
176
      THROW_ERROR((env, "listelem_to_obj failed: %s", sge_dstring_get_string(&ds)));
 
177
      sge_dstring_free(&ds);
 
178
   }
 
179
 
 
180
   lFreeList(&alp);
 
181
   DEXIT;
 
182
}
 
183
 
 
184
<%
 
185
     methodName = "Java_com_sun_grid_jgdi_jni_JGDI_add" + name;
 
186
%>
 
187
/* -------------- ADD ------------------------------------------------------- */
 
188
/*
 
189
 * Class:     com_sun_grid_jgdi_jni_JGDI
 
190
 * Method:    add<%=jh.getClassName(cullObj)%>
 
191
 * Signature: (L<%=fullClassName%>;)V
 
192
 */
 
193
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject jobj)
 
194
{
 
195
   lList *lp = NULL;
 
196
   lList *alp = NULL;
 
197
   lCondition *where = NULL;
 
198
   static lEnumeration *what  = NULL;
 
199
   lListElem *ep = NULL;
 
200
   sge_gdi_ctx_class_t *ctx = NULL;
 
201
   sge_error_class_t *eh = NULL;
 
202
   
 
203
   DENTER( TOP_LAYER, "<%=methodName%>" );
 
204
 
 
205
   eh = sge_error_class_create();
 
206
   if (!eh) {
 
207
      THROW_ERROR((env, "sge_error_class_create failed"));
 
208
      DEXIT;
 
209
      return;
 
210
   }   
 
211
   
 
212
   /* create what and where */
 
213
   if (!what) {
 
214
      what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
 
215
   }   
 
216
 
 
217
   ep = obj_to_listelem(env, jobj, <%=cullObj.getName()%>, &alp);
 
218
 
 
219
   if (answer_list_has_error(&alp)) {
 
220
      dstring ds = DSTRING_INIT;
 
221
      answer_list_to_dstring(alp, &ds);
 
222
      THROW_ERROR((env, "obj_to_listelem: %s", sge_dstring_get_string(&ds)));
 
223
      sge_dstring_free(&ds);
 
224
      DEXIT;
 
225
      return; 
 
226
   }
 
227
 
 
228
   lp = lCreateList("<%=listName%> list to add", <%=cullObj.getName()%>);
 
229
   lAppendElem(lp, ep);
 
230
 
 
231
   /* get context */
 
232
   ctx = getGDIContext(env, jgdi, &alp);
 
233
 
 
234
   /* add to <%=cullObj.getName()%> list */
 
235
 
 
236
   alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_ADD, &lp, where, what, NULL);
 
237
   lFreeList(&lp);
 
238
 
 
239
   /* if error throw exception */
 
240
   if (answer_list_has_error(&alp)) {
 
241
      dstring ds = DSTRING_INIT;
 
242
      answer_list_to_dstring(alp, &ds);
 
243
      THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
 
244
      sge_dstring_free(&ds);
 
245
   }
 
246
 
 
247
   lFreeList(&alp);
 
248
 
 
249
   DEXIT;
 
250
}
 
251
 
 
252
 
 
253
<%
 
254
     methodName = "Java_com_sun_grid_jgdi_jni_JGDI_delete" + name;
 
255
%>
 
256
 
 
257
/*
 
258
 * Class:     com_sun_grid_jgdi_jni_JGDI
 
259
 * Method:    delete<%=name%>
 
260
 * Signature: (L<%=fullClassName%>;)V
 
261
 */
 
262
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject jobj)
 
263
{
 
264
   lList *lp = NULL;
 
265
   lList *alp = NULL;
 
266
   lCondition *where = NULL;
 
267
   static lEnumeration *what  = NULL;
 
268
   lListElem *ep = NULL;
 
269
   sge_gdi_ctx_class_t *ctx = NULL;
 
270
 
 
271
   DENTER( TOP_LAYER, "<%=methodName%>" );
 
272
   
 
273
   /* create what and where */
 
274
   if (!what) {
 
275
      what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
 
276
   }   
 
277
 
 
278
   ep = obj_to_listelem(env, jobj, <%=cullObj.getName()%>, &alp);
 
279
 
 
280
   if (answer_list_has_error(&alp)) {
 
281
      dstring ds = DSTRING_INIT;
 
282
      answer_list_to_dstring(alp, &ds);
 
283
      THROW_ERROR((env, "obj_to_listelem: %s", sge_dstring_get_string(&ds)));
 
284
      sge_dstring_free(&ds);
 
285
      DEXIT;
 
286
      return; 
 
287
   }
 
288
 
 
289
   lp = lCreateList("<%=listName%> list to delete", <%=cullObj.getName()%>);
 
290
   lAppendElem(lp, ep);
 
291
 
 
292
   /* get context */
 
293
   ctx = getGDIContext(env,jgdi, &alp);
 
294
 
 
295
   /* delete from <%=cullObj.getName()%> list */
 
296
   alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_DEL, &lp, where, what, NULL);
 
297
   lFreeList(&lp);
 
298
 
 
299
   /* if error throw exception */
 
300
   if (answer_list_has_error(&alp)) {
 
301
      dstring ds = DSTRING_INIT;
 
302
      answer_list_to_dstring(alp, &ds);
 
303
      THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
 
304
      sge_dstring_free(&ds);
 
305
   }
 
306
 
 
307
   lFreeList(&alp);
 
308
 
 
309
   DEXIT;
 
310
}
 
311
 
 
312