File: java_qconf_cmd.jsp

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (376 lines) | stat: -rw-r--r-- 15,183 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
 *
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 *
 *  Sun Microsystems Inc., March, 2001
 *
 *
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *   Copyright: 2001 by Sun Microsystems, Inc.
 *
 *   All Rights Reserved.
 *
 ************************************************************************/
/*___INFO__MARK_END__*/
/**
 *  Generated from java_jmx_jgdi.jsp
 *  !!! DO NOT EDIT THIS FILE !!!
 */
 

<%
    /*
    * Helper class to initialize option Map.
    */
   class MapInit {
      java.util.Map<String, String> nameToOpt = new java.util.HashMap<String, String>();

      //TODO LP: Is already defined in OptionAnnotation, however annotation not seen in this context
      static final int MAX_ARG_VALUE = Integer.MAX_VALUE / 8;
      
      public MapInit() {
         nameToOpt.put("Calendar","cal");
         nameToOpt.put("Checkpoint","ckpt");
         nameToOpt.put("Configuration","conf");
         nameToOpt.put("ClusterQueue","q");
         //nameToOpt.put("ExecHost","e");
         nameToOpt.put("Hostgroup","hgrp");
         nameToOpt.put("ParallelEnvironment","p");
         nameToOpt.put("Project","prj");
         //nameToOpt.put("ResourceQuotaSet","rqs");
         nameToOpt.put("User","user");
      }
      
      java.util.Map<String, String> getMap() {
         return nameToOpt;
      }
      
      public void genDefaultMethodsForType(String type) {
         if (!nameToOpt.containsKey(type)) {
            throw new IllegalStateException("<QConfCommand> failed: Unknown option type "+type);
         }
         String opt = (String) nameToOpt.get(type);
         genAddMethod(type, "-a"+opt, 0, 1);
         genAddFromFileMethod(type, "-A"+opt, 1, 0);
         genModifyMethod(type, "-m"+opt, 1, 0);
         genModifyFromFileMethod(type, "-M"+opt, 1, 0);
         genShowMethod(type, "-s"+opt, 1, MAX_ARG_VALUE);
         genShowListMethod(type, "-s"+opt+"l", 0, 0);
         genDeleteMethod(type, "-d"+opt, 1, MAX_ARG_VALUE);
      }
      
      void genAddMethod(String objectType, String optionString, int mandatory, int optional) {  
      %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void add<%=objectType%>(final OptionInfo oi) throws JGDIException {
      oi.optionDone();
      String arg = oi.getFirstArg();
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      // create an object with defaults set
      <%=objectType%> obj = new <%=objectType%>Impl(true);
      if (arg != null) {
         obj.setName(arg);
      }
      String userTypedText = runEditor(GEObjectEditor.getConfigurablePropertiesAsText(obj));

      if (userTypedText != null) {
         GEObjectEditor.updateObjectWithText(jgdi, obj, userTypedText);
         jgdi.add<%=objectType%>WithAnswer(obj, answer);
         printAnswers(answer);
      }
   }   
   <%
       } //end genAddMethod
       
       void genAddFromFileMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void addFromFile<%=objectType%>(final OptionInfo oi) throws JGDIException {
      //Just look at the filename
      final String fileName = oi.getArgs().get(0);
      oi.optionDone();
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      <%=objectType%> obj = new <%=objectType%>Impl(true);
      String inputText = readFile(oi);
      <%if (objectType.equals("Configuration")) {%>
      final String keyAttrValue = new File(fileName).getName();
      <%} else {%>
      final String keyAttrValue = getKeyAttributeValueFromString(err, "<%=objectType%>", fileName, inputText);
      <% } %>
      if (keyAttrValue == null) {
         return;
      }
      obj.setName(keyAttrValue);
      GEObjectEditor.updateObjectWithText(jgdi, obj, inputText);
      jgdi.add<%=objectType%>WithAnswer(obj, answer);
      printAnswers(answer);
   }  
   <%
       } //end genAddFromFileMethod  
       
       void genModifyMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void modify<%=objectType%>(final OptionInfo oi) throws JGDIException {
      final String arg = oi.getFirstArg();
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      <% if ( mandatory == 0 && optional == 0 ) { %>
      <%=objectType%> obj = jgdi.get<%=objectType%>WithAnswer(answer);
      <% } else { %>
      <%=objectType%> obj = jgdi.get<%=objectType%>WithAnswer(arg, answer);
      <% }%>
      if (obj != null) {
         //clear the answers from the get request
         answer.clear();
         String userTypedText = runEditor(GEObjectEditor.getConfigurablePropertiesAsText(obj));
         if (userTypedText != null) {
            GEObjectEditor.updateObjectWithText(jgdi, obj, userTypedText);
            jgdi.update<%=objectType%>WithAnswer(obj, answer);
         }
         printAnswers(answer);
      } else {
         err.println(getErrorMessage("InvalidObjectArgument", oi.getOd().getOption(), arg));
         setExitCode(getCustomExitCode("InvalidObjectArgument", oi.getOd().getOption()));
      }
      oi.optionDone();
   }  
   <%
       } //end genModifyMethod  
       
       void genModifyFromFileMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void modifyFromFile<%=objectType%>(final OptionInfo oi) throws JGDIException {
      //Just look at the filename
      final String fileName = oi.getArgs().get(0);
      oi.optionDone();
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      String inputText = readFile(oi);
      <%=objectType%> obj;
      <%if (objectType.equals("SchedConf")) {%>
      obj = jgdi.getSchedConfWithAnswer(answer);
      <%} else {%>
      final String keyAttrValue = getKeyAttributeValueFromString(err, "<%=objectType%>", fileName, inputText);
      if (keyAttrValue == null) {
         return;
      }
      obj = jgdi.get<%=objectType%>WithAnswer(keyAttrValue, answer);
      <%} %>
      printAnswers(answer);
      answer.clear();
      if (obj != null) {
          GEObjectEditor.updateObjectWithText(jgdi, obj, inputText);
          jgdi.update<%=objectType%>WithAnswer(obj, answer);
          printAnswers(answer);
      } else {
          //TODO LP: Check this is ever displayed
          <%if (objectType.equals("SchedConf")) {%>
          err.println(getErrorMessage("InvalidObjectArgument", oi.getOd().getOption()));
          <%} else {%>
          err.println(getErrorMessage("InvalidObjectArgument", oi.getOd().getOption(), keyAttrValue));
          <%} %>
          setExitCode(getCustomExitCode("InvalidObjectArgument", oi.getOd().getOption()));
      }
   }  
   <%
       } //end genModifyFromFileMethod  
       
       void genShowMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void show<%=objectType%>(final OptionInfo oi) throws JGDIException {
      final String arg = oi.getFirstArg();
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      <% if ( mandatory == 0 && optional == 0 ) { %>
      <%=objectType%> obj = jgdi.get<%=objectType%>WithAnswer(answer);
      <% } else { %>
      <%=objectType%> obj = jgdi.get<%=objectType%>WithAnswer(arg, answer);
      <% }%>
      printAnswers(answer);
      //Display error message in no such object exists
      if (obj == null) {
          err.println(getErrorMessage("InvalidObjectArgument", oi.getOd().getOption(), arg));
          setExitCode(getCustomExitCode("InvalidObjectArgument", oi.getOd().getOption()));
          return;
      }
      //Show the object
      String text = GEObjectEditor.getAllPropertiesAsText(obj);
      out.print(text);
   } 
   <%
       } //end genShowMethod  
       
       void genShowListMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void showList<%=objectType%>(final OptionInfo oi) throws JGDIException {
      List<JGDIAnswer> answer = new LinkedList<JGDIAnswer>();
      List< <%=objectType%> > list = (List< <%=objectType%> >)jgdi.get<%=objectType%>ListWithAnswer(answer);
      printAnswers(answer);
      List<String> values = new LinkedList<String>();
      for (<%=objectType%> obj : list) {
         values.add(obj.getName());
      }
      <% if (objectType.equals("Configuration") || objectType.equals("UserSet")) { %>
      values.remove("global");
      <%} else if (objectType.equals("ExecHost")) { %>
      values.remove("global");
      values.remove("template");
      <% } %>
      //Show correct error message if list is empty
      if (values.size() == 0) {
          err.println(getErrorMessage("NoObjectFound", oi.getOd().getOption()));
          setExitCode(getCustomExitCode("NoObjectFound", oi.getOd().getOption()));
          return;
      }
      //Otherwise print sorted list
      Collections.sort(values);
      for (String val : values) {
        out.println(val);
      }
      oi.optionDone();
   }   
   <%
       } //end genShowListMethod
       
       void genDeleteMethod(String objectType, String optionString, int mandatory, int optional) {
       %>
   /**
    *   Implements qconf <%=optionString%> option
    *   @param  oi <b>OptionInfo</b> option enviroment object
    *   @throws JGDIException on any error on the GDI layer
    */
   @OptionAnnotation(value = "<%=optionString%>", min = <%=mandatory%>, extra = <%=optional%>)
   public void delete<%=objectType%>(final OptionInfo oi) throws JGDIException {
      List<JGDIAnswer> answers = new LinkedList<JGDIAnswer>();
      int size = oi.getArgs().size();
      final String[] vals = oi.getArgs().toArray(new String[size]);
      oi.optionDone();
      jgdi.delete<%=objectType%>sWithAnswer(vals, answers);
      printAnswers(answers);
   }
   <%
       } //end genDeleteMethod  
       
  } //end Class MapInit
  
  
  // ---------------------------------------------------------------------------
  // Build Generator instances
  // ---------------------------------------------------------------------------
  MapInit init = new MapInit();
