Javadoc fixes
[jabaws.git] / runner / compbio / runner / _NativeSpecHelper.java
1 /* Copyright (c) 2011 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
4  * \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
7  * \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
11  * \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
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 package compbio.runner;\r
19 \r
20 import java.net.UnknownServiceException;\r
21 \r
22 import compbio.engine.cluster.dundee._Queue;\r
23 \r
24 @Deprecated\r
25 public class _NativeSpecHelper {\r
26 \r
27         int maxCalculationTime;\r
28         int requiredMemory;\r
29         String queue;\r
30 \r
31         public _NativeSpecHelper(int requiredMemory) {\r
32                 this(requiredMemory, 0);\r
33         }\r
34 \r
35         public _NativeSpecHelper(int requiredMemory, int maxCalculationTime) {\r
36                 this.requiredMemory = requiredMemory;\r
37                 this.maxCalculationTime = maxCalculationTime;\r
38         }\r
39 \r
40         public void setRequiredMemory(int memory) {\r
41                 this.requiredMemory = memory;\r
42         }\r
43 \r
44         int getRequiredMemory() {\r
45                 return requiredMemory;\r
46         }\r
47 \r
48         public void setQueue(String queue) {\r
49                 this.queue = queue;\r
50         }\r
51 \r
52         public String getQueue() {\r
53                 return queue;\r
54         }\r
55 \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
60                 } else {\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
66                         }\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
72                         }\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
78                         }\r
79                 }\r
80                 return "-q " + queue.toString() + "-l qname=" + queue.toString()\r
81                                 + ", h_vmem=" + requiredMemory + "M,ram=" + requiredMemory\r
82                                 + "M";\r
83         }\r
84 \r
85         public _Queue getApproprieteQueue() {\r
86                 return _Queue.getQueue(requiredMemory, maxCalculationTime);\r
87         }\r
88 \r
89 }\r