1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
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
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.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.jgdi.jni;
34
import com.sun.grid.jgdi.JGDIException;
35
import com.sun.grid.jgdi.configuration.JGDIAnswer;
36
import com.sun.grid.jgdi.monitoring.*;
38
import java.util.ArrayList;
39
import java.util.LinkedList;
40
import java.util.List;
41
import java.util.logging.Level;
42
import java.util.logging.LogRecord;
43
import java.util.logging.Logger;
48
public abstract class JGDIBaseImpl implements com.sun.grid.jgdi.JGDIBase {
50
private final static Logger log = Logger.getLogger(JGDIBaseImpl.class.getName());
51
private int ctxIndex = -1;
53
private final static List<JGDIBaseImpl> instances = new LinkedList<JGDIBaseImpl>();
54
private static boolean shutdown = false;
56
public void init(String url) throws JGDIException {
57
synchronized (instances) {
59
throw new JGDIException("shutdown in progress");
63
ctxIndex = nativeInit(url);
64
if (log.isLoggable(Level.FINE)) {
65
log.log(Level.FINE, "native connection with id {1} established (url={0})", new Object[]{url, ctxIndex});
73
public static void resetShutdown() {
74
synchronized (instances) {
79
public static void closeAllConnections() {
80
List<JGDIBaseImpl> currentInstances = null;
81
synchronized (instances) {
83
currentInstances = new ArrayList<JGDIBaseImpl>(instances);
85
for (JGDIBaseImpl jgdi : currentInstances) {
88
} catch (JGDIException ex) {
89
LogRecord lr = new LogRecord(Level.FINE, "close of connection {0} failed");
90
lr.setParameters(new Object[]{jgdi.ctxIndex});
97
public void close() throws com.sun.grid.jgdi.JGDIException {
100
tmpCtxIndex = ctxIndex;
103
if (tmpCtxIndex >= 0) {
104
log.log(Level.FINE, "Closing connection with id {0}", tmpCtxIndex);
105
synchronized (instances) {
106
instances.remove(this);
108
nativeClose(tmpCtxIndex);
109
if (log.isLoggable(Level.FINE)) {
110
log.log(Level.FINE, "Connection with id {0} closed", tmpCtxIndex);
115
public File getSGERoot() throws JGDIException {
116
if (sgeRoot == null) {
117
sgeRoot = new File(nativeGetSGERoot());
122
public String getSGECell() throws JGDIException {
123
return nativeGetSGECell();
126
public String getAdminUser() throws JGDIException {
127
return nativeGetAdminUser();
130
public String getActQMaster() throws JGDIException {
131
return nativeGetActQMaster();
134
public String getSchedulerHost() throws JGDIException {
135
return nativeGetSchedulerHost();
138
public QHostResult execQHost(QHostOptions options) throws JGDIException {
139
QHostResultImpl ret = new QHostResultImpl();
140
nativeExecQHost(options, ret);
144
public List<ClusterQueueSummary> getClusterQueueSummary(ClusterQueueSummaryOptions options) throws JGDIException {
145
List<ClusterQueueSummary> ret = new LinkedList<ClusterQueueSummary>();
146
nativeFillClusterQueueSummary(options, ret);
150
public QueueInstanceSummaryResult getQueueInstanceSummary(QueueInstanceSummaryOptions options) throws JGDIException {
151
QueueInstanceSummaryResultImpl ret = new QueueInstanceSummaryResultImpl();
152
nativeFillQueueInstanceSummary(options, ret);
156
public QQuotaResult getQQuota(QQuotaOptions options) throws JGDIException {
157
QQuotaResultImpl ret = new QQuotaResultImpl();
158
nativeGetQQuota(options, ret);
162
public void cleanQueuesWithAnswer(String[] queues, List<JGDIAnswer> answers) throws JGDIException {
163
nativeCleanQueuesWithAnswer(queues, answers);
166
public void cleanQueues(String[] queues) throws JGDIException {
167
cleanQueuesWithAnswer(queues, null);
170
public void unsuspendWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
171
nativeUnsuspendWithAnswer(queues, force, answers);
174
public void unsuspend(String[] queues, boolean force) throws JGDIException {
175
unsuspendWithAnswer(queues, force, null);
178
public void unsuspendQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
179
nativeUnsuspendQueuesWithAnswer(queues, force, answers);
182
public void unsuspendQueues(String[] queues, boolean force) throws JGDIException {
183
unsuspendQueuesWithAnswer(queues, force, null);
186
public void unsuspendJobsWithAnswer(String[] jobs, boolean force, List<JGDIAnswer> answers) throws JGDIException {
187
nativeUnsuspendJobsWithAnswer(jobs, force, answers);
190
public void unsuspendJobs(String[] jobs, boolean force) throws JGDIException {
191
unsuspendJobsWithAnswer(jobs, force, null);
194
public void suspendWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
195
nativeSuspendWithAnswer(queues, force, answers);
198
public void suspend(String[] queues, boolean force) throws JGDIException {
199
suspendWithAnswer(queues, force, null);
202
public void suspendQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
203
nativeSuspendQueuesWithAnswer(queues, force, answers);
206
public void suspendQueues(String[] queues, boolean force) throws JGDIException {
207
suspendQueuesWithAnswer(queues, force, null);
210
public void suspendJobsWithAnswer(String[] jobs, boolean force, List<JGDIAnswer> answers) throws JGDIException {
211
nativeSuspendJobsWithAnswer(jobs, force, answers);
214
public void suspendJobs(String[] jobs, boolean force) throws JGDIException {
215
suspendJobsWithAnswer(jobs, force, null);
218
public void rescheduleJobsWithAnswer(String[] jobs, boolean force, List<JGDIAnswer> answers) throws JGDIException {
219
nativeRescheduleJobsWithAnswer(jobs, force, answers);
222
public void rescheduleJobs(String[] jobs, boolean force) throws JGDIException {
223
rescheduleJobsWithAnswer(jobs, force, null);
226
public void rescheduleQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
227
nativeRescheduleQueuesWithAnswer(queues, force, answers);
230
public void rescheduleQueues(String[] queues, boolean force) throws JGDIException {
231
rescheduleQueuesWithAnswer(queues, force, null);
234
public void rescheduleWithAnswer(String[] queue_or_job, boolean force, List<JGDIAnswer> answers) throws JGDIException {
235
nativeRescheduleWithAnswer(queue_or_job, force, answers);
238
public void reschedule(String[] queue_or_job, boolean force) throws JGDIException {
239
rescheduleWithAnswer(queue_or_job, force, null);
242
public void clearJobsWithAnswer(String[] jobs, boolean force, List<JGDIAnswer> answers) throws JGDIException {
243
nativeClearJobsWithAnswer(jobs, force, answers);
246
public void clearJobs(String[] jobs, boolean force) throws JGDIException {
247
clearJobsWithAnswer(jobs, force, null);
250
public void clearQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
251
nativeClearQueuesWithAnswer(queues, force, answers);
254
public void clearQueues(String[] queues, boolean force) throws JGDIException {
255
clearQueuesWithAnswer(queues, force, null);
258
public void disableQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
259
nativeDisableQueuesWithAnswer(queues, force, answers);
262
public void disableQueues(String[] queues, boolean force) throws JGDIException {
263
disableQueuesWithAnswer(queues, force, null);
266
public void enableQueuesWithAnswer(String[] queues, boolean force, List<JGDIAnswer> answers) throws JGDIException {
267
nativeEnableQueuesWithAnswer(queues, force, answers);
270
public void enableQueues(String[] queues, boolean force) throws JGDIException {
271
enableQueuesWithAnswer(queues, force, null);
274
public void killAllExecdsWithAnswer(boolean terminateJobs, List<JGDIAnswer> answers) throws JGDIException {
275
nativeKillAllExecdsWithAnswer(terminateJobs, answers);
278
public void killAllExecds(boolean terminateJobs) throws JGDIException {
279
killAllExecdsWithAnswer(terminateJobs, null);
282
public void killExecdWithAnswer(String[] hosts, boolean terminateJobs, List<JGDIAnswer> answers) throws JGDIException {
283
nativeKillExecdWithAnswer(hosts, terminateJobs, answers);
286
public void killExecd(String[] hosts, boolean terminateJobs) throws JGDIException {
287
killExecdWithAnswer(hosts, terminateJobs, null);
290
public void killEventClientsWithAnswer(int[] ids, List<JGDIAnswer> answers) throws JGDIException {
291
nativeKillEventClientsWithAnswer(ids, answers);
294
public void killEventClients(int[] ids) throws JGDIException {
295
killEventClientsWithAnswer(ids, null);
298
public void triggerSchedulerMonitoringWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
299
nativeTriggerSchedulerMonitoringWithAnswer(answers);
302
public void triggerSchedulerMonitoring() throws JGDIException {
303
triggerSchedulerMonitoringWithAnswer(null);
306
public void clearShareTreeUsageWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
307
nativeClearShareTreeUsageWithAnswer(answers);
310
public void clearShareTreeUsage() throws JGDIException {
311
clearShareTreeUsageWithAnswer(null);
314
public void killAllEventClientsWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
315
nativeKillAllEventClientsWithAnswer(answers);
318
public void killAllEventClients() throws JGDIException {
319
killAllEventClientsWithAnswer(null);
322
public void killMasterWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
323
nativeKillMasterWithAnswer(answers);
326
public void killMaster() throws JGDIException {
327
killMasterWithAnswer(null);
330
public void killSchedulerWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
331
nativeKillSchedulerWithAnswer(answers);
334
public void killScheduler() throws JGDIException {
335
killSchedulerWithAnswer(null);
338
public void startSchedulerWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
339
nativeStartSchedulerWithAnswer(answers);
342
public void startScheduler() throws JGDIException {
343
startSchedulerWithAnswer(null);
346
public String showDetachedSettingsWithAnswer(String[] queues, List<JGDIAnswer> answers) throws JGDIException {
347
return nativeShowDetachedSettingsWithAnswer(queues, answers);
350
public String showDetachedSettings(String[] queues) throws JGDIException {
351
return showDetachedSettingsWithAnswer(queues, null);
354
public String showDetachedSettingsAllWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
355
return nativeShowDetachedSettingsAllWithAnswer(answers);
358
public String showDetachedSettingsAll() throws JGDIException {
359
return showDetachedSettingsAllWithAnswer(null);
362
public void deleteShareTree() throws JGDIException {
363
deleteShareTreeWithAnswer(null);
366
public void deleteShareTreeWithAnswer(List<JGDIAnswer> answers) throws JGDIException {
367
nativeDeleteShareTreeWithAnswer(answers);
370
private native int nativeInit(String url) throws JGDIException;
372
private native void nativeClose(int ctxIndex) throws JGDIException;
374
private native String nativeGetSGERoot() throws JGDIException;
376
private native String nativeGetSGECell() throws JGDIException;
378
private native String nativeGetAdminUser() throws JGDIException;
380
private native String nativeGetActQMaster() throws JGDIException;
382
private native void nativeExecQHost(QHostOptions options, QHostResultImpl result);
384
private native void nativeFillClusterQueueSummary(ClusterQueueSummaryOptions options, List<ClusterQueueSummary> list) throws JGDIException;
386
private native void nativeFillQueueInstanceSummary(QueueInstanceSummaryOptions options, QueueInstanceSummaryResultImpl result) throws JGDIException;
388
private native String nativeGetSchedulerHost() throws JGDIException;
390
private native void nativeGetQQuota(QQuotaOptions options, QQuotaResultImpl ret) throws JGDIException;
392
private native void nativeCleanQueuesWithAnswer(String[] queues, java.util.List<JGDIAnswer> answers) throws JGDIException;
394
private native void nativeUnsuspendWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
396
private native void nativeKillSchedulerWithAnswer(List<JGDIAnswer> answers) throws JGDIException;
398
private native void nativeStartSchedulerWithAnswer(List<JGDIAnswer> answers) throws JGDIException;
400
private native void nativeUnsuspendQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
402
private native void nativeUnsuspendJobsWithAnswer(String[] jobs, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
404
private native void nativeSuspendWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
406
private native void nativeSuspendQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
408
private native void nativeSuspendJobsWithAnswer(String[] jobs, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
410
private native void nativeRescheduleJobsWithAnswer(String[] jobs, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
412
private native void nativeRescheduleQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
414
private native void nativeRescheduleWithAnswer(String[] queue_or_job, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
416
private native void nativeClearJobsWithAnswer(String[] jobs, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
418
private native void nativeClearQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
420
private native void nativeDisableQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
422
private native void nativeEnableQueuesWithAnswer(String[] queues, boolean force, java.util.List<JGDIAnswer> answers) throws JGDIException;
424
private native void nativeKillAllExecdsWithAnswer(boolean terminateJobs, List<JGDIAnswer> answers) throws JGDIException;
426
private native void nativeKillExecdWithAnswer(String[] hosts, boolean terminateJobs, List<JGDIAnswer> answers) throws JGDIException;
428
private native void nativeKillEventClientsWithAnswer(int[] ids, List<JGDIAnswer> answers) throws JGDIException;
430
private native void nativeTriggerSchedulerMonitoringWithAnswer(java.util.List<JGDIAnswer> answer) throws JGDIException;
432
private native void nativeClearShareTreeUsageWithAnswer(java.util.List<JGDIAnswer> answers) throws JGDIException;
434
private native void nativeKillAllEventClientsWithAnswer(List<JGDIAnswer> answers) throws JGDIException;
436
private native void nativeKillMasterWithAnswer(List<JGDIAnswer> answers) throws JGDIException;
438
private native String nativeShowDetachedSettingsWithAnswer(String[] queues, List<JGDIAnswer> answers) throws JGDIException;
440
private native String nativeShowDetachedSettingsAllWithAnswer(List<JGDIAnswer> answers) throws JGDIException;
442
private native void nativeDeleteShareTreeWithAnswer(List<JGDIAnswer> answers) throws JGDIException;