%>
package com.sun.grid.jgdi.util.shell;

import com.sun.grid.jgdi.JGDI;
import com.sun.grid.jgdi.JGDIException;
import com.sun.grid.jgdi.configuration.*;
import com.sun.grid.jgdi.util.shell.AnnotatedCommand;
import com.sun.grid.jgdi.util.shell.editor.EditorUtil;
import com.sun.grid.jgdi.util.shell.editor.GEObjectEditor;
import com.sun.grid.jgdi.util.shell.editor.TextEditor;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;

/**
 * Generated abstract class for handling generic JGDI objects.
 * Implements generic qconf command options.
 * NOTE: QConfCommand should extend this class.
 * @see com.sun.grid.jgdi.util.shell.QConfCommand
 */
public abstract class QConfCommandGenerated extends AnnotatedCommand {

   
<% for (String objType : init.getMap().keySet()) {
     init.genDefaultMethodsForType(objType);
  }
  //ExecHost
  init.genAddFromFileMethod("ExecHost", "-Ae", 1, 0);
  init.genModifyMethod("ExecHost", "-me", 1, 0);
  init.genModifyFromFileMethod("ExecHost", "-Me", 1, 0);
  init.genShowMethod("ExecHost", "-se", 1, init.MAX_ARG_VALUE);
  init.genShowListMethod("ExecHost", "-sel", 0, 0);
  init.genDeleteMethod("ExecHost", "-de", 1, init.MAX_ARG_VALUE);
  //SchedConf
  init.genModifyMethod("SchedConf","-msconf", 0, 0);
  init.genModifyFromFileMethod("SchedConf", "-Msconf", 1, 0);
  init.genShowMethod("SchedConf", "-ssconf",0, 0);
  //UserSet
  init.genAddFromFileMethod("UserSet","-Au", 1, 0);
  init.genModifyMethod("UserSet", "-mu", 1, 0);
  init.genModifyFromFileMethod("UserSet","-Mu",  1, 0);
  init.genShowMethod("UserSet", "-su", 1, init.MAX_ARG_VALUE);
  init.genShowListMethod("UserSet", "-sul", 0, 0);
  //Operator
  init.genShowListMethod("Operator", "-so", 0, 0);
  //Manager
  init.genShowListMethod("Manager", "-sm", 0, 0);
  //SubmitHost
  init.genShowListMethod("SubmitHost", "-ss", 0, 0);
  //AdminHost
  init.genShowListMethod("AdminHost", "-sh", 0, 0);
  //ResourceQuotaSet
  init.genAddMethod("ResourceQuotaSet", "-arqs", 0, init.MAX_ARG_VALUE);
  init.genAddFromFileMethod("ResourceQuotaSet", "-Arqs", 1, 0);
  init.genModifyFromFileMethod("ResourceQuotaSet", "-Mrqs", 1, 0);
  init.genShowListMethod("ResourceQuotaSet", "-srqsl", 0, 0);
  init.genDeleteMethod("ResourceQuotaSet", "-drqs", 1, init.MAX_ARG_VALUE);
%>
  <%@include file="java_qconf_cmd.static"%>
}