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

« back to all changes in this revision

Viewing changes to source/libs/jgdi/examples/src/com/sun/grid/jgdi/examples/ConfigExample.java

  • 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
package com.sun.grid.jgdi.examples;
 
33
 
 
34
import com.sun.grid.jgdi.JGDI;
 
35
import com.sun.grid.jgdi.JGDIException;
 
36
import com.sun.grid.jgdi.JGDIFactory;
 
37
import com.sun.grid.jgdi.configuration.Checkpoint;
 
38
import com.sun.grid.jgdi.configuration.ConfigurationFactory;
 
39
import com.sun.grid.jgdi.configuration.JGDIAnswer;
 
40
import java.util.LinkedList;
 
41
import java.util.List;
 
42
 
 
43
/**
 
44
 * Simple example which demonstrates how to add/update/delete configuration
 
45
 * objects of the Sun™ Grid Engine
 
46
 *
 
47
 */
 
48
public class ConfigExample {
 
49
 
 
50
    public static void main(String[] args) {
 
51
 
 
52
        try {
 
53
            String url = "bootstrap:///opt/sge@default:1026";
 
54
 
 
55
            if (args.length == 1) {
 
56
                url = args[0];
 
57
            }
 
58
 
 
59
            JGDI jgdi = JGDIFactory.newInstance(url);
 
60
            List<JGDIAnswer> answers = new LinkedList<JGDIAnswer>();
 
61
 
 
62
            try {
 
63
                System.out.println("Successfully connected to " + url);
 
64
 
 
65
                // Create a new checkpoint object which intialized with default values
 
66
                Checkpoint ckpt = ConfigurationFactory.createCheckpointWithDefaults();
 
67
                ckpt.setName("sample");
 
68
                ckpt.setCkptCommand("/usr/bin/ckpt");
 
69
                ckpt.setCkptDir("/tmp");
 
70
 
 
71
                jgdi.addCheckpointWithAnswer(ckpt, answers);
 
72
                for (JGDIAnswer a : answers) {
 
73
                    System.out.println(a.getText());
 
74
                }
 
75
                try {
 
76
                    ckpt = jgdi.getCheckpoint(ckpt.getName());
 
77
                    ckpt.setRestCommand("/tmp/blubber");
 
78
                    jgdi.updateCheckpointWithAnswer(ckpt, answers);
 
79
                    for (JGDIAnswer a : answers) {
 
80
                        System.out.println(a.getText());
 
81
                    }
 
82
                } finally {
 
83
                    jgdi.deleteCheckpointWithAnswer(ckpt.getName(), answers);
 
84
                    for (JGDIAnswer a : answers) {
 
85
                        System.out.println(a.getText());
 
86
                    }
 
87
                }
 
88
            } finally {
 
89
                jgdi.close();
 
90
            }
 
91
        } catch (JGDIException e) {
 
92
            e.printStackTrace();
 
93
        }
 
94
 
 
95
    }
 
96
}