001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.align.client; 022 023import org.biojava.nbio.structure.align.util.ResourceManager; 024 025public class FarmJobParameters { 026 027 028 public static final int DEFAULT_JOB_TIME = -1; 029 public static final int DEFAULT_NR_ALIGNMENTS = -1; 030 public static final int DEFAULT_NR_THREADS = 1; 031 public static final String DEFAULT_SERVER_URL; 032 private static ResourceManager resourceManager; 033 static { 034 resourceManager = ResourceManager.getResourceManager("jfatcat"); 035 DEFAULT_SERVER_URL = resourceManager.getString("server.url"); 036 } 037 public static final String DEFAULT_PDB_PATH = "/tmp/"; 038 public static final int DEFAULT_BATCH_SIZE = 100; 039 040 private static final String DEFAULT_BATCH_SIZE_PROP = "request.pair.size"; 041 042 int nrAlignments; 043 int time; 044 int threads; 045 String server; 046 String pdbFilePath; 047 String username; 048 boolean runBackground; 049 boolean verbose; 050 boolean updateRemediatedFiles; 051 int stepSize; 052 String cacheFilePath; 053 054 055 public FarmJobParameters(){ 056 nrAlignments = DEFAULT_NR_ALIGNMENTS; 057 time = DEFAULT_JOB_TIME; 058 threads = DEFAULT_NR_THREADS; 059 server = DEFAULT_SERVER_URL; 060 pdbFilePath = DEFAULT_PDB_PATH; 061 runBackground = false; 062 cacheFilePath = DEFAULT_PDB_PATH; 063 updateRemediatedFiles = false; 064 String nrPairsProp = resourceManager.getString(DEFAULT_BATCH_SIZE_PROP); 065 066 stepSize = DEFAULT_BATCH_SIZE; 067 068 username = FarmJobRunnable.getRandomUsername(); 069 if ( nrPairsProp != null){ 070 stepSize = Integer.parseInt(nrPairsProp); 071 } 072 073 } 074 075 public String getPdbFilePath() { 076 return pdbFilePath; 077 } 078 079 public void setPdbFilePath(String pdbFilePath) { 080 this.pdbFilePath = pdbFilePath; 081 } 082 public String getCacheFilePath() { 083 return cacheFilePath; 084 } 085 086 public void setCacheFilePath(String cacheFilePath) { 087 this.cacheFilePath = cacheFilePath; 088 } 089 090 public int getNrAlignments() { 091 return nrAlignments; 092 } 093 094 095 public void setNrAlignments(int nrAlignments) { 096 this.nrAlignments = nrAlignments; 097 } 098 099 100 public int getTime() { 101 return time; 102 } 103 104 public void setTime(int time) { 105 this.time = time; 106 } 107 108 public int getThreads() { 109 return threads; 110 } 111 112 public void setThreads(int threads) { 113 this.threads = threads; 114 } 115 116 public String getServer() { 117 return server; 118 } 119 120 public void setServer(String server) { 121 this.server = server; 122 } 123 124 public String getUsername() { 125 return username; 126 } 127 public void setUsername(String username) { 128 this.username = username; 129 } 130 131 /** Flag if a job that only runs one parallell job should be run in its own thread or in the main thread. 132 * For User interface related apps should be set to true. Default: false; 133 * @return flag 134 */ 135 public boolean isRunBackground() { 136 return runBackground; 137 } 138 public void setRunBackground(boolean runBackground) { 139 this.runBackground = runBackground; 140 } 141 142 143 /** how many pairs should be requested for alignment from server? 144 * 145 * @return stepsize 146 */ 147 public int getStepSize() { 148 return stepSize; 149 } 150 151 public void setStepSize(int stepSize) { 152 this.stepSize = stepSize; 153 } 154 155 156 /** Flag if the job should be run in verbose mode. Default: false 157 * 158 * @return flag if the job should be run in verbose mode 159 */ 160 public boolean isVerbose() { 161 return verbose; 162 } 163 164 public void setVerbose(boolean verbose) { 165 this.verbose = verbose; 166 } 167 168 public boolean isUpdateRemediatedFiles() { 169 return updateRemediatedFiles; 170 } 171 172 public void setUpdateRemediatedFiles(boolean updateRemediatedFiles) { 173 this.updateRemediatedFiles = updateRemediatedFiles; 174 } 175 176 @Override 177 public String toString() { 178 return "FarmJobParameters [nrAlignments=" + nrAlignments + ", time=" 179 + time + ", threads=" + threads + ", server=" + server 180 + ", pdbFilePath=" + pdbFilePath 181 + ", username=" + username + ", runBackground=" 182 + runBackground + ", verbose=" + verbose 183 + ", updateRemediatedFiles=" + updateRemediatedFiles 184 + ", stepSize=" + stepSize + ", cacheFilePath=" + cacheFilePath 185 + "]"; 186 } 187 188 189 190}