1 /* Copyright (c) 2009 Peter Troshin
\r
3 * Jalview Web Services @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
24 public class _NativeSpecHelper {
\r
26 int maxCalculationTime;
\r
30 public _NativeSpecHelper(int requiredMemory) {
\r
31 this(requiredMemory, 0);
\r
34 public _NativeSpecHelper(int requiredMemory, int maxCalculationTime) {
\r
35 this.requiredMemory = requiredMemory;
\r
36 this.maxCalculationTime = maxCalculationTime;
\r
39 public void setRequiredMemory(int memory) {
\r
40 this.requiredMemory = memory;
\r
43 int getRequiredMemory() {
\r
44 return requiredMemory;
\r
47 public void setQueue(String queue) {
\r
51 public String getQueue() {
\r
55 // -q 64bit.q -l qname=64bit.q -l h_vmem=8000M -l ram=8000M
\r
56 public String getNativeSpec() throws UnknownServiceException {
\r
57 if (queue == null) {
\r
58 queue = getApproprieteQueue().toString();
\r
60 // check whether chosen queue suits for memory and runtime settings
\r
61 _Queue knownQueue = _Queue.BIGINT.getQueue(queue);
\r
62 if (knownQueue == null) {
\r
63 throw new UnknownServiceException("Queue " + queue
\r
64 + " is not regestered in the system! ");
\r
66 if (this.requiredMemory <= knownQueue.getMemoryLimit()) {
\r
67 throw new UnknownServiceException("Queue " + queue
\r
68 + " has a memory limit of "
\r
69 + knownQueue.getMemoryLimit()
\r
70 + "M - which is smaller than requested!");
\r
72 if (knownQueue.hasTimeLimit()
\r
73 && this.maxCalculationTime <= knownQueue.getTimeLimit()) {
\r
74 throw new UnknownServiceException("Queue " + queue
\r
75 + " has a time limit of " + knownQueue.getTimeLimit()
\r
76 + "hours - which is smaller than requested!");
\r
79 return "-q " + queue.toString() + "-l qname=" + queue.toString()
\r
80 + ", h_vmem=" + requiredMemory + "M,ram=" + requiredMemory
\r
84 public _Queue getApproprieteQueue() {
\r
85 return _Queue.getQueue(requiredMemory, maxCalculationTime);
\r