Debian Codegraph @

src/extensions/java/GendersTest/GendersTest.java

raw
1 /*****************************************************************************\
2 * Copyright (C) 2007-2019 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2001-2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Jim Garlick <[email protected]> and Albert Chu <[email protected]>.
6 * UCRL-CODE-2003-004.
7 *
8 * This file is part of Genders, a cluster configuration database.
9 * For details, see <http://www.llnl.gov/linux/genders/>.
10 *
11 * Genders is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 *
16 * Genders is distributed in the hope that it will be useful, but WITHOUT ANY
17 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with Genders. If not, see <http://www.gnu.org/licenses/>.
23 \*****************************************************************************/
24
25 import gov.llnl.lc.chaos.*;
26
27 class GendersTest
28 {
29 public static void main(String[] args)
30 {
31 try {
32
33 Genders gh = new Genders("GendersTest/testgenders");
34
35 try {
36 System.out.println("NumNodes = " + gh.getnumnodes());
37 System.out.println("Numattrs = " + gh.getnumattrs());
38 System.out.println("Maxattrs = " + gh.getmaxattrs());
39 System.out.println("Getnodname = " + gh.getnodename());
40 }
41 catch (Exception e) {
42 System.out.println("unexpected exception: " + e);
43 }
44
45 String[] nodes;
46
47 try {
48 nodes = gh.getnodes();
49 for (String tmp : nodes)
50 System.out.println("GetNodes All Node: " + tmp);
51
52 nodes = gh.getnodes("mgmt");
53 for (String tmp : nodes)
54 System.out.println("GetNodes mgmt Node: " + tmp);
55
56 nodes = gh.getnodes("foobarlalala");
57 for (String tmp : nodes)
58 System.out.println("GetNodes foobarlalala Node: " + tmp);
59
60 nodes = gh.getnodes("cfhost");
61 for (String tmp : nodes)
62 System.out.println("GetNodes cfhost Node: " + tmp);
63
64 nodes = gh.getnodes("cfhost", "foobar");
65 for (String tmp : nodes)
66 System.out.println("GetNodes cfhost=foobar Node: " + tmp);
67
68 nodes = gh.getnodes("cfhost", "hypei");
69 for (String tmp : nodes)
70 System.out.println("GetNodes cfhost=hypei Node: " + tmp);
71 }
72 catch (Exception e) {
73 System.out.println("unexpected exception: " + e);
74 }
75
76 String attrs[];
77 String vals[];
78
79 try {
80 attrs = gh.getattr();
81 for (String tmp : attrs)
82 System.out.println("getattr : " + tmp);
83
84 attrs = gh.getattr("hype355");
85 for (String tmp : attrs)
86 System.out.println("getattr hype355: " + tmp);
87
88 attrs = gh.getattr_all();
89 for (String tmp : attrs)
90 System.out.println("Getattr All : " + tmp);
91 }
92 catch (Exception e) {
93 System.out.println("unexpected exception: " + e);
94 }
95
96 boolean b;
97
98 try {
99 b = gh.isnode("foobar");
100 System.out.println("Isnode foobar : " + b);
101
102 b = gh.isnode("hype355");
103 System.out.println("Isnode hype355 : " + b);
104
105 b = gh.isnode(null);
106 System.out.println("Isnode null : " + b);
107
108 b = gh.isattr("foobar");
109 System.out.println("Isattr foobar : " + b);
110
111 b = gh.isattr("mgmt");
112 System.out.println("Isattr mgmt : " + b);
113
114 b = gh.isattrval("cfhost", "foobar");
115 System.out.println("Isattrval cfhost=foobar : " + b);
116
117 b = gh.isattrval("cfhost", "hypei");
118 System.out.println("Isattrval cfhost=hypei : " + b);
119 }
120 catch (Exception e) {
121 System.out.println("unexpected exception: " + e);
122 }
123
124 try {
125 nodes = gh.query("mgmt");
126 for (String tmp : nodes)
127 System.out.println("Query mgmt: " + tmp);
128
129 nodes = gh.query("mgmt||login");
130 for (String tmp : nodes)
131 System.out.println("Query mgmt||login: " + tmp);
132
133 nodes = gh.query("mgmt&&login");
134 for (String tmp : nodes)
135 System.out.println("Query mgmt&&login: " + tmp);
136
137 nodes = gh.query("~mgmt");
138 for (String tmp : nodes)
139 System.out.println("Query ~mgmt: " + tmp);
140
141 b = gh.testquery("mgmt");
142 System.out.println("TestQuery mgmt: " + b);
143
144 b = gh.testquery("login");
145 System.out.println("TestQuery login: " + b);
146
147 b = gh.testquery("hype355", "mgmt");
148 System.out.println("TestQuery mgmt: " + b);
149
150 b = gh.testquery("hype355", "login");
151 System.out.println("TestQuery login: " + b);
152
153 b = gh.testquery("hype356", "mgmt");
154 System.out.println("TestQuery mgmt: " + b);
155
156 b = gh.testquery("hype356", "login");
157 System.out.println("TestQuery login: " + b);
158 }
159 catch (Exception e) {
160 System.out.println("unexpected exception: " + e);
161 }
162
163 String val;
164
165 try {
166 val = gh.getattrval("mgmt");
167 System.out.println("Getattrval mgmt : " + val);
168
169 val = gh.getattrval("login");
170 System.out.println("Getattrval login : " + val);
171
172 val = gh.getattrval("cfhost");
173 System.out.println("Getattrval cfhost : " + val);
174
175 val = gh.getattrval("hype355", "mgmt");
176 System.out.println("Getattrval hype355 mgmt : " + val);
177
178 val = gh.getattrval("hype355", "login");
179 System.out.println("Getattrval hype355 login : " + val);
180 }
181 catch (Exception e) {
182 System.out.println("unexpected exception: " + e);
183 }
184
185 try {
186 val = gh.getattrval("hype355", "cfhost");
187 System.out.println("Getattrval hype355 cfhost : " + val);
188
189 val = gh.getattrval("hype356", "mgmt");
190 System.out.println("Getattrval hype356 mgmt : " + val);
191
192 val = gh.getattrval("hype356", "login");
193 System.out.println("Getattrval hype356 login : " + val);
194
195 val = gh.getattrval("hype356", "cfhost");
196 System.out.println("Getattrval hype356 cfhost : " + val);
197
198 b = gh.testattr("mgmt");
199 System.out.println("Testattr mgmt : " + b);
200
201 b = gh.testattr("login");
202 System.out.println("Testattr login : " + b);
203
204 b = gh.testattr("cfhost");
205 System.out.println("Testattr cfhost : " + b);
206
207 b = gh.testattr("hype355", "mgmt");
208 System.out.println("Testattr hype355 mgmt : " + b);
209
210 b = gh.testattr("hype355", "login");
211 System.out.println("Testattr hype355 login : " + b);
212
213 b = gh.testattr("hype355", "cfhost");
214 System.out.println("Testattr hype355 cfhost : " + b);
215
216 b = gh.testattr("hype356", "mgmt");
217 System.out.println("Testattr hype356 mgmt : " + b);
218
219 b = gh.testattr("hype356", "login");
220 System.out.println("Testattr hype356 login : " + b);
221
222 b = gh.testattr("hype356", "cfhost");
223 System.out.println("Testattr hype356 cfhost : " + b);
224
225 b = gh.testattrval("mgmt", "");
226 System.out.println("Testattrval mgmt= : " + b);
227
228 b = gh.testattrval("mgmt", "foobar");
229 System.out.println("Testattrval mgmt=foobar : " + b);
230
231 b = gh.testattrval("login", "");
232 System.out.println("Testattrval login= : " + b);
233
234 b = gh.testattrval("login", "foobar");
235 System.out.println("Testattrval login=foobar : " + b);
236
237 b = gh.testattrval("cfhost", "hypei");
238 System.out.println("Testattrval cfhost=hypei : " + b);
239
240 b = gh.testattrval("cfhost", "foobar");
241 System.out.println("Testattrval cfhost=foobar : " + b);
242
243 b = gh.testattrval("hype355", "mgmt", "");
244 System.out.println("Testattrval hype355 mgmt= : " + b);
245
246 b = gh.testattrval("hype355", "mgmt", "foobar");
247 System.out.println("Testattrval hype355 mgmt=foobar : " + b);
248
249 b = gh.testattrval("hype355", "login", "");
250 System.out.println("Testattrval hype355 login= : " + b);
251
252 b = gh.testattrval("hype355", "login", "foobar");
253 System.out.println("Testattrval hype355 login=foobar : " + b);
254
255 b = gh.testattrval("hype355", "cfhost", "hypei");
256 System.out.println("Testattrval hype355 cfhost=hypei : " + b);
257
258 b = gh.testattrval("hype355", "cfhost", "foobar");
259 System.out.println("Testattrval hype355 cfhost=foobar : " + b);
260
261 b = gh.testattrval("hype356", "mgmt", "");
262 System.out.println("Testattrval hype356 mgmt= : " + b);
263
264 b = gh.testattrval("hype356", "mgmt", "foobar");
265 System.out.println("Testattrval hype356 mgmt=foobar : " + b);
266
267 b = gh.testattrval("hype356", "login", "");
268 System.out.println("Testattrval hype356 login= : " + b);
269
270 b = gh.testattrval("hype356", "login", "foobar");
271 System.out.println("Testattrval hype356 login=foobar : " + b);
272
273 b = gh.testattrval("hype356", "cfhost", "hypei");
274 System.out.println("Testattrval hype356 cfhost=hypei : " + b);
275
276 b = gh.testattrval("hype356", "cfhost", "foobar");
277 System.out.println("Testattrval hype356 cfhost=foobar : " + b);
278 }
279 catch (Exception e) {
280 System.out.println("unexpected exception: " + e);
281 }
282
283 try {
284 gh.getattr("foobarnode");
285 }
286 catch (GendersExceptionNotfound e) {
287 System.out.println("Got not found exception : " + e);
288 }
289 catch (Exception e) {
290 System.out.println("unexpected exception: " + e);
291 }
292
293 gh.cleanup();
294
295 try {
296 System.out.println("NumNodes = " + gh.getnumnodes());
297 }
298 catch (GendersExceptionInternal e) {
299 System.out.println("Got internal exception: " + e);
300 }
301 catch (Exception e) {
302 System.out.println("unexpected exception: " + e);
303 }
304 }
305 catch (Exception e) {
306 System.out.println("unexpected exception: " + e);
307 }
308 }
309 }