/* Copyright (c) 2009 Peter Troshin * * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache * License for more details. * * A copy of the license is in apache_license.txt. It is also available here: * @see: http://www.apache.org/licenses/LICENSE-2.0.txt * * Any republication or derived work distributed in source code form * must include this copyright and license notice. */ package compbio.engine.cluster.dundee; import static compbio.engine.cluster.dundee._QueueConstraints.FIRST_MEMORY_LIMIT; import static compbio.engine.cluster.dundee._QueueConstraints.LONG_TIME_LIMIT; import static compbio.engine.cluster.dundee._QueueConstraints.MAX_MEMORY_LIMIT; import static compbio.engine.cluster.dundee._QueueConstraints.SHORT_TIME_LIMIT; @Deprecated public enum _Queue { /* * devel.q 4Gb or 16Gb 8 hour I 64bit-pri.q 4Gb or 16Gb 24 hours B 64bit.q * 4Gb or 16Gb None B bigint.q 32Gb 8 h I bigmem.q 32Gb None B */ /** * Order of the constraint reflect the priority of the queue */ DEVEL(FIRST_MEMORY_LIMIT, SHORT_TIME_LIMIT, "devel.q"), PRIBIT64( FIRST_MEMORY_LIMIT, LONG_TIME_LIMIT, "64bit-pri.q"), BIT64( FIRST_MEMORY_LIMIT, 0, "64bit.q"), BIGINT(MAX_MEMORY_LIMIT, SHORT_TIME_LIMIT, "bigint.q"), BIGMEM(MAX_MEMORY_LIMIT, 0, "bigmem.q"); int maxMemory; int maxRuntime; String qname; private _Queue(int maxMemory, int maxRuntime, String qname) { this.maxMemory = maxMemory; this.maxRuntime = maxRuntime; this.qname = qname; } // -q 64bit.q -l qname=64bit.q -l h_vmem=8000M -l ram=8000M @Override public String toString() { return qname; } /** * 0 - unlimited * * @return max runtime in hours */ public int getTimeLimit() { return this.maxRuntime; } /** * * @return true if the queue has time limit, false overwise */ public boolean hasTimeLimit() { return this.maxRuntime != 0; } /** * return max memory limit in Mb * * @return */ public int getMemoryLimit() { return this.maxMemory; } public static _Queue getQueueByMemoryRequirements(int maxMemory) { if (maxMemory > FIRST_MEMORY_LIMIT) { return BIGMEM; } else if (maxMemory < MAX_MEMORY_LIMIT) return BIT64; else { throw new UnsupportedOperationException( "Cluster does not support tasks requiring more than 30000M of memory"); } } public static _Queue getQueue(int maxMemory, int timeLimitInHours) { if (timeLimitInHours == 0) { return getQueueByMemoryRequirements(maxMemory); } else { if (timeLimitInHours <= SHORT_TIME_LIMIT) { if (maxMemory <= FIRST_MEMORY_LIMIT) { return DEVEL; } else if (maxMemory <= MAX_MEMORY_LIMIT) { return BIGINT; } else { throw new UnsupportedOperationException( "Cluster does not support tasks requiring more than 30000M of memory"); } } else { // timeLimit > 8 if (timeLimitInHours <= LONG_TIME_LIMIT && maxMemory <= FIRST_MEMORY_LIMIT) { return PRIBIT64; } else if (maxMemory <= MAX_MEMORY_LIMIT) { return BIGMEM; } else { throw new UnsupportedOperationException( "Cluster does not support tasks requiring more than 30000M of memory"); } } } } public _Queue getQueue(String queueName) { switch (this) { case DEVEL : if (queueName.equals(DEVEL.toString())) { return DEVEL; } break; case PRIBIT64 : if (queueName.equals(PRIBIT64.toString())) { return PRIBIT64; } break; case BIT64 : if (queueName.equals(BIT64.toString())) { return BIT64; } break; case BIGMEM : if (queueName.equals(BIGMEM.toString())) { return BIGMEM; } break; case BIGINT : if (queueName.equals(BIGINT.toString())) { return BIGINT; } break; } // such queue appears to be not defined in the system! return null; } }