root/trunk/components/blitz/resources/omero/Scripts.ice
| Revision 3075, 6.8 kB (checked in by andrew, 2 months ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | * $Id$ |
| 3 | * |
| 4 | * Copyright 2008 Glencoe Software, Inc. All rights reserved. |
| 5 | * Use is subject to license terms supplied in LICENSE.txt |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef OMERO_SCRIPTS_ICE |
| 10 | #define OMERO_SCRIPTS_ICE |
| 11 | |
| 12 | #include <omero/RTypes.ice> |
| 13 | #include <omero/ServerErrors.ice> |
| 14 | #include <omero/model/Job.ice> |
| 15 | #include <Ice/BuiltinSequences.ice> |
| 16 | |
| 17 | /* |
| 18 | * The Processor API is intended to provide an script runner |
| 19 | * implementation, for use by the server and via the |
| 20 | * InteractiveProcessor wrapper by clients. |
| 21 | * |
| 22 | * See https://trac.openmicroscopy.org.uk/omero/wiki/OmeroGrid |
| 23 | */ |
| 24 | module omero { |
| 25 | |
| 26 | class Internal{}; |
| 27 | |
| 28 | /* |
| 29 | * Base type for RTypes whose contents will not be parsed by |
| 30 | * the server. This is an intermediate solution while |
| 31 | * conversion between Blitz/JBoss types is necessary. |
| 32 | * |
| 33 | * Direct references to RType2 should be minimized. |
| 34 | */ |
| 35 | ["protected"] class RInternal extends omero::RType { |
| 36 | Internal val; |
| 37 | Internal getValue(); |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * Types using the "Internal" infrastructure to allow storing |
| 42 | * useful types in the input/output environments of scripts. |
| 43 | */ |
| 44 | sequence<Ice::ByteSeq> Bytes2D; |
| 45 | |
| 46 | class Plane extends Internal { |
| 47 | Bytes2D data; |
| 48 | }; |
| 49 | |
| 50 | class Point extends Internal { |
| 51 | int x; |
| 52 | int y; |
| 53 | }; |
| 54 | |
| 55 | module grid { |
| 56 | |
| 57 | /* |
| 58 | * A single parameter to a Job. For example, used by |
| 59 | * ScriptJobs to define what the input and output |
| 60 | * environment variables should be. |
| 61 | */ |
| 62 | class Param { |
| 63 | string name; |
| 64 | string description; |
| 65 | bool optional; |
| 66 | omero::RType prototype; |
| 67 | }; |
| 68 | |
| 69 | dictionary<string, Param> ParamMap; |
| 70 | |
| 71 | /* |
| 72 | * Complete job description with all input |
| 73 | * and output Params. See above. |
| 74 | */ |
| 75 | class JobParams extends Internal { |
| 76 | |
| 77 | string name; |
| 78 | string description; |
| 79 | |
| 80 | ParamMap inputs; |
| 81 | ParamMap outputs; |
| 82 | |
| 83 | string stdoutFormat; |
| 84 | string stderrFormat; |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | * Callback which can be attached to a Process |
| 89 | * with notification of any of the possible |
| 90 | * ends-of-life that a Process might experience |
| 91 | */ |
| 92 | interface ProcessCallback { |
| 93 | |
| 94 | /* |
| 95 | * Process terminated normally. Return code provided. |
| 96 | * In the case that a non-Blitz process sent a signal |
| 97 | * (KILL, TERM, ... ), that will represented in the |
| 98 | * return code. |
| 99 | */ |
| 100 | void processFinished(int returncode); |
| 101 | |
| 102 | /* |
| 103 | * cancel() was called on this Process. If the Process |
| 104 | * failed to terminate, argument is false, in which calling |
| 105 | * kill() is the last resort. |
| 106 | */ |
| 107 | void processCancelled(bool success); |
| 108 | |
| 109 | /* |
| 110 | * kill() was called on this Process. If this does not |
| 111 | * succeed, there is nothing else that Blitz can do to |
| 112 | * stop its execution. |
| 113 | */ |
| 114 | void processKilled(bool success); |
| 115 | }; |
| 116 | |
| 117 | /* |
| 118 | * Thin wrapper around a system-level process. Most closely |
| 119 | * resembles Python's subprocess.Popen class. |
| 120 | */ |
| 121 | interface Process { |
| 122 | |
| 123 | /* |
| 124 | * Returns the return code of the process, or null |
| 125 | * if unfinished. |
| 126 | */ |
| 127 | omero::RInt poll(); |
| 128 | |
| 129 | /* |
| 130 | * Blocks until poll() would return a non-null return code. |
| 131 | */ |
| 132 | int wait(); |
| 133 | |
| 134 | /* |
| 135 | * Signal to the Process that it should terminate. This may |
| 136 | * be done "softly" for a given time period. |
| 137 | */ |
| 138 | bool cancel(); |
| 139 | |
| 140 | /* |
| 141 | * Terminate the Process immediately. |
| 142 | */ |
| 143 | bool kill(); |
| 144 | |
| 145 | /* |
| 146 | * Add a callback for end-of-life events |
| 147 | */ |
| 148 | void registerCallback(ProcessCallback* cb); |
| 149 | |
| 150 | /* |
| 151 | * Remove a callback for end-of-life events |
| 152 | */ |
| 153 | void unregisterCallback(ProcessCallback* cb); |
| 154 | }; |
| 155 | |
| 156 | /* |
| 157 | * Simple controller for Processes. Uses the session |
| 158 | * id given to create an Ice.Config file which is used |
| 159 | * as the sole argument to an execution of the given job. |
| 160 | * |
| 161 | * Jobs are responsible for loading arguments from the |
| 162 | * environment via the session id. |
| 163 | */ |
| 164 | interface Processor { |
| 165 | |
| 166 | /* |
| 167 | * Starts a process based on the given job. If |
| 168 | * this processor cannot handle the given job, a |
| 169 | * null process will be returned. |
| 170 | */ |
| 171 | ["ami"] Process* processJob(string session, omero::model::Job j) throws ServerError; |
| 172 | |
| 173 | /* |
| 174 | * Parses a job and returns metadata definition required |
| 175 | * for properly submitting the job. |
| 176 | */ |
| 177 | ["ami"] JobParams parseJob(string session, omero::model::Job j) throws ServerError; |
| 178 | |
| 179 | }; |
| 180 | |
| 181 | |
| 182 | /* |
| 183 | * Client facing interface to the background processing |
| 184 | * framework. If a user needs interactivity, one of these |
| 185 | * processors should be acquired from the ServiceFactory. |
| 186 | * Otherwise, a Job can be submitted via JobHandle. |
| 187 | */ |
| 188 | interface InteractiveProcessor { |
| 189 | |
| 190 | /* |
| 191 | * Returns the system clock time in milliseconds since the epoch |
| 192 | * at which this processor will be reaped. |
| 193 | */ |
| 194 | long expires(); |
| 195 | |
| 196 | /* |
| 197 | * Returns the job which defines this processor. This may be |
| 198 | * only the last job associated with the processor if execute |
| 199 | * is called multiple times. |
| 200 | */ |
| 201 | omero::model::Job getJob(); |
| 202 | |
| 203 | /* |
| 204 | * Retrieves the parameters needed to be passed in an execution |
| 205 | * and the results which will be passed back out. |
| 206 | */ |
| 207 | JobParams params() throws ServerError; |
| 208 | |
| 209 | /* |
| 210 | * Executes an instance of the job returned by getJob() using |
| 211 | * the given map as inputs. |
| 212 | */ |
| 213 | ["ami"] Process* execute(omero::RMap inputs) throws ServerError; |
| 214 | |
| 215 | /* |
| 216 | * Retrieve the results for the given process. This will throw |
| 217 | * an ApiUsageException if called before the process has returned. |
| 218 | * Use either process.poll() or process.wait() or a ProcessCallback |
| 219 | * to wait for completion before calling. |
| 220 | * |
| 221 | * If the user has not overridden or disabled the output values |
| 222 | * "stdout" and "stderr", these will be filled with the OriginalFile |
| 223 | * instances uploaded after completion under the key values of the |
| 224 | * same name. |
| 225 | */ |
| 226 | ["ami"] omero::RMap getResults(Process* proc) throws ServerError; |
| 227 | |
| 228 | }; |
| 229 | }; |
| 230 | }; |
| 231 | |
| 232 | #endif |
Note: See TracBrowser
for help on using the browser.
