1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.runner;
\r
20 import java.net.UnknownServiceException;
\r
22 import compbio.engine.cluster.dundee._Queue;
\r
25 public class _NativeSpecHelper {
\r
27 int maxCalculationTime;
\r
31 public _NativeSpecHelper(int requiredMemory) {
\r
32 this(requiredMemory, 0);
\r
35 public _NativeSpecHelper(int requiredMemory, int maxCalculationTime) {
\r
36 this.requiredMemory = requiredMemory;
\r
37 this.maxCalculationTime = maxCalculationTime;
\r
40 public void setRequiredMemory(int memory) {
\r
41 this.requiredMemory = memory;
\r
44 int getRequiredMemory() {
\r
45 return requiredMemory;
\r
48 public void setQueue(String queue) {
\r
52 public String getQueue() {
\r
56 // -q 64bit.q -l qname=64bit.q -l h_vmem=8000M -l ram=8000M
\r
57 public String getNativeSpec() throws UnknownServiceException {
\r
58 if (queue == null) {
\r
59 queue = getApproprieteQueue().toString();
\r
61 // check whether chosen queue suits for memory and runtime settings
\r
62 _Queue knownQueue = _Queue.BIGINT.getQueue(queue);
\r
63 if (knownQueue == null) {
\r
64 throw new UnknownServiceException("Queue " + queue
\r
65 + " is not regestered in the system! ");
\r
67 if (this.requiredMemory <= knownQueue.getMemoryLimit()) {
\r
68 throw new UnknownServiceException("Queue " + queue
\r
69 + " has a memory limit of "
\r
70 + knownQueue.getMemoryLimit()
\r
71 + "M - which is smaller than requested!");
\r
73 if (knownQueue.hasTimeLimit()
\r
74 && this.maxCalculationTime <= knownQueue.getTimeLimit()) {
\r
75 throw new UnknownServiceException("Queue " + queue
\r
76 + " has a time limit of " + knownQueue.getTimeLimit()
\r
77 + "hours - which is smaller than requested!");
\r
80 return "-q " + queue.toString() + "-l qname=" + queue.toString()
\r
81 + ", h_vmem=" + requiredMemory + "M,ram=" + requiredMemory
\r
85 public _Queue getApproprieteQueue() {
\r
86 return _Queue.getQueue(requiredMemory, maxCalculationTime);
\r