Changeset 5405
- Timestamp:
- Sep 10, 2010, 1:09:05 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java
r5404 r5405 365 365 query.setParameter("_excludes_", Arrays.asList(Values.getInt(exclude.split(","))), Type.INT); 366 366 } 367 checkInterrupted();367 ThreadSignalHandler.checkInterrupted(); 368 368 exportProperties(dc, out, format, exportedProperties, itemType, query, progress); 369 369 } … … 575 575 do 576 576 { 577 checkInterrupted();577 ThreadSignalHandler.checkInterrupted(); 578 578 result = queryWrapper.iterate(); 579 579 while (result.hasNext()) 580 580 { 581 checkInterrupted();581 ThreadSignalHandler.checkInterrupted(); 582 582 numExported++; 583 583 Object item = result.next(); -
trunk/src/core/net/sf/basedb/core/Install.java
r5404 r5405 115 115 method. 116 116 */ 117 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(8 2).intValue();117 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(83).intValue(); 118 118 119 119 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/Job.java
r5329 r5405 894 894 { 895 895 checkPermission(Permission.WRITE); 896 if (getStatus() != Status.WAITING && getStatus() != Status.UNCONFIGURED) 896 Job.Status status = getStatus(); 897 if (status != Status.WAITING && status != Status.UNCONFIGURED) 897 898 { 898 899 throw new PermissionDeniedException("Can't prepare a job with status '"+getStatus()+"': "+toString()); … … 1098 1099 data.setServer(null); 1099 1100 data.setJobAgentId(null); 1101 data.setSignalTransporter(null); 1100 1102 if (useLatestConfiguration) 1101 1103 { … … 1109 1111 } 1110 1112 1113 /** 1114 This method is used to indicate that a job had to be aborted due 1115 to a system shutdown. The job can be restarted one the 1116 system is up and running again. 1117 <p> 1118 This method will reset the job status to WAITING. The execute 1119 command parameter can be set to allow the plug-in to tell the 1120 difference between a first-time execution and resuming after 1121 a system shutdown. 1122 1123 @param executeCommand The command to send the next time the 1124 job is started, if not given {@link Request#COMMAND_EXECUTE} 1125 is used 1126 @since 2.16 1127 */ 1128 void continueLater(String executeCommand) 1129 { 1130 JobData data = getData(); 1131 data.setStatus(Job.Status.WAITING.getValue()); 1132 data.setPercentComplete(0); 1133 data.setStarted(null); 1134 data.setEnded(null); 1135 data.setExecuteCommand(executeCommand); 1136 data.setStatusMessage(null); 1137 data.setStackTrace(null); 1138 data.setSignalTransporter(null); 1139 } 1111 1140 1112 1141 /** … … 1216 1245 ProgressReporterImpl jobProgress = 1217 1246 new ProgressReporterImpl(this, server, agent, progress); 1218 1247 String command = getData().getExecuteCommand(); 1248 if (command == null) command = Request.COMMAND_EXECUTE; 1219 1249 PluginExecutionRequest request = 1220 1250 new PluginExecutionRequest( 1221 sc, plugin, Request.COMMAND_EXECUTE,1251 sc, plugin, command, 1222 1252 config, config == null ? null : config.getParameterValuesImpl(getParameterVersion()), 1223 1253 this, parameters, pd … … 1697 1727 Job job = jobId == 0 ? this.job : Job.getById(dc, jobId); 1698 1728 job.getData().setDryRun(response.isDryRun()); 1699 1700 if ( response.getStatus()== Response.Status.ERROR)1729 Response.Status status = response.getStatus(); 1730 if (status == Response.Status.ERROR) 1701 1731 { 1702 1732 job.doneError(response.getMessage(), response.getErrorList()); 1733 } 1734 else if (status == Response.Status.CONTINUE) 1735 { 1736 // The job will be continue again when the system restarts 1737 job.continueLater(response.getNextCommand()); 1703 1738 } 1704 1739 else -
trunk/src/core/net/sf/basedb/core/PluginResponse.java
r5384 r5405 120 120 121 121 /** 122 Get the next command sent via {@link net.sf.basedb.core.plugin.Response.Status#CONTINUE}. 123 @return The next command or null 124 @since 2.16 125 */ 126 public String getNextCommand() 127 { 128 return nextCommand; 129 } 130 131 /** 122 132 Get a <code>PluginRequest</code> object that handles the next request, 123 133 if status is {@link net.sf.basedb.core.plugin.Response.Status#CONTINUE}. … … 228 238 throws PermissionDeniedException 229 239 { 230 if (Request.COMMAND_EXECUTE.equals(request.getCommand()))231 {232 throw new PermissionDeniedException("Not allowed with command '"+nextCommand+"' after execute");233 }234 240 reset(Response.Status.CONTINUE); 235 241 PluginResponse.this.nextCommand = nextCommand; -
trunk/src/core/net/sf/basedb/core/Update.java
r5390 r5405 901 901 </td> 902 902 </tr> 903 <tr> 904 <td>83</td> 905 <td> 906 Added {@link JobData#getExecuteCommand()}. No special update is needed. 907 Only increase the schema version. 908 </td> 909 </tr> 903 910 </table> 904 911 … … 1225 1232 } 1226 1233 1227 // Schemaversion 81-8 2only updates the version number1228 if (schemaVersion < 8 2)1229 { 1230 if (progress != null) progress.display((int)(8 1*progress_factor), "--Updating schema version: " + schemaVersion + " -> 82...");1231 schemaVersion = setSchemaVersionInTransaction(session, 8 2);1234 // Schemaversion 81-83 only updates the version number 1235 if (schemaVersion < 83) 1236 { 1237 if (progress != null) progress.display((int)(82*progress_factor), "--Updating schema version: " + schemaVersion + " -> 83..."); 1238 schemaVersion = setSchemaVersionInTransaction(session, 83); 1232 1239 } 1233 1240 -
trunk/src/core/net/sf/basedb/core/data/JobData.java
r4889 r5405 144 144 } 145 145 146 147 146 /** 148 147 The maximum allowed length of the plugin version. … … 240 239 { 241 240 this.dryRun = dryRun; 241 } 242 243 /** 244 The maximum allowed length of the execute command. 245 @since 2.16 246 */ 247 public static final int MAX_COMMAND_LENGTH = 255; 248 private String executeCommand; 249 /** 250 The command to send to the plug-in when starting to 251 execute it. If null, a default values is used. See 252 Request.COMMAND_EXECUTE. This is usually only used when 253 automatically restarting a failed job. 254 @hibernate.property column="`exec_command`" type="string" length="255" not-null="false" 255 @since 2.16 256 */ 257 public String getExecuteCommand() 258 { 259 return executeCommand; 260 } 261 public void setExecuteCommand(String command) 262 { 263 this.executeCommand = command; 242 264 } 243 265 -
trunk/src/core/net/sf/basedb/core/plugin/AbstractPlugin.java
r5241 r5405 33 33 import net.sf.basedb.core.SessionControl; 34 34 import net.sf.basedb.core.PluginParameter; 35 import net.sf.basedb.core.signal. SignalException;35 import net.sf.basedb.core.signal.EnhancedThreadSignalHandler; 36 36 import net.sf.basedb.core.signal.ThreadSignalHandler; 37 37 … … 357 357 Check if the current thread has been interrupted and throw 358 358 a SignalException if it has. Subclasses that use the {@link ThreadSignalHandler} 359 to implement signal handling should regularly call this method. 359 or {@link EnhancedThreadSignalHandler} to implement signal handling should 360 regularly call this method. 360 361 @since 2.6 361 */ 362 @deprecated In 2.16, use {@link ThreadSignalHandler#checkInterrupted()} instead 363 */ 364 @Deprecated 362 365 protected void checkInterrupted() 363 366 { 364 if (Thread.interrupted()) 365 { 366 throw new SignalException("Aborted by user"); 367 } 367 ThreadSignalHandler.checkInterrupted(); 368 368 } 369 369 -
trunk/src/core/net/sf/basedb/core/plugin/Response.java
r4889 r5405 26 26 import net.sf.basedb.core.Job; 27 27 import net.sf.basedb.core.ProgressReporter; 28 import net.sf.basedb.core.signal.Signal; 28 29 29 30 import java.util.List; … … 39 40 { 40 41 /** 41 This method will continue the configuration of the job with 42 a new command to the plugin. This response is only allowed 43 while configuring a plugin or a job, not after executing the plugin. 44 45 @param nextCommand the next command to the plugin 46 @throws PermissionDeniedException If another command isn't allowed, 47 ie. after an {@link Request#COMMAND_EXECUTE} command 42 This method will continue the configuration or execution of the 43 job with a new command to the plugin. If the plug-in is currently 44 being configured the configuration will continue with the next 45 command. If the plug-in is currently executing the job will 46 be returned to job queue. The intention is that plug-ins can use 47 this to survive a temporary shutdown of the system after 48 catching the {@link Signal#SHUTDOWN} signal. 49 50 @param nextCommand The next command to the plugin 51 @throws PermissionDeniedException If another command isn't allowed 48 52 */ 49 53 public void setContinue(String nextCommand) -
trunk/src/core/net/sf/basedb/core/signal/EnhancedThreadSignalHandler.java
r5399 r5405 31 31 An extension to the thread signal handler that supports any number of 32 32 signals. When a signal is recieved it will call {@link Thread#interrupt()} 33 on the worker thread. When the worker thread becomes aware of the notification 34 it should call {@link #getReceivedSignals()} or {@link #hasReceived(Signal)} 33 on the worker thread. This signal handler is also registered as an interrupt 34 handler with {@link ThreadSignalHandler#setInterruptHandler(InterruptHandler)}, 35 and will throw a {@link SignalReceivedException} when interrupted. 36 <p> 37 When the worker thread becomes aware of the notification it should call 38 {@link #getReceivedSignals()} or {@link #hasReceived(Signal)} 35 39 to find out which signal that was sent and then take the proper action. 40 <p> 41 42 There are usually three different ways to get a notification about 43 the signal: 44 <ul> 45 <li>An {@link InterruptedException} is thrown. This usually happens when the 46 code involves blocking IO operations or other blocking synchronization 47 functions. 48 <li>A {@link SignalReceivedException} is thrown. This is usually 49 thrown from the BASE core when it detects that the thread has been 50 interrupted. 51 <li>Check the Thread.interrupted() flag. But we recommend that 52 {@link ThreadSignalHandler#checkInterrupted()} is used instead. 53 </ul> 36 54 37 55 38 56 <pre class="code"> 39 57 // ... code in worker thread 40 threadSignalHandler.setWorkerThread( null);58 threadSignalHandler.setWorkerThread(); 41 59 beginTransaction(); 42 60 boolean done = false; … … 47 65 { 48 66 done = doSomeWork(); // NOTE! This must not take forever! 49 interrupted = Thread.interrupted(); 67 ThreadSignalHandler.checkInterrupted(); 68 } 69 catch (SignalReceivedException ex) 70 { 71 // This exception can be thrown from BASE core when a thread is interrupted 72 interrupted = true; 50 73 } 51 74 catch (InterruptedException ex) … … 76 99 public class EnhancedThreadSignalHandler 77 100 extends AbstractSignalHandler 101 implements InterruptHandler 78 102 { 79 103 … … 102 126 super(supported); 103 127 this.received = Collections.synchronizedList(new ArrayList<Signal>()); 128 setWorkerThread(); 104 129 } 105 130 … … 113 138 { 114 139 this(Arrays.asList(supported)); 115 }116 117 /**118 Create a new thread signal handler.119 @param workerThread The worker thread to interrupt when it receieves the120 {@link Signal#ABORT} signal, or null to interrupt the current thread121 */122 public EnhancedThreadSignalHandler(Thread workerThread, Collection<Signal> supported)123 {124 this(supported);125 setWorkerThread(workerThread);126 140 } 127 141 … … 160 174 // ------------------------------------------- 161 175 162 /** 163 Set the worker thread that should be interrupted when a signal is 164 receiver. 165 @param workerThread The worker thread, or null to use the current thread 166 */ 167 public void setWorkerThread(Thread workerThread) 168 { 169 this.workerThread = workerThread == null ? Thread.currentThread() : workerThread; 176 /* 177 From the InterruptHandler interface 178 ----------------------------------- 179 */ 180 /** 181 Throws a {@link SignalReceivedException} if one ore more 182 signals has been received. 183 */ 184 @Override 185 public void handleInterrupt() 186 { 187 if (received.size() > 0) 188 { 189 throw new SignalReceivedException(received); 190 } 191 192 } 193 // ----------------------------------- 194 195 /** 196 Set the worker thread to the current thread. This will also register 197 this object as an interrupt handler with {@link 198 ThreadSignalHandler#setInterruptHandler(InterruptHandler)}. 199 */ 200 public void setWorkerThread() 201 { 202 this.workerThread = Thread.currentThread(); 203 ThreadSignalHandler.setInterruptHandler(this); 170 204 } 171 205 … … 218 252 return received.contains(signal); 219 253 } 220 221 } 254 255 } -
trunk/src/core/net/sf/basedb/core/signal/ThreadSignalHandler.java
r4516 r5405 78 78 79 79 /** 80 Utility method to check if the current thread has been interrupted and throws 81 a SignalException if it has. 80 Keep per-thread interupt handlers. The default handler is 81 {@link ExceptionInterruptHandler} which simply throws a 82 {@link SignalException} if the current thread has been 83 interrupted. 84 @since 2.16 85 */ 86 private static ThreadLocal<InterruptHandler> interruptHandler = 87 new ThreadLocal<InterruptHandler>() 88 { 89 @Override 90 protected InterruptHandler initialValue() 91 { 92 return new ExceptionInterruptHandler("Aborted by user"); 93 } 94 }; 95 96 /** 97 Utility method to check if the current thread has been interrupted 98 and (may) throw a SignalException if it has. 99 NOTE! Since BASE 2.16 the actual behaviour of this method is 100 determined by the {@link InterruptHandler} that has been registered 101 for the current thread by {@link #setInterruptHandler(InterruptHandler)}. 102 The default handler always throws a {@link SignalException}. 82 103 */ 83 104 public static void checkInterrupted() 84 105 { 85 if (Thread.interrupted()) throw new SignalException("Aborted by user"); 86 } 87 106 if (Thread.interrupted()) interruptHandler.get().handleInterrupt(); 107 } 108 109 /** 110 Register an interrupt handler with the current thread. The handler 111 is used by the {@link #checkInterrupted()} method when the thread 112 has been interrupted. If no handler has been registered with a 113 thread the default action is to throw a {@link SignalException}. 114 115 @param handler An interrupt handler or null to remove a previously 116 registered handler 117 @since 2.16 118 */ 119 public static void setInterruptHandler(InterruptHandler handler) 120 { 121 if (handler != null) 122 { 123 interruptHandler.set(handler); 124 } 125 else 126 { 127 interruptHandler.remove(); 128 } 129 } 88 130 89 131 /** -
trunk/src/core/net/sf/basedb/util/basefile/BaseFileParser.java
r5374 r5405 35 35 import net.sf.basedb.core.ProgressReporter; 36 36 import net.sf.basedb.core.signal.SignalException; 37 import net.sf.basedb.core.signal.ThreadSignalHandler; 37 38 import net.sf.basedb.util.Values; 38 39 import net.sf.basedb.util.parser.FlatFileParser; … … 199 200 Checks if the currently executing thread has been interrupted and 200 201 throws a {@link SignalException} if it has. 201 */ 202 @deprecated In 2.16, use {@link ThreadSignalHandler#checkInterrupted()} instead 203 */ 204 @Deprecated 202 205 public void checkInterrupted() 203 206 { 204 if (Thread.interrupted()) throw new SignalException("Aborted by user");207 ThreadSignalHandler.checkInterrupted(); 205 208 } 206 209 -
trunk/src/core/net/sf/basedb/util/export/spotdata/AbstractBioAssaySetExporter.java
r5319 r5405 52 52 import net.sf.basedb.core.query.SqlResult; 53 53 import net.sf.basedb.core.signal.SignalException; 54 import net.sf.basedb.core.signal.ThreadSignalHandler; 54 55 import net.sf.basedb.core.snapshot.SnapshotManager; 55 56 import net.sf.basedb.util.formatter.Formatter; … … 682 683 Checks if the currently executing thread has been interrupted and 683 684 throws a {@link SignalException} if it has. 684 */ 685 @deprecated In 2.16, use {@link ThreadSignalHandler#checkInterrupted()} instead 686 */ 687 @Deprecated 685 688 protected void checkInterrupted() 686 689 { 687 if (Thread.interrupted()) throw new SignalException("Aborted by user");690 ThreadSignalHandler.checkInterrupted(); 688 691 } 689 692 -
trunk/src/core/net/sf/basedb/util/export/spotdata/BaseFileExporter.java
r5384 r5405 47 47 import net.sf.basedb.core.query.Selects; 48 48 import net.sf.basedb.core.query.SqlResult; 49 import net.sf.basedb.core.signal.ThreadSignalHandler; 49 50 import net.sf.basedb.util.Values; 50 51 import net.sf.basedb.util.basefile.BaseFileWriter; … … 463 464 while (it.hasNext()) 464 465 { 465 checkInterrupted();466 ThreadSignalHandler.checkInterrupted(); 466 467 SqlResult result = it.next(); 467 468 -
trunk/src/core/net/sf/basedb/util/export/spotdata/BfsExporter.java
r5384 r5405 43 43 import net.sf.basedb.core.Type; 44 44 import net.sf.basedb.core.query.SqlResult; 45 import net.sf.basedb.core.signal.ThreadSignalHandler; 45 46 import net.sf.basedb.util.ChainedProgressReporter; 46 47 import net.sf.basedb.util.Values; … … 567 568 while (it.hasNext()) 568 569 { 569 checkInterrupted();570 ThreadSignalHandler.checkInterrupted(); 570 571 SqlResult result = it.next(); 571 572 … … 643 644 for (BioAssay ba : assays) 644 645 { 645 checkInterrupted();646 ThreadSignalHandler.checkInterrupted(); 646 647 index = 0; 647 648 for (int i = 1; i <= numFields; ++i) … … 709 710 while (it.hasNext()) 710 711 { 711 checkInterrupted();712 ThreadSignalHandler.checkInterrupted(); 712 713 SqlResult result = it.next(); 713 714 -
trunk/src/core/net/sf/basedb/util/export/spotdata/SerialBaseFileExporter.java
r5373 r5405 29 29 import net.sf.basedb.core.DynamicSpotQuery; 30 30 import net.sf.basedb.core.Type; 31 import net.sf.basedb.core.signal.ThreadSignalHandler; 31 32 import net.sf.basedb.util.basefile.BaseFileWriter; 32 33 … … 102 103 long count = countQuery.count(dc); 103 104 spotCount += count; 104 checkInterrupted();105 ThreadSignalHandler.checkInterrupted(); 105 106 exportSpotSectionHeaders(Arrays.asList(current), count); 106 107 } -
trunk/src/core/net/sf/basedb/util/importer/spotdata/BaseFileImporter.java
r5384 r5405 52 52 import net.sf.basedb.core.query.SqlResult; 53 53 import net.sf.basedb.core.signal.SignalException; 54 import net.sf.basedb.core.signal.ThreadSignalHandler; 54 55 import net.sf.basedb.util.ChainedProgressReporter; 55 56 import net.sf.basedb.util.basefile.BaseFileParser; … … 262 263 Checks if the currently executing thread has been interrupted and 263 264 throws a {@link SignalException} if it has. 264 */ 265 @deprecated In 2.16, use {@link ThreadSignalHandler#checkInterrupted()} instead 266 */ 267 @Deprecated 265 268 protected void checkInterrupted() 266 269 { 267 if (Thread.interrupted()) throw new SignalException("Aborted by user");270 ThreadSignalHandler.checkInterrupted(); 268 271 } 269 272 -
trunk/src/core/net/sf/basedb/util/importer/spotdata/BfsImporter.java
r5329 r5405 41 41 import net.sf.basedb.core.Transformation; 42 42 import net.sf.basedb.core.signal.SignalException; 43 import net.sf.basedb.core.signal.ThreadSignalHandler; 43 44 import net.sf.basedb.util.ChainedProgressReporter; 44 45 import net.sf.basedb.util.Values; … … 240 241 Checks if the currently executing thread has been interrupted and 241 242 throws a {@link SignalException} if it has. 242 */ 243 @deprecated In 2.16, use {@link ThreadSignalHandler#checkInterrupted()} instead 244 */ 245 @Deprecated 243 246 protected void checkInterrupted() 244 247 { 245 if (Thread.interrupted()) throw new SignalException("Aborted by user");248 ThreadSignalHandler.checkInterrupted(); 246 249 } 247 250 -
trunk/src/core/net/sf/basedb/util/importer/spotdata/FirstPassSectionSpotsParser.java
r5096 r5405 31 31 import net.sf.basedb.core.BioAssaySet; 32 32 import net.sf.basedb.core.DbControl; 33 import net.sf.basedb.core.signal.ThreadSignalHandler; 33 34 import net.sf.basedb.util.Values; 34 35 import net.sf.basedb.util.basefile.BaseFileParser; … … 222 223 while ((data = ffp.nextData()) != null) 223 224 { 224 parser.checkInterrupted();225 ThreadSignalHandler.checkInterrupted(); 225 226 226 227 long parsedBytes = ffp.getParsedBytes(); -
trunk/src/core/net/sf/basedb/util/importer/spotdata/SecondPassSectionSpotsParser.java
r5384 r5405 32 32 import net.sf.basedb.core.SpotBatcher; 33 33 import net.sf.basedb.core.SpotExtraValueBatcher; 34 import net.sf.basedb.core.signal.ThreadSignalHandler; 34 35 import net.sf.basedb.util.Values; 35 36 import net.sf.basedb.util.basefile.BaseFileParser; … … 139 140 while ((data = ffp.nextData()) != null) 140 141 { 141 parser.checkInterrupted();142 ThreadSignalHandler.checkInterrupted(); 142 143 int parsedLines = ffp.getParsedLines(); 143 144 if (parsedLines >= nextProgressReport) -
trunk/src/core/net/sf/basedb/util/importer/spotdata/SectionReporterListParser.java
r5096 r5405 32 32 import net.sf.basedb.core.Transformation; 33 33 import net.sf.basedb.core.data.ReporterData; 34 import net.sf.basedb.core.signal.ThreadSignalHandler; 34 35 import net.sf.basedb.util.Values; 35 36 import net.sf.basedb.util.basefile.BaseFileParser; … … 105 106 while ((data = ffp.nextData()) != null) 106 107 { 107 parser.checkInterrupted();108 ThreadSignalHandler.checkInterrupted(); 108 109 long parsedBytes = ffp.getParsedBytes(); 109 110 if (parsedBytes >= nextProgressReport) -
trunk/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java
r5384 r5405 642 642 } 643 643 } 644 checkInterrupted();644 ThreadSignalHandler.checkInterrupted(); 645 645 FlatFileParser.LineType result = ffp.parseHeaders(); 646 646 FlatFileParser.Line line = null; … … 671 671 } 672 672 } 673 checkInterrupted();673 ThreadSignalHandler.checkInterrupted(); 674 674 } 675 675 catch (Throwable t) … … 724 724 } 725 725 // In case the server is shutting down... throw exception, rollback and quit 726 checkInterrupted();726 ThreadSignalHandler.checkInterrupted(); 727 727 } 728 728 } -
trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java
r5384 r5405 80 80 import net.sf.basedb.core.query.Orders; 81 81 import net.sf.basedb.core.query.Restrictions; 82 import net.sf.basedb.core.signal.ThreadSignalHandler; 82 83 import net.sf.basedb.plugins.util.Parameters; 83 84 import net.sf.basedb.util.error.ClassMapErrorHandler; … … 911 912 numReplaced += na.getNumReplaced(); 912 913 numRemoved += na.getNumRemoved(); 913 checkInterrupted();914 ThreadSignalHandler.checkInterrupted(); 914 915 } 915 916 } -
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r5384 r5405 664 664 if (chainedProgress != null) chainedProgress.setRange(0, 20); 665 665 stdin = exportData(dc, workingDirectory, chainedProgress); 666 checkInterrupted();666 ThreadSignalHandler.checkInterrupted(); 667 667 dc.commit(); 668 668 } … … 683 683 try 684 684 { 685 checkInterrupted();685 ThreadSignalHandler.checkInterrupted(); 686 686 tmpDir = getExecDirectory(); 687 687 copy(stdin, tmpDir); … … 763 763 { 764 764 dc = sc.newDbControl(); 765 checkInterrupted();765 ThreadSignalHandler.checkInterrupted(); 766 766 progress.display(60, "Importing data from plugin."); 767 767 BioAssaySet parentBas = getSourceBioAssaySet(dc); … … 1475 1475 private void associateFiles(DbControl dc, Transformation trans, Directory homeDirectory) 1476 1476 { 1477 checkInterrupted();1477 ThreadSignalHandler.checkInterrupted(); 1478 1478 String root = homeDirectory.getPath().toString(); 1479 1479 AnyToAny ata = AnyToAny.getNew(dc, trans, homeDirectory, "./", false); … … 1506 1506 try 1507 1507 { 1508 checkInterrupted();1508 ThreadSignalHandler.checkInterrupted(); 1509 1509 newFile.upload(new FileInputStream(f), true); 1510 1510 } -
trunk/src/plugins/core/net/sf/basedb/plugins/CdfFileReporterImporter.java
r5384 r5405 190 190 File cdfFile = (File)job.getValue("file"); 191 191 cdfFile = File.getById(dc, cdfFile.getId()); 192 checkInterrupted();192 ThreadSignalHandler.checkInterrupted(); 193 193 FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile); 194 194 … … 480 480 private int importFromCdf(DbControl dc, FusionCDFData cdf, ProgressReporter progress) 481 481 { 482 checkInterrupted();482 ThreadSignalHandler.checkInterrupted(); 483 483 484 484 ReporterBatcher batcher = ReporterBatcher.getNew(dc); -
trunk/src/plugins/core/net/sf/basedb/plugins/FormulaFilter.java
r5319 r5405 171 171 Restriction filter = BioAssaySetUtil.createJepRestriction(dc, expression, source.getSpotData()); 172 172 173 checkInterrupted();173 ThreadSignalHandler.checkInterrupted(); 174 174 175 175 if (includeLimit != null || excludeLimit != null) -
trunk/src/plugins/core/net/sf/basedb/plugins/GalExporter.java
r4888 r5405 341 341 signalHandler.setWorkerThread(null); 342 342 } 343 checkInterrupted();343 ThreadSignalHandler.checkInterrupted(); 344 344 if (progress != null) progress.display(0, "Loading blocks..."); 345 345 … … 374 374 // Start data output 375 375 writeDataHeader(writer); 376 checkInterrupted();376 ThreadSignalHandler.checkInterrupted(); 377 377 if (progress != null) progress.display(5, "Loading features..."); 378 378 … … 401 401 if (done % progressInterval == 0) 402 402 { 403 checkInterrupted();403 ThreadSignalHandler.checkInterrupted(); 404 404 if (progress != null) 405 405 { -
trunk/src/plugins/core/net/sf/basedb/plugins/HelpExporter.java
r4889 r5405 326 326 327 327 //Get helpitems from database 328 checkInterrupted();328 ThreadSignalHandler.checkInterrupted(); 329 329 long numHelpItems = helpTextQuery.count(dc); 330 330 float percentPerItem = 100.0f / numHelpItems; 331 331 332 checkInterrupted();332 ThreadSignalHandler.checkInterrupted(); 333 333 result = helpTextQuery.iterate(dc); 334 334 while (result.hasNext()) 335 335 { 336 checkInterrupted();336 ThreadSignalHandler.checkInterrupted(); 337 337 //Create a new helpitem element 338 338 Help helpItem = result.next(); -
trunk/src/plugins/core/net/sf/basedb/plugins/HelpImporter.java
r5384 r5405 356 356 for (int i = 0; i < helpElements.size(); i++) 357 357 { 358 checkInterrupted();358 ThreadSignalHandler.checkInterrupted(); 359 359 Element helpElement = helpElements.get(i); 360 360 String name = helpElement.getChildText("name"); -
trunk/src/plugins/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java
r5060 r5405 245 245 Job thisJob = Job.getById(dc, jobId); 246 246 247 checkInterrupted();247 ThreadSignalHandler.checkInterrupted(); 248 248 BioAssaySet rootBas = null; 249 249 if (IntensityCalculatorUtil.checkSameArrayDesign(sources, false)) -
trunk/src/plugins/core/net/sf/basedb/plugins/JepExtraValueCalculator.java
r5319 r5405 178 178 179 179 if (progress != null) progress.display(10, "Calculating extra value ("+source.getNumSpots()+" total)..."); 180 checkInterrupted();180 ThreadSignalHandler.checkInterrupted(); 181 181 extraBatcher.insert(query); 182 182 -
trunk/src/plugins/core/net/sf/basedb/plugins/JepIntensityTransformer.java
r5319 r5405 202 202 // Create the batchers we need 203 203 if (progress != null) progress.display(10, "Transforming intensities ("+source.getNumSpots()+" total)..."); 204 checkInterrupted();204 ThreadSignalHandler.checkInterrupted(); 205 205 SpotBatcher spotBatcher = child.getSpotBatcher(); 206 206 spotBatcher.insert(query); -
trunk/src/plugins/core/net/sf/basedb/plugins/LowessNormalization.java
r5384 r5405 66 66 import net.sf.basedb.core.query.SqlResult; 67 67 import net.sf.basedb.core.query.WhenStatement; 68 import net.sf.basedb.core.signal.EnhancedThreadSignalHandler; 69 import net.sf.basedb.core.signal.Signal; 68 70 import net.sf.basedb.core.signal.SignalException; 69 71 import net.sf.basedb.core.signal.SignalHandler; 70 import net.sf.basedb.core.signal.SignalReceivedException;71 72 import net.sf.basedb.core.signal.SignalTarget; 72 73 import net.sf.basedb.core.signal.ThreadSignalHandler; … … 180 181 private RequestInformation configureJob; 181 182 182 private ThreadSignalHandler signalHandler;183 private EnhancedThreadSignalHandler signalHandler; 183 184 184 185 /* … … 218 219 if (command.equals(Request.COMMAND_EXECUTE)) 219 220 { 220 if (signalHandler != null) 221 { 222 signalHandler.setWorkerThread(null); 223 } 221 if (signalHandler != null) signalHandler.setWorkerThread(); 224 222 DbControl dc = null; 225 223 try … … 245 243 response.setDone(normalizedSpots + " spots normalized, " + (source.getNumSpots() - normalizedSpots) + " spots removed"); 246 244 } 245 catch (SignalException ex) 246 { 247 if (signalHandler != null && signalHandler.hasReceived(Signal.SHUTDOWN)) 248 { 249 response.setContinue(command); 250 } 251 else 252 { 253 response.setError("Aborted by user", Arrays.asList(ex)); 254 } 255 } 247 256 catch (Throwable ex) 248 257 { … … 330 339 } 331 340 } 332 catch (SignalReceivedException ex)333 {334 response.setError("Aborted by user", Arrays.asList(ex));335 }336 341 catch (Throwable ex) 337 342 { … … 347 352 public SignalHandler getSignalHandler() 348 353 { 349 signalHandler = new ThreadSignalHandler(); 354 if (signalHandler == null) 355 { 356 signalHandler = new EnhancedThreadSignalHandler(Signal.ABORT, Signal.SHUTDOWN); 357 } 350 358 return signalHandler; 351 359 } … … 467 475 while (numDone < numAssays) 468 476 { 469 checkInterrupted();477 ThreadSignalHandler.checkInterrupted(); 470 478 471 479 // Get data for the next bioassay unless the working queue … … 522 530 catch (InterruptedException ex) 523 531 { 524 throw new SignalException("Aborted by user"); 532 if (signalHandler != null) 533 { 534 signalHandler.checkForSignals(); 535 } 536 throw new SignalException("Aborted by user", ex); 525 537 } 526 538 finally … … 552 564 while (it.hasNext()) 553 565 { 554 checkInterrupted();566 ThreadSignalHandler.checkInterrupted(); 555 567 SqlResult r = it.next(); 556 568 SpotData spot = new SpotData(bioassayColumn, r.getInt(positionIndex), -
trunk/src/plugins/core/net/sf/basedb/plugins/MedianRatioNormalization.java
r5103 r5405 459 459 for (BioAssay assay : assays) 460 460 { 461 checkInterrupted();461 ThreadSignalHandler.checkInterrupted(); 462 462 463 463 // query spot data for this bioassay … … 567 567 DynamicSpotQuery query = source.getSpotData(); 568 568 query.restrictPermanent(intensityRestriction); 569 checkInterrupted();569 ThreadSignalHandler.checkInterrupted(); 570 570 long numSpots = query.count(dc); 571 571 query.reset(); … … 588 588 for (BioAssay assay : assays) 589 589 { 590 checkInterrupted();590 ThreadSignalHandler.checkInterrupted(); 591 591 592 592 // Prepare list for holding data … … 607 607 while (it.hasNext()) 608 608 { 609 checkInterrupted();609 ThreadSignalHandler.checkInterrupted(); 610 610 SqlResult r = it.next(); 611 611 SpotData spot = new SpotData(r.getInt(positionIndex), … … 632 632 while (fromBlock <= maxBlock) 633 633 { 634 checkInterrupted();634 ThreadSignalHandler.checkInterrupted(); 635 635 // Find start and end index for current block range 636 636 int toBlock = fromBlock + blockGroupSize - 1; … … 664 664 for (int j = fromIndex; j < toIndex; ++j) 665 665 { 666 checkInterrupted();666 ThreadSignalHandler.checkInterrupted(); 667 667 SpotData spot = data.get(j); 668 668 float newCh1 = (float)(spot.ch1 * invSqrtMedRatio); -
trunk/src/plugins/core/net/sf/basedb/plugins/PackedFileExporter.java
r5329 r5405 391 391 for (Nameable item : itemsToPack) 392 392 { 393 checkInterrupted();393 ThreadSignalHandler.checkInterrupted(); 394 394 currentFile++; 395 395 String entryPath = null; … … 582 582 for (Integer fileId : files) 583 583 { 584 checkInterrupted();584 ThreadSignalHandler.checkInterrupted(); 585 585 try 586 586 { … … 603 603 for (Integer dirId : directories) 604 604 { 605 checkInterrupted();605 ThreadSignalHandler.checkInterrupted(); 606 606 try 607 607 { … … 630 630 for (File f : fileQuery.list(dc)) 631 631 { 632 checkInterrupted();632 ThreadSignalHandler.checkInterrupted(); 633 633 if (f.getLocation() == Location.PRIMARY) 634 634 { … … 646 646 for (Directory dir : dirQuery.list(dc)) 647 647 { 648 checkInterrupted();648 ThreadSignalHandler.checkInterrupted(); 649 649 loadedFiles.add(dir); 650 650 loadFiles(dc, loadedFiles, dir); -
trunk/src/plugins/core/net/sf/basedb/plugins/PlateMappingExporter.java
r4523 r5405 295 295 for (int column = 0; column < destGeometry.getColumns(); ++column) 296 296 { 297 checkInterrupted();297 ThreadSignalHandler.checkInterrupted(); 298 298 MappingCoordinate destination = new MappingCoordinate(plate, row, column); 299 299 MappingCoordinate source = mapping.getSourceCoordinate(destination); -
trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationExporter.java
r4889 r5405 268 268 ); 269 269 configQuery.setParameter("_selected_", selectedItems, Type.INT); 270 checkInterrupted();270 ThreadSignalHandler.checkInterrupted(); 271 271 ItemResultIterator<PluginConfiguration> configurations = configQuery.iterate(dc); 272 272 … … 280 280 while (configurations.hasNext()) 281 281 { 282 checkInterrupted();282 ThreadSignalHandler.checkInterrupted(); 283 283 PluginConfiguration pluginConfig = configurations.next(); 284 284 -
trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationImporter.java
r5384 r5405 377 377 for (Object obj : configurations) 378 378 { 379 checkInterrupted();379 ThreadSignalHandler.checkInterrupted(); 380 380 Element configuration = (Element)obj; 381 381 String name = configuration.getChildText("configname"); -
trunk/src/plugins/core/net/sf/basedb/plugins/TarFileUnpacker.java
r4513 r5405 49 49 import net.sf.basedb.core.plugin.About; 50 50 import net.sf.basedb.core.plugin.AboutImpl; 51 import net.sf.basedb.core.signal.ThreadSignalHandler; 51 52 import net.sf.basedb.util.FileUtil; 52 53 import net.sf.basedb.util.InputStreamTracker; … … 163 164 while ((entry = TarUtil.getNextEntry(tarStream)) != null) 164 165 { 165 checkInterrupted();166 ThreadSignalHandler.checkInterrupted(); 166 167 String subPath = entry.getName(); 167 168 String completePath = rootPath + "/" + subPath; -
trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java
r5384 r5405 285 285 // Run the exporter plug-in 286 286 if (chainedProgress != null) chainedProgress.setRange(5, 40); 287 checkInterrupted();287 ThreadSignalHandler.checkInterrupted(); 288 288 runExporter(requestWrapper, responseWrapper, chainedProgress); 289 289 if (responseWrapper.hasError()) … … 297 297 String cmdLine = (String)configuration.getValue(PARAMETER_EXTERNAL_CMDLINE); 298 298 if (progress != null) progress.display(50, "Executing external program: " + externalProgram); 299 checkInterrupted();299 ThreadSignalHandler.checkInterrupted(); 300 300 runExternalProgram(externalProgram, cmdLine, workDir, "stdin.txt", "stdout.txt", progress); 301 301 … … 303 303 if (chainedProgress != null) chainedProgress.setRange(60, 95); 304 304 responseWrapper = new ResponseWrapper(); 305 checkInterrupted();305 ThreadSignalHandler.checkInterrupted(); 306 306 runImporter(requestWrapper, responseWrapper, chainedProgress); 307 307 if (responseWrapper.hasError())
Note: See TracChangeset
for help on using the changeset viewer.