IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6055


Ignore:
Timestamp:
Jan 19, 2006, 12:58:19 AM (21 years ago)
Author:
eugene
Message:

updates

Location:
trunk/doc
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/Makefile

    r6033 r6055  
    11# Makefile for all IPP main engineering documents
    22
    3 DIR = pslib modules design hardware ipptools pantasks psphot misc
     3DIR = pslib modules design hardware dvo ipptools pantasks psphot misc
    44
    55all:
  • trunk/doc/design/ippSSDD.tex

    r6054 r6055  
    1 %%% $Id: ippSSDD.tex,v 1.5 2006-01-19 06:49:50 eugene Exp $
     1%%% $Id: ippSSDD.tex,v 1.6 2006-01-19 10:58:19 eugene Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    779779\subsection{AP Database}
    780780
     781\tbd{this section needs to be updated with current implemetation; the
     782  DVO SDD contains much of this information, but needs to be fleshed
     783  out in places.}
     784
    781785\subsubsection{Corresponding Requirements}
    782786
     
    11991203%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    12001204
    1201 \subsection{Controller}
    1202 \label{sec:Controller}
    1203 
    1204 \subsubsection{Corresponding Requirements}
    1205 
    1206 The Controller must meet the requirements specified in Section 3.4.4
    1207 of the Pan-STARRS PS-1 IPP SRS (PSDC-430-005).  The design must meet
    1208 requirements 3.4.4.1 - 3.4.4.7.  In particular, the Controller / Node
    1209 Agent architecture is chosen to control the I/O flow between the
    1210 Controller and the individual processes so that blocking on the I/O
    1211 from many remote processes does not saturate the Controller
    1212 processing.
    1213 
    1214 \subsubsection{Overview}
     1205\subsection{PanTasks : the IPP Scheduler}
     1206
     1207PanTasks is the IPP tool which manages the sequencing of data analysis
     1208steps and, with the related tool `PControl', distributes the data
     1209processing across a cluster of computers. \tbd{describe the 'opihi'
     1210shell-scripting system}
     1211
     1212The purpose of PanTasks is to manage the automatic construction and
     1213execution of inter-related (often repetative) operations.  PanTasks
     1214uses a set of rules to define UNIX commands, and their corresponding
     1215command-line arguments, to be performed on some regular, repeated
     1216basis.  The utility of PanTasks is that it can easily define and
     1217manage an analysis system which is completely state-based, as opposed
     1218to an event-driven system.
     1219
     1220Consider, for example, a telescope which obtains a collection of
     1221images over the course of a night. Every minute or two, it takes an
     1222image and writes the image to some disk. An event-driven analysis
     1223system would involve having the telescope initiate a process at the
     1224end of the exposure. This process would perform an analysis, write
     1225some output, then send trigger another process. This type of operation
     1226works very well for a simple set up with reliable hardware. Such a
     1227system becomes more difficult to maintain when hardware failures occur
     1228or when multiple systems need to interact with each other. When
     1229failures occur, the triggering information (the events) is easily
     1230lost, thus some mechanisms are needed to detect these failures and
     1231either re-send the trigger or send an alternative failure-mode
     1232trigger. Or, if two systems need to interact, one or the other system
     1233must block for results from the first. Stopping and restarting such an
     1234analysis system is very delicate since the appropriate triggers must
     1235be set up some how, eg by noticing which images have not succeeded and
     1236restarting them at the appropriate stage. All of these types of
     1237methods of handling complexity and failures are essentially
     1238state-based rules. PanTasks allows the easy definition of a totally
     1239state-based analysis system.
     1240
     1241In a state-based system, some mechanism examines the state of the
     1242system and decides which actions to perform based on the current
     1243state. In the illustration above, the mechanism could examine the
     1244images available (either by examining the disk or by examining the
     1245state of a data table) and decide to perform an operation based on
     1246what images are available. This makes it very easy to handle
     1247complexity and errors. If an analysis fails, the state either is not
     1248successfully updated or the error state is recorded, both situations
     1249being easy to detect and easy to handle. Restarting the system simply
     1250involves starting the state-monitoring mechanism. Combining results
     1251from multiple input sources simply involves watching for the multiple
     1252inputs to be available. PanTasks provides a mechanism to define state
     1253monitors, and to define the actions which are performed when those
     1254states occur. PanTasks action consist of initiating UNIX commands, where
     1255the arguments of those commands may depend on the results of the state
     1256tests. 
     1257
     1258\subsubsection{Tasks vs Jobs}
     1259
     1260The two basic units of PanTasks operation are the 'task' and the
     1261'job'.  A 'job' is simply a command the user would execute on a
     1262command line; it consists of a command along with optional command
     1263line arguments.  A 'task' is a generic description of a type of job in
     1264which the details of any specific piece of data are omitted.  The task
     1265defines the UNIX command which corresponds to the job, and it provides
     1266rules for determining the identity of data for the job.  The task also
     1267defines tests which are used to decide if the job may be executed.
     1268Finally, it defines a polling frequency in which PanTasks should
     1269attempt to construct a new job for the task.
     1270
     1271For example, we may want to regularly copy files from one location to
     1272another.  Perhaps the name of the next available file is available in
     1273a database table, and can be retrieved with the command 'nextFile'.
     1274Perhaps we wish to check for new files every 60 seconds.  Thus, the
     1275task is to copy files, while a specific job of this task might be of
     1276the form \code{cp newfile newpath}.  With PanTasks, we would define a
     1277copy task somewhat like the following:
     1278
     1279\begin{verbatim}
     1280  task copyfile
     1281    periods -exec 60.0
     1282
     1283    task.exec
     1284      $file = `nextFile`
     1285      if ($file == "none")
     1286        break
     1287      end
     1288      command cp $file $newpath
     1289    end
     1290
     1291    task.exit 0
     1292      queuepush copied $file
     1293    end
     1294
     1295    task.exit 1
     1296      queuepush failure $file
     1297    end
     1298  end
     1299\end{verbatim}
     1300
     1301In this simple example, the task is attempted every 60 seconds.  If
     1302there is no new file (output of 'nextFile' is 'none'), then no job
     1303results from this task.  If there is a new file, the copy command is
     1304performed.  This example is deceptively simple because one could
     1305easily imagine writing a stand-along program which performs the same
     1306thing.  The important advantages of using PanTasks for this type of
     1307operation are:
     1308\begin{itemize}
     1309\item the output from one job can be used to spawn a number of other tasks.
     1310\item the success or failure state of each job can be used to spawn
     1311  other tasks.
     1312\item the details of the job and data test are kept separated from the
     1313  rules which connect tasks together. 
     1314\item the relationships between tasks are kept together in a single
     1315  location.
     1316\end{itemize}
     1317
     1318In addition to these organizational advantages, PanTasks also provides
     1319a direct connection to the tool for monitoring parallel jobs,
     1320pcontrol.  Thus the jobs spawned by PanTasks can be defined to run in
     1321the background locally or on any of the computers in the parallel
     1322processing cluster.
     1323
     1324\subsubsection{Parallel vs Local Job Processing}
     1325
     1326Jobs which are generated by PanTasks tasks may either be run locally
     1327(forked in the background on the same machine as PanTasks) or run on
     1328the IPP parallel process controller, pcontrol. The default is for the
     1329job to be run locally. If a job should be run on the parallel
     1330controller, this can be specified by including the command host
     1331(hostname) in the definition of a task. If the value of (hostname) is
     1332'anyhost', then pcontrol may select any of its host computers to run
     1333the job according to its own rules. If the value of (hostname) is one
     1334of the computers managed by pcontrol, then that machine will be
     1335selected for the job, if it is available. This amounts to a preference
     1336to use that machine, but pcontrol is allowed to substitute a different
     1337machine if it chooses. If the host command is given the option
     1338-required, then pcontrol is forced to use the named host, even if the
     1339machine is down, unknown, or otherwise unavailable. If the machine is
     1340not available, pcontrol will simply hold onto the job until the
     1341machine is available or the job is deleted. Note that PanTasks may
     1342delete jobs from pcontrol if they remain pending for too long.
     1343
     1344It is possible to interact directly with the parallel processor to
     1345examine the current status, halt the parallel processor, etc. Commands
     1346to the parallel processor are defined under the controller
     1347command. The following controller commands are available:
     1348
     1349\begin{itemize}
     1350
     1351\item controller host (command) (hostname): Manage the parallel
     1352  controller collection of hosts. This command can be used to add a
     1353  new host, the delete one of the existing hosts, to turn a host on or
     1354  off, and to check the status of a host
     1355
     1356  \begin{itemize}
     1357  \item controller host add (hostname): add a new host.
     1358
     1359  \item controller host delete (hostname): delete a host.
     1360
     1361  \item controller host on (hostname): tell pcontrol that the host is on.
     1362
     1363  \item controller host off (hostname): tell pcontrol that the host is off.
     1364
     1365  \item controller host retry (hostname): tell pcontrol to retry the host connection.
     1366
     1367  \item controller host check (hostname): check the current status of a host.
     1368  \end{itemize}
     1369
     1370  \item controller exit: stop controller execution.
     1371
     1372  \item controller status: report controller current status.
     1373
     1374  \item controller check: check job or host status.
     1375
     1376  \item controller output: print accumulated messages from the controller.
     1377\end{itemize}
     1378
     1379It is also possible to specify a host for a task which has not been
     1380identified to the controller. If such a host is required, the
     1381controller will simply keep the associated jobs in the pending state
     1382until such a machine exists. See the pcontrol section below for
     1383further discussion of the controller manipuation of jobs and hosts.
     1384
     1385\subsubsection{Task Restrictions}
     1386
     1387Tasks may have restrictions on when they create jobs and how
     1388frequently they create jobs. The task command trange is used to
     1389specify a valid or invalid time range for a task. A valid time range
     1390limits the task evaluation to that time period. An invalid time range
     1391excludes task evaluation from the time period. Any number of time
     1392range restrictions may be defined, and the union of all restrictions
     1393will define if a job may be created. By default, the time range is an
     1394inclusive time range: the task is evaluated only if the current time
     1395falls within the specified time range. Alternatively, if the -exclude
     1396flag is given, the time range is exclusive, in which case the task is
     1397not evaluated if the current time falls within this range.
     1398
     1399The time range may be given as a range of absolute dates as follows:
     1400
     1401\begin{verbatim}
     1402 trange YYYY/MM/DD,HH:MM:SS YYYY/MM/DD,HH:MM:SS
     1403\end{verbatim}
     1404
     1405where the two dates specify the start and end of the time range. In
     1406either of these date representations, the least-significant elements
     1407of the date and time may be dropped, defaulting to 00 (in the case of
     1408hours, minutes, and seconds) or 01 (in the case of day and
     1409months). Rather than specifying an end date, it is also valid to
     1410specify a time interval from the starting date. The time interval is
     1411specified as a number followed by a unit indicated by a single letter:
     1412d (days), h (hours), m (minutes), s (seconds).
     1413
     1414The time range may also be specified as a repeated period of time,
     1415either as a time of day or a day and time of week. In the first case,
     1416the time range is specified as follows:
     1417
     1418 
     1419\begin{verbatim}
     1420 trange HH:MM:SS HH:MM:SS
     1421 \end{verbatim}
     1422
     1423
     1424where again the least-significant elements may be dropped and default
     1425to 00. This type of restriction defines a time range which is valid
     1426every day. The alternative is to specify a time range within the week,
     1427in the following form:
     1428
     1429\begin{verbatim}
     1430 trange DAY@HH:MM:SS DAY@HH:MM:SS
     1431\end{verbatim}
     1432
     1433where the value of DAY may take on any of the three letter day-of-week
     1434names (Sun, Mon, Tue, etc). This restriction specifies a start and end
     1435time within a week which is evaluated for each week.
     1436
     1437Below are several examples of valid time range restrictions
     1438
     1439\begin{verbatim}
     1440 trange 2005/01/01 2005/12/31   (only run during 2005!)
     1441 trange 18:00 00:00             (only run from 6pm until midnight)
     1442 trange 00:00 06:00             (only run from midnight until 6am)
     1443 trange Mon@08:00 Fri@17:00     (only run between Mon morning and Fri afternoon)
     1444 trange -exclude 12:00 13:00    (skip 1 hour from noon)
     1445\end{verbatim}
     1446
     1447Note that the current definition of trange does not include time zone
     1448information. This means that all times are relative to UT. This should
     1449be addressed by adding a timezone environment variable to PanTasks and
     1450by allowing the trange to define a timezone offset.
     1451
     1452It is also possible to restrict the total number of jobs which are
     1453spawned for a given task. This is done with the nmax command, which is
     1454given as part of the task definition. Once a task has constructed nmax
     1455jobs, it stops task evaluation. It is possible to redefine the value
     1456of nmax at any time by redefining the task. Any time the task is
     1457redefined, the new values for any task concept will override the
     1458existing values for the task concept.
     1459
     1460\subsubsection{Inter-Task and Inter-Job Communications}
     1461
     1462There are several ways in which the results of jobs may be used to
     1463influence other jobs. These include:
     1464
     1465\begin{itemize}
     1466\item external communications
     1467\item job exit status
     1468\item job stdout/stderr parsing
     1469\end{itemize}
     1470
     1471It is always possible for the interprocess communication to be
     1472performed externally: all jobs may simply write results to an external
     1473data source which is queried as part of the task evaluation. PanTasks
     1474may interact with UNIX programs using Opihi system interaction
     1475functions. These interaction methods include: the backticks for
     1476setting Opihi variables:
     1477
     1478\begin{verbatim}
     1479 $variable = `UNIX Command`
     1480\end{verbatim}
     1481
     1482The exec command (which executes a UNIX command) and the backticks
     1483both receive the UNIX command exit status, setting the variable
     1484\code{$STATUS}. It is also possible to set a variable list to the
     1485output of a UNIX command:
     1486
     1487\begin{verbatim}
     1488 list var -x "UNIX Command"
     1489\end{verbatim}
     1490
     1491In this last case, the values \code{$var:0 - $var:N-1} are set to the
     1492value of the stdout lines from the UNIX command, and the value
     1493\code{$var:n} is set to the number of output lines.
     1494% $
     1495
     1496Fine-grained control over the job exit status is available with the
     1497task.exit macro command. This allows a task to define an exit macro
     1498which is performed for different exit status conditions. The argument
     1499to the task.exit command is the exit status value which triggers the
     1500macro. This may consist of any valid numeric exit status value
     1501(0-255). It may also have the value crash, in which case the macro is
     1502executed if the program exited as a result of a signal (ie,
     1503segmentation fault, etc). Finally, if may have the value default, in
     1504which case, the macro is run if no other macro describes the exit
     1505status.
     1506
     1507Jobs may transmit their results back to PanTasks for further
     1508evaluation through the standard output and standard error
     1509streams. Whenever a job exits, the complete stdout and stderr streams
     1510from the job are pushed onto the PanTasks queues \code{stdout} and
     1511\code{stderr}. The job exit macros may then parse these queues, moving
     1512the results into other PanTasks / Opihi data containers (queues,
     1513variables, vectors, whatever is appropriate). Note that currently, the
     1514output data is simply pushed onto these output queues. It is currently
     1515the responsibility of the PanTasks programmer to use or dispose of the
     1516data in these queues. This may change in the future: the queues may be
     1517flushed for each job completion.
     1518
     1519\subsubsection{PanTasks Monitoring Loop}
    12151520
    12161521\begin{figure}
    12171522\begin{center}
    1218 \resizebox{4.5in}{!}{\includegraphics{pics/Controller}}
    1219 \caption{Schematic illustration of the Controller components}
    1220 \label{fig:Controller}
     1523\includegraphics[scale=0.85,angle=-90]{pics/pantasks.01.ps}
     1524\caption{\label{MonitorLoop} PanTasks Monitor Loop}
    12211525\end{center}
    12221526\end{figure}
    12231527
     1528Figure~\ref{MonitorLoop} illustrates the operation of PanTasks.
     1529Currently, PanTasks is run as a stand-alone foreground process, not a
     1530server.  In this current operating mode, PanTasks accepts commands
     1531from the user (left side) via a GNU readline interface.  Readline
     1532provides a mechanism to schedule an background process which is
     1533executed on a regular basis, or in the interval after each keystroke.
     1534This background processing is represented as the loop on the right.
     1535In this loop, PanTasks checks on the status of pcontrol and on any
     1536locally spawned background jobs.  It also checks the list of tasks for
     1537tasks which are ready to be executed.  The tasks and the background
     1538jobs are kept in rotating queues.  Every time the loop is processed,
     1539PanTasks runs through a number of the background jobs and tasks,
     1540attempting to evaluate as many as possible, but stopping after a
     1541limited number of milliseconds.  This test stage cycles through the
     1542tasks and/or jobs in their queue, but stops if it examines all of the
     1543entries in the queue.  If this testing process runs out of time before
     1544the entire queue is searched, it leaves the sequence intact for the
     1545next pass.  The timeout is set to keep the keyboard small enough to
     1546keep the human interaction from being troublesome.
     1547
     1548\begin{figure}
     1549\begin{center}
     1550\includegraphics[scale=0.85,angle=-90]{pics/pantasks.02.ps}
     1551\caption{\label{TaskLoop} PanTasks Task Check Loop}
     1552\end{center}
     1553\end{figure}
     1554
     1555Figure~\ref{TaskLoop} shows the interactions performed for each check
     1556of the list of tasks.  The task timers are examined to see if the
     1557specific task is ready to be executed.  If so, then the task exec
     1558macro is executed.  If this macro exit status is false, the loop goes
     1559to the next task.  If the task exec macro is true, the job command is
     1560constructed and the job is submitted to the correct location, either
     1561the controller (pcontrol) or to the queue of local, background jobs.
     1562
     1563\begin{figure}
     1564\begin{center}
     1565\includegraphics[scale=0.85,angle=-90]{pics/pantasks.03.ps}
     1566\caption{\label{JobLoop} PanTasks Job Check Loop}
     1567\end{center}
     1568\end{figure}
     1569
     1570Figure~\ref{JobLoop} shows the interactions performed for each check
     1571of a single background job.  The job timer is checked to see if the
     1572job has timed out.  Next, the job run status is examined to see if the
     1573job has finished or not.  If the job has finished, the appropriate
     1574exit macro is executed and the job results are returned to the rest of
     1575the PanTasks data structures (ie, stderr and stdout queues are filled
     1576out).  Users should not define exit macros which perform long running
     1577jobs, or PanTasks will become quite sluggish to keyboard strokes.
     1578
     1579PanTasks also checks the current status of pcontrol on each loop.
     1580In this test, PanTasks requests from pcontrol a list of the jobs which
     1581have finished.  It then attempts to harvest the finished jobs one by
     1582one and place the results in the approrpiate locations.  This loop is
     1583also limited to a fixed amount of time; any pcontrol jobs which remain
     1584unharvested are left for the next pass by PanTasks.
     1585
     1586\subsubsection{Running the scheduler}
     1587
     1588Once a set of tasks has been defined, the scheduler can be
     1589started. The scheduler will run in the background, at regular
     1590intervals examining the collection of tasks and jobs. In these
     1591periods, the scheduler attempts to construct new jobs and checks on
     1592the status of jobs which may have finished, either locally or on the
     1593controller. To start the scheduler, give the command run. To stop the
     1594scheduler, given the command stop. The current status of the
     1595scheduler, controller, and any jobs which have been spawned are listed
     1596with the status command.
     1597
     1598It is also possible to kill or delete individual jobs by hand with the
     1599commands kill (jobID) or delete (jobID).  Other features
     1600
     1601\subsection{pcontrol : the PanTasks parallel controller}
     1602
    12241603The IPP uses a group of computers to store and process images and to
    1225 manipulate collections of detections.  These computers perform any of
    1226 a large number of analysis stages or other processing tasks without
    1227 significant interprocess communication.  It is necessary to have a
     1604manipulate collections of detections. These computers perform any of a
     1605large number of analysis stages or other processing tasks without
     1606significant interprocess communication. It is necessary to have a
    12281607mechanism which initiates computing tasks on the different computers,
    12291608which monitors the tasks as they are executed, which handles the
    12301609output and the errors from these tasks, and which reacts to the
    1231 failure of any of the computing nodes.  The system responsible for the
    1232 tasks in the IPP is the IPP Controller.
    1233 
    1234 The IPP Controller interacts with the collection of computers under
    1235 its management and with other subsystems in the IPP.  The IPP
    1236 Controller receives a variety of inputs from other subsystems,
    1237 described below, and initiates actions such as adding a new process to
    1238 the queue of pending tasks.  The IPP Controller also provides
    1239 information to other subsystems on demand about its processing history
    1240 and current state.  Each physical computer may have multiple
    1241 processors; since the IPP Controller is managing processing tasks, it
    1242 treats each processor independently.  It is up to the system
    1243 configuration if each computer needs to reserve one of its CPUs to
    1244 manage background tasks or if the IPP Controller should attempt to
    1245 send one task per CPU and let the operating system handle the I/O
    1246 load.  The relationship between the different components of the
    1247 Controller is illustrated in Figure~\ref{fig:Controller} and discussed
    1248 below.
    1249 
    1250 \subsubsection{Nodes}
    1251 
    1252 The Controller maintains a table of available processing computers
    1253 (`Nodes') and tracks the status of these Nodes.  Nodes managed by the
    1254 IPP Controller are allowed to be in one of several states, and the IPP
    1255 Controller must interact with it in an appropriate way for each of
    1256 those states.  A Node may be {\tt alive}, {\tt dead} or {\tt off}.
    1257 If the Node is {\tt alive}, it responds to commands from the IPP
    1258 Controller and may be used for tasks subject to other constraints.  If
    1259 it is {\tt dead}, the Node is not responsive and must not be used
    1260 for executing tasks.  The IPP Controller must identify Nodes which
    1261 have died (not responding) and occasionally test them to see if they
    1262 are {\tt alive} again.  Nodes which are {\tt off} are not
    1263 available for tasks and must not be tested.  Nodes may be set to
    1264 the {\tt off} or {\tt dead} states by external subsystems; it is the
    1265 responsibility of the IPP Controller to return a Node to the {\tt
    1266 alive} state if possible.
    1267 
    1268 The IPP Controller must honor requests (normally from the users) to
    1269 change the mode of any computing node on demand between {\tt off} and
    1270 {\tt dead}.  This would normally be done after a Node has been
    1271 rebooted and is released to the IPP Controller for its use.  It must
    1272 also be able to change the list of allowed tasks as requested by
    1273 external commands.
    1274 
    1275 Two example scenarios illustrate the transition between these states,
    1276 and the basic concept of operations for the IPP Controller.  First,
    1277 imagine a computer crashes.  At this point the IPP Controller should
    1278 detect that the Node is no longer responsive and mark it as {\tt
    1279 dead}.  It should occasionally try to re-establish communication with
    1280 the Node, potentially with longer and longer delays between attempts.
    1281 A human could be notified if the Node seems to remain {\tt dead} for a
    1282 very long time.  In another scenario, a person needs to work on a
    1283 Node.  They notify the IPP Controller that the machine is {\tt off},
    1284 perhaps with a prior notification that the machine should be prepared
    1285 to go off.  When work on the machine is complete, it should be placed
    1286 in the {\tt dead} state.  Only when the person is done working and
    1287 testing the machine, and tells the IPP Controller that the machine is
    1288 now {\tt dead} can the IPP Controller attempt to re-start
    1289 communications and re-new processing operations on that Node.
    1290 
    1291 \subsubsection{Node Agents}
    1292 
    1293 When the Controller starts, it attempts to launch a Node Agent on each
    1294 of the available processing Nodes.  Nodes which are not responsive are
    1295 marked as {\tt dead} so they may be re-tried.  A Node Agent runs on
    1296 each of the individual nodes to execute the tasks as directed by the
    1297 Controller.  The Node Agents communicate with the Controller via a
    1298 socket connection.
    1299 
    1300 A Node Agent (which is only running on a Node in the {\tt alive}
    1301 state) may be in one of four modes: {\tt idle}, {\tt busy}, {\tt
    1302 done}, {\tt crash}.  A Node Agent which is {\tt busy} currently has a
    1303 task assigned to it which is executing.  The IPP Controller may only
    1304 assign one task to a Node at a time.  A Node Agent which is in the
    1305 {\tt idle} state may have a task assigned to it.  When the Node Agent
    1306 detects that a tasks has finished, it changes to either the {\tt done}
    1307 or {\tt crash} states depending on the outcome of the process
    1308 execution.  The IPP Controller must also respect a list of task
    1309 restrictions which may require specific tasks to run on specific CPUs
    1310 or exclude specific tasks from specific CPUs.
    1311 
    1312 A task being executed by the Node is run in the UNIX user space as a
    1313 forked process.  The Node Agent must monitor the standard error and
    1314 standard output of the executing task and save them in separate
    1315 buffers.  If the process exits or dies, the Node Agent must detect
    1316 this result and change state appropriately.  The Node Agent must
    1317 respond to various commands from the Controller, as follows:
    1318 
    1319 \paragraph{Report status}
    1320 
    1321 The Node Agent returns its state ({\tt idle}, {\tt busy}, {\tt done},
    1322 {\tt crash}) and the exit status of the current processing task, if
    1323 available.  The reported exit state, if the process has completed
    1324 without crashing, is the UNIX exit state reported by the task: 0--256
    1325 with 0 indicating a successful completion.
    1326 
    1327 \paragraph{Report stdout}
    1328 
    1329 Send and flush the current stdout buffer.  The Node Agent will return
    1330 the complete contents of the stdout buffer via a buffered write and
    1331 flush the buffer when it is finished.  The Node Agent will not accept
    1332 more data on the stdout buffer from the current processing task until
    1333 the send is complete and the buffer is flushed.  The daemon must
    1334 accept all of the buffer output.
    1335 
    1336 \paragraph{Report stderr}
    1337 
    1338 Identical to `report stdout', but for stderr.
    1339 
    1340 \paragraph{Kill task }
    1341 
    1342 The Node Agent should send a kill signal (\code{KILL} or \code{TERM})
    1343 to the current processing task.  When the processing task has exited,
    1344 the Node Agent should set its state to {\tt crash}.
    1345 
    1346 \paragraph{Clear task}
    1347 
    1348 The Node Agent should set its state {\tt idle}.  If a processing stage
    1349 is currently running, it should be killed (\code{KILL} or \code{TERM})
    1350 before the task is cleared.
    1351 
    1352 \paragraph{Start processing stage}
    1353 
    1354 The Node Agent forks a specified command.  The command should be a
    1355 standard UNIX command without command line redirection or
    1356 backgrounding.  The task is run with the same user ID as the Node
    1357 Agent, which is also the same user ID as the Controller.
    1358 
    1359 \subsubsection{Tasks}
    1360 
    1361 The IPP Controller accepts tasks from other IPP subsystems.  The task
    1362 requests include the specific command to be executed and are in the
    1363 form of a UNIX command which could be performed on any of the
    1364 computing nodes.  Any input or output data in the commands must be a
    1365 valid resource regardless of the node on which the task is executed.
    1366 Input and output data resources must be unique where necessary to
    1367 avoid conflicts.  It is the responsibility of the task to wait for
    1368 network lags (ie, NFS delays).  The IPP Controller gives each task a
    1369 unique identifier, which is returned to the requesting entity.  The
    1370 requestor may then use that ID to obtain status information on that
    1371 task or to send control signals to the specific task.
    1372 
    1373 Task requests may specify a desired node for the task execution.  The
    1374 IPP Controller attempts to honor the request if the node is {\tt
    1375 alive}, but will execute it on another node if the requested one is
    1376 {\tt dead} or {\tt off}.  Even if a node is {\tt alive}, the IPP
    1377 Controller will choose another node if the specified task is not
    1378 allowed on the requested node.  In all other cases, the IPP Controller
    1379 waits until the currently executing processes, and processes with
    1380 higher priority, are completed before executing the specified task on
    1381 the requested node.
    1382 
    1383 Task requests may specify an urgency level.  The IPP Controller
    1384 determines the priority of the task on the basis of both the urgency
    1385 and the age of the request.  An executing task must be completed on a
    1386 CPU before any new task is started on that CPU, regardless of
    1387 priority.  The urgency levels range from 0 to 2.  Tasks with an
    1388 urgency of 1 are scheduled whenever they reach the top of the stack.
    1389 Tasks with an urgency of 2 are sent immediately to the top of the
    1390 stack. Tasks assigned a priority of 0 are maintained in the queue and
    1391 never executed.
    1392 
    1393 It may be useful for the Controller to distinguish between tasks
    1394 dominated by I/O and tasks dominated by data processing.  It is
    1395 possible that one of each of these types of tasks may be sent to the
    1396 same node without significantly impacting the system performance.
    1397 Alternatively, it may be necessary to limit a single machine with 2
    1398 CPUs to only one of each of these types of tasks (i.e., one processor
    1399 will be working on I/O while the other is working on processing).
    1400 Such details will be studied by the IfA IPP Team.
    1401 
    1402 The IPP Controller monitors the output streams from the executing
    1403 tasks and the exit status of the tasks.  Each task is associated with
    1404 a log file, to which all output is written.  The status, including the
    1405 exit status, of each task is maintained by the IPP Controller so that
    1406 other subsystems may determine if specific tasks have started or
    1407 completed.
    1408 
    1409 \subsubsection{Controller Interfaces}
    1410 
    1411 The IPP Controller must accept commands from other IPP subsystems.
    1412 These commands include those which govern the processing of specified
    1413 tasks, those which govern the behavior of specific computing nodes,
    1414 and those which request information from the IPP Controller.  The IPP
    1415 Controller must be able to halt the execution of a specified task,
    1416 delete an unexecuted task from the task list, change the priority of
    1417 tasks, and change the requested nodes for tasks.  The IPP Controller
    1418 must also be able to stop the current execution of a task and push it
    1419 to the end of the queue and also change its priority.
    1420 
    1421 The IPP Controller must respond to informational requests regarding the
    1422 collection of machines and their states as well as the collection of
    1423 tasks and their states.  The IPP Controller must monitor the execution
    1424 times of the different tasks and provide summary statistics.  Finally,
    1425 the IPP Controller must respond to three top-level commands: {\tt finish},
    1426 {\tt stop} and {\tt abort}.  When {\tt finish} is requested, no more
    1427 new tasks are accepted on the stack of task, and when all tasks in the
    1428 stack have completed, the IPP Controller must exit.  When {\tt stop} is
    1429 requested, the currently executing tasks must be completed at which
    1430 point the IPP Controller must exit, but tasks remaining in the stack which
    1431 have not been started are flushed.  When {\tt abort} is issued, the
    1432 IPP Controller immediately kills all executing tasks and exits.
    1433 
    1434 The IPP Controller and the IPP Image Server have related needs for
    1435 information from the combined storage-and-processing nodes regarding
    1436 which nodes are available.  It is not yet clear if this information is
    1437 best stored in a single location (either IPP Controller or IPP Image
    1438 Server), which provides the information to other systems on demand, or
    1439 if both systems should maintain the information.  Also, it may be
    1440 necessary to distinguish nodes which are available for processing from
    1441 those that are available to serve data as part of the IPP Image
    1442 Server.
    1443 
    1444 The Controller maintains three tables of processing jobs: pending
    1445 stages, active stages, and completed stages.  The pending stages are
    1446 those which have not yet been performed.  The active stages are those
    1447 currently being performed on one of the remote nodes.  The completed
    1448 stages are those which have finished, either successfully or with an
    1449 error state.  The Controller daemon monitors the collection of remote
    1450 clients and sends them new pending stages when they become free.
    1451 
    1452 The IPP Controller provides a mechanism for users (either other
    1453 programs or humans) to interact with it.  The user interface provides
    1454 commands to check the current processing job queues, the tables of
    1455 successful and failed jobs, to stop or delete jobs, etc.
    1456 
    1457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1458 
    1459 \subsection{Scheduler}
    1460 \label{sec:scheduler}
    1461 
    1462 \subsubsection{Corresponding Requirements}
    1463 
    1464 The Scheduler must meet the requirements specified in Section 3.4.5 of
    1465 the Pan-STARRS PS-1 IPP SRS (PSDC-430-005).  The design must meet
    1466 requirements 3.4.5.1 - 3.4.5.7.  In particular, the Task / Test
    1467 division is chosen to prevent the Scheduler from blocking while an
    1468 analysis process is performed.  Scheduling requirements will be met by
    1469 defining appropriate Test periods for the different Tasks.
    1470 
    1471 \subsubsection{Overview}
    1472 
    1473 The IPP is responsible for a variety of analysis jobs: processing of
    1474 the science images through several stages; routine assessment of the
    1475 detrend (instrumental calibration) images used in processing the
    1476 science images; construction of replacement detrend images when
    1477 needed; generation of astrometric and photometric reference catalogs
    1478 based on the collected dataset; and the performance of test analysis
    1479 programs.  At any point, decisions need to be made about which of
    1480 these tasks should be performed, based on an analysis of the contents
    1481 of the metadata database, the requirements of the people monitoring
    1482 the IPP, and the near-term observing plans.  The IPP Scheduler is the
    1483 mechanism that assesses these various inputs to guide the decisions
    1484 and initiate the actions.
    1485 
    1486 The IPP Scheduler acts as an interface between several components of
    1487 the IPP and also between the IPP and external agents such as OTIS and
    1488 the users who must monitor the behavior of the IPP.  The IPP Scheduler
    1489 may be viewed as the central brain of the IPP.
    1490 Figure~\ref{fig:Scheduler} illustrates the design of the IPP
    1491 Scheduler.
    1492 
    1493 \subsubsection{Scheduler Tasks and Tests}
    1494 
    1495 The IPP Scheduler performs two types of actions.  'Tasks' are
    1496 long-running programs which are executed by the Controller.  These are
    1497 not only background tasks, but are distributed computing tasks.
    1498 Examples of these include the science analysis tasks (eg, Phase 1, 2,
    1499 3, 4), the Calibration construction tasks, and data copy tasks (such
    1500 as copying images and metadata from the summit system).  'Tests' are
    1501 short-running programs which are used to decide which tasks should be
    1502 run.  Tests should be designed to return immediately ($< 100 ms$) and
    1503 are not run in the background; the Scheduler will block until the test
    1504 is complete.  The IPP Scheduler daemon, which runs continuously,
    1505 performs tests (eg, queries of the IPP Metadata Database, queries of
    1506 OTIS, checks of the IPP hardware status, etc).  Based on these tests,
    1507 the daemon defines appropriate tasks and sends them to the Controller.
    1508 When tasks are completed, their results may be used by the Scheduler
    1509 to update the external systems (update the Metadata Database), or the
    1510 tasks themselves may send their results directly to the Metadata
    1511 Database or other subsystems.  Based on the successful completion (or
    1512 not!) of the tasks, and the new state of entries in the Metadata
    1513 Database, the Scheduler can define new tasks.
     1610failure of any of the computing nodes. The system responsible for the
     1611tasks in the IPP is pcontrol.
     1612
     1613\subsubsection{Host States}
    15141614
    15151615\begin{figure}
    15161616\begin{center}
    1517 \resizebox{6in}{!}{\includegraphics{pics/Scheduler}}
    1518 \caption{ \label{fig:Scheduler} IPP Scheduler}
     1617\includegraphics[scale=0.85,angle=-90]{pics/pantasks.04.ps}
     1618\caption{\label{HostStates} PanTasks Host States}
    15191619\end{center}
    15201620\end{figure}
    15211621
    1522 The IPP Scheduler sends tasks to the IPP Controller for execution.
    1523 While the IPP Scheduler chooses the tasks to be performed, it is the
    1524 IPP Controller's responsibility to manage the specific tasks executing
    1525 on a given processing node.  This division of responsibilities allows
    1526 the different functionalities of the IPP Scheduler and the IPP
    1527 Controller to be isolated and encapsulated.  With this separation, the
    1528 IPP Controller does not information about the details of the tasks it
    1529 executes, while the IPP Scheduler does not need to monitor the
    1530 computer hardware.
    1531 
    1532 Communication between the IPP Scheduler and the IPP Controller is
    1533 bi-directional; the IPP Scheduler sends tasks to the IPP Controller,
    1534 while the IPP Controller informs the IPP Scheduler of the outcome of
    1535 those tasks.  For the PS-1 IPP, the IPP Scheduler and the IPP
    1536 Controller are distinct, interacting software components.  The
    1537 interface mechanisms are described in Section~\ref{sec:interfaces}.
    1538 
    1539 \subsubsection{Task Rules}
    1540 
    1541 The IPP Scheduler takes as input a collection of rules which define
    1542 the dependency of tasks on certain tests.  The IPP Scheduler must
    1543 choose between several types of analysis tasks based on those rules
    1544 and on results of the tests.  The timescale on which different tasks
    1545 (and their related tests) are executed may vary from 10s of seconds to
    1546 hours, days, or even as long as a week.  The list of tasks which the
    1547 IPP Scheduler must decide between, and the relevant timescale, follow:
     1622pcontrol maintains a table of available processing computers (hosts)
     1623and tracks their status. Hosts managed by pcontrol are allowed to be
     1624in one of several states: \code{off}, \code{down}, \code{idle},
     1625\code{busy}, and \code{done} (see Figure~\ref{HostStates}). There are
     1626also two virtual states: \code{new} and \code{delete}.  These states
     1627have the following meanings:
     1628
     1629If the host is \code{off}, it is known to pcontrol, but pcontrol does
     1630not have an active connection to the machine. Hosts which are
     1631\code{off} are not available for jobs, and pcontrol does not attempt to
     1632initiate a connection to them.  A pcontrol user may force a host to
     1633transition to the \code{off} state with the command host
     1634\code{off~(hostname)}. (Note that this command will set only one of
     1635the connections to the named host to \code{off}. If multiple
     1636connections to a machine have been defined, multiple \code{off}
     1637commands must be sent).
     1638
     1639When pcontrol is told to consider a machine on, the machine is moved
     1640from the \code{off} state to the \code{down} state. Pcontrol attempts
     1641to initiate a connection to the host. Connections are made by running
     1642a remote client on the host, using the specified connection
     1643method. The connection method may be ssh, rsh, or an equivalent remote
     1644shell connection. The choice is specified by the \code{COMMAND} Opihi
     1645variable. The remote connection starts a dedicated remote client which
     1646must accept the pcontrol client commands and respond
     1647appropriately. The provided remote client is called {\em pclient},
     1648though in principal other equivalent programs could be used by setting
     1649the Opihi variable \code{SHELL}.  This feature more generally allows a
     1650user to specify a path to the remote client, if it is not in the
     1651user's path.
     1652
     1653If the remote connection is successful, the connected host is moved by
     1654pcontrol from the \code{down} state to the \code{idle} state. If the
     1655connection is unsuccessful, pcontrol will try again after a certain
     1656period of time. If the connection continues to be unsuccessful, the
     1657retry period is doubled for each successiver connection attempt. If
     1658the user wants to force pcontrol to retry the connection to a machine
     1659(if, for example, the timeout is now very long, but the user knows the
     1660machine's ethernet cable has been re-inserted...), this can be
     1661achieved with the command host \code{retry (hostname)}. A host which
     1662is \code{down} is in the limbo state between \code{off} and
     1663\code{idle}.
     1664
     1665Once pcontrol has made a successful connection to the host, the host
     1666is in the \code{idle} state. At this point, it is ready to accept jobs
     1667from pcontrol for execution. Pcontrol periodically queries the hosts
     1668to check that they are still alive. If a host is discovered to be
     1669unresponsive, and particularly if the remote pipe connection has
     1670closed, then the machine is moved back to the \code{down} state.
     1671
     1672Hosts which are \code{idle} may accept a job from pcontrol. A job
     1673simply consists of a bare UNIX command, without redirection of
     1674standard input or standard output. The host will initiate the job, and
     1675pcontrol will place the host into the \code{busy} state. The remote
     1676client, pclient, runs the job in the background and will continue to
     1677accept input from pcontrol. pcontrol will continue to check the status
     1678of the host, and now also the status of the specific job. As before,
     1679if the connection breaks, pcontrol will migrate the host to the
     1680\code{down} state. Any job already initiated on a host which goes down
     1681will be returned to the pool of unexecuted jobs for later processing,
     1682so the job will not be lost.
     1683
     1684When the job exits, pclient tells pcontrol that the job is completed,
     1685and specifies the exit status. At this point, pcontrol will move the
     1686host from \code{busy} to \code{done} state. It will stay in this state
     1687until pcontrol can determine the ending conditions and reset the
     1688remote client. pcontrol requests the standard error and standard
     1689output from the job from pclient. pcontrol stores this data with its
     1690information about the completed job, and send a reset command to the
     1691remote client. Once these cleanup tasks are successfully completed,
     1692pcontrol will move the host to the \code{idle} state, ready for
     1693further jobs.
     1694
     1695Each physical computer may have multiple processors. pcontrol treats
     1696each processor independently. It is up to the system configuration if
     1697each computer needs to reserve one of its CPUs to manage background
     1698tasks or if pcontrol should attempt to send one task per CPU and let
     1699the operating system handle the I/O load. some of this behavior will
     1700probably be eventually more intelligent. For example, the commands
     1701which turn a host on or off should be able to do the same operation to
     1702all host connections for the same machine name.
     1703
     1704A machine may be completely removed from pcontrol's host tables with
     1705the command host delete (hostname).
     1706
     1707\subsubsection{Jobs}
     1708
     1709The pcontrol accepts new jobs with the command \code{job ...}, in
     1710which the ellipsis represents the command and arguments of a valid
     1711UNIX command. The commands are run under \code{sh}, and are executed
     1712in the user's home directory. Users should be wary of the conditions
     1713under which the remote jobs are run. If the nodes in question all
     1714cross-mount the same home directories, multiple jobs which interact
     1715with the same named file may produce unexpected results. The
     1716controller cannot enforce good behavior on the part of the remote
     1717jobs; it is the responsibility of the user to ensure that conflicts do
     1718not arise by, eg, always using unique output file names.
     1719
     1720Other issues may arise from the fact that pcontrol may be choosing any
     1721of the hosts to run the job. Typical failures arise if the user does
     1722not realize that specific jobs do not behave the same on all machines,
     1723or if a necessary resource (eg, some input data file) is only
     1724available or accessible from some of the hosts. It is also the
     1725responsibility of the task to wait for network lags (ie, NFS delays).
     1726
     1727pcontrol gives each task a unique internal identifier (Job ID)
     1728equivalent to the process ID used in UNIX. When a job is submitted to
     1729pcontrol, the command echoes back the Job ID. This ID may be used by
     1730other pcontrol commands to obtain information about or interact with
     1731the job.  For example, PanTasks uses the Job ID to examine specific
     1732jobs.
     1733
     1734A job may specify a specific host for the task execution. The host
     1735specified for a job may be required, or desired. In the first case,
     1736pcontrol, will only run the job on the specified host, waiting until
     1737it is available before attempting the job. In the second case,
     1738pcontrol will attempt to send the job to the specified host, but if
     1739the host is unavailable (how long? what conditions?), pcontrol will
     1740allow the job to be sent to an alternative host. pcontrol attempts to
     1741honor the requests for required and desired hosts, giving priority
     1742first to required-host jobs, then to the desired-host jobs, and
     1743finally to all other jobs. To specify a host for a job, the following
     1744commands are used:
     1745
     1746\begin{verbatim}
     1747 job -host (command and arguments...)
     1748 job +host (command and arguments...)
     1749\end{verbatim}
     1750
     1751
     1752The first case specifies a desired host, while the second specifies a
     1753required host. It is also possible to specify the special host name
     1754anyhost, which is equivalent to not specifying a host at all.
     1755
     1756Job priority / urgency levels are not implemented at this time.
     1757
     1758I/O vs CPU tasks are not currently distinguished by pcontrol
     1759
     1760pcontrol stores the stdout and stderr for each completed job. To
     1761retrieve these data from these streams, the user issues the commands
     1762stdout (JobID) and stderr (JobID). The result is a single line
     1763specifying the number of bytes to expect, followed by a dump of the
     1764buffers, followed by the prompt. It is the user's responsibility to
     1765relieve pcontrol of this data load by deleting jobs once they are no
     1766longer needed. Job deletion is performed with the command delete
     1767(JobID).
     1768
     1769\begin{figure}
     1770\begin{center}
     1771\includegraphics[scale=0.85,angle=-90]{pics/pantasks.05.ps}
     1772\caption{\label{queues} pcontrol job states.  Transitions labeled Ux
     1773  are issued by the pcontrol user (including PanTasks).  Transitions
     1774  labeled Px are initiated by pcontrol.  Transitions labeled Tx are
     1775  the result of the job completion}
     1776\end{center}
     1777\end{figure}
     1778
     1779Jobs are moved between the following states by pcontrol (see
     1780Figure~\ref{JobStates}):
    15481781\begin{itemize}
    1549 \item moving data from the Summit pixel server ($\sim 30$ second timescales)
    1550 \item running the science analysis stages ($\sim 30$ second timescales)
    1551 \item testing the validity of the current detrend images ($\sim$
    1552   nightly)
    1553 \item constructing new detrend images ($\sim$ weekly)
     1782\item pending: the job has not yet been executed.
     1783\item busy: the job is currently being executed.
     1784\item done: the job has completed, but the stdout/stderr has not been processed by pcontrol.
     1785\item exit: the job has completed with a valid exit status
     1786\item crash: the job has completed with a crash status (exit on signal).
    15541787\end{itemize}
    1555 The scheduler may be viewed as a complex state machine.  The goal is
    1556 to design the scheduler so that rules may be specified independently
    1557 from the engine which parses the rules to determine which specific jobs
    1558 to send to the controller.
    1559 
    1560 \subsubsection{User Interface}
    1561 
    1562 The IPP Scheduler shall possess a user interface which allows a human
    1563 operator, or other processes, to monitor the current state of the
    1564 Scheduler.  Users have the option to specify that a particular task or
    1565 set of tasks is of higher or lower urgency (as defined in
    1566 Section~\ref{sec:Controller}) than the norm, or to schedule a
    1567 particular tasks on a different timescale from the basic rule.
    1568 
    1569 The IPP Scheduler defines the operating state of the IPP and shares
    1570 the same set of states:
    1571 \begin{itemize}
    1572 \item active state
    1573 \item interactive state
    1574 \item paused state
    1575 \end{itemize}
    1576 When the IPP Scheduler is in the {\em active state}, it performs the
    1577 most appropriate of all possible tasks at a particular time.  When the
    1578 IPP Scheduler is in the {\em interactive state}, it performs only a
    1579 specific requested action regardless of the outcome of the decision
    1580 trees.  In addition, in the interactive state, the IPP Scheduler must
    1581 only perform the requested actions and not attempt to perform the
    1582 other normally-required actions.  The only exception to this exclusion
    1583 is that, in the interactive state, data is still copied from the
    1584 summit system.  An additional IPP state is the {\em paused state},
    1585 intended for tests or maintenance, in which case the IPP Scheduler
    1586 does not perform even the data copy tasks.  Every task is performed on
    1587 demand by the user.  A user command sets the IPP Scheduler in one of
    1588 these three states, {\em active}, {\em interactive}, and {\em paused}.
     1788
     1789\subsubsection{Miscellaneous Commands}
     1790
     1791It is possible to check the status of a single host or job with the
     1792user command \code{check}.
     1793
     1794pcontrol continuously examines the stack of jobs, adjusting their
     1795state as needed and extracting their output when it is ready. These
     1796checks are performed in the background, with pcontrol ready to accept
     1797further commands from the user in the foreground. These checks are
     1798performed after every keystroke, and also after an inactivity
     1799timeout. The interrupt interval defaults to 1 second, but may be
     1800adjusted with the pulse command, which takes as an argument, the
     1801number of microseconds for the timeout.
     1802
     1803The pcontrol system status may be examined with the command
     1804status. This provides a dump of the job stacks and the host stacks.
     1805
     1806It is possible to list the jobs currently in a specific stack,
     1807corresponding to the list of jobs with a given state. This is done
     1808with the command jobstack (stackname). The valid stack names are
     1809pending, busy, exit, crash, and done. The result is a list of all jobs
     1810on the specified stack. This is useful to determine quickly which jobs
     1811have exited or crashed.
     1812
     1813A specific job may be killed with the command \code{kill
     1814(JobID)}. This command is only valid for a job in the busy state. Any
     1815job in the pending, exit, or crash state may be deleted with the
     1816\code{delete (JobID)} command. This is necessary to free the memory
     1817associated with the job and its output streams.  PanTasks
     1818automatically performs these job harvesting functions.
     1819
     1820The command \code{verbose (mode)} turns the verbosity of the pcontrol
     1821operations on or off.
     1822
     1823The pcontrol and Nebulous have related needs for information from the
     1824combined storage-and-processing nodes regarding which nodes are
     1825available. Currently, the two systems independently examine the
     1826hardware to judge the availability.  It is not yet clear if this
     1827information is best stored in a single location (either pcontrol or
     1828Nebulous), which provides the information to other systems on demand.
     1829The current implementation allows the IPP system as a whole to
     1830distinguih nodes which are available for processing from those that
     1831are available to serve data as part of Nebulous.
     1832
     1833\begin{figure}
     1834\begin{center}
     1835\includegraphics[scale=0.85,angle=-90]{pics/pantasks.06.ps}
     1836\caption{\label{PControlLoop} PControl Job Monitor Loop}
     1837\end{center}
     1838\end{figure}
     1839
     1840Figure~\ref{PControlLoop} illustrated the pcontrol job monitor loop.
     1841This is very similar to the loop in PanTasks.  A background process
     1842launched by readline during idle periods cycles through the list of
     1843hosts (children) and migrates jobs to and from them as needed.
     1844
     1845\subsubsection{pclient}
     1846
     1847pclient is the remote process monitor for pcontrol, the parallel
     1848process controller.
     1849
     1850The program pclient is used to support the remote jobs which are run
     1851on the remote hosts by pcontrol. The concept of pclient is to act as a
     1852buffer between the job running on the remote host and pcontrol. The
     1853pcontrol design uses (by default) ssh connections initiated by
     1854pcontrol to the remote hosts. These connections execute the remote
     1855program of pclient. The use of a remote login process lets the UNIX
     1856system take care of the user authentication issues. In this case, the
     1857recommended practice is to set up ssh to allow the connection to the
     1858remote host without additional authentication using the appropriate
     1859authorized keys.  The security is maintained by the security of ssh
     1860logins to the computers used by PanTask and pcontrol. 
     1861
     1862It is convenient to keep a continuous connection to the remote
     1863hosts. This avoids incurring the overhead of authentication for each
     1864command which is executed, while keeping a high-quality user
     1865authentication process in place.
     1866
     1867pclient acts as a buffer between pcontrol and the remote background
     1868process, allowing the continuous connection to remain viable without
     1869samping pcontrol with output from the jobs. 
     1870
     1871\begin{figure}
     1872\begin{center}
     1873\includegraphics[scale=0.85,angle=-90]{pics/pantasks.07.ps}
     1874\caption{\label{queues} PanTasks queues and MDDB tables}
     1875\end{center}
     1876\end{figure}
    15891877
    15901878%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    25072795object analysis in the other analysis stages.
    25082796
    2509 \subsection{AstroRef: Astrometric Reference Catalog creation}
    2510 
    2511 \tbd{needs to be fleshed out substantially}
    2512 
    2513 This processing stage shall use many observations over a given time
    2514 period to fit a consistent global astrometric solution, resulting in a
    2515 high quality and internally-consistent astrometric catalog that may be
    2516 published.
    2517 
    2518 \subsection{PhotoRef: Photometric Reference Catalog creation}
    2519 
    2520 \tbd{needs to be fleshed out substantially}
    2521 
    2522 This processing stage shall use many observations over a given time
    2523 period to fit a consistent global photometric solution, resulting in a
    2524 high quality and internally-consistent photometric catalog that may be
    2525 published.
     2797\section{IPPtools}
     2798
     2799Above, we discussed PanTasks, the IPP scheduler which determines the
     2800new jobs to run and distributes them to computers across the network.
     2801PanTasks is a general tool; by it self it does not define the specific
     2802analysis tasks that the IPP requires.  The previous few sections
     2803discussed in detail the analysis which is performed by the IPP
     2804analysis stages.  IPPtools is the collection of PanTasks scripts,
     2805Metadata Database interaction programs, and other tools used to
     2806definet the specific analysis stages of the IPP.
     2807
     2808\tbd{this section needs to be fleshed out with a summary of the
     2809  ippTools functions.  The stand-alone IPPTools document gives a
     2810  detailed discussion of these issues}.
    25262811
    25272812%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    39684253%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    39694254
     4255\section{PanTasks Example : Pcopy.pro}
     4256
     4257Below is an example script for psched which demonstrates the
     4258scheduling system. This parallel-copying script implements the
     4259Pan-STARRS image copying system, which requests images from the summit
     4260and copies them to the appropriate computer. The first task in the
     4261script queries an external system for new image names with the
     4262function new.images. In the case of Pan-STARRS, this would be a
     4263request from OTIS, the observatory controlling system. The second task
     4264initiates the individual image copies, with separate CCDs being copied
     4265to separate computers. This script uses the concept of having specific
     4266machines assigned to specific CCDs (as Pan-STARRS intends to
     4267operate). The association is determined by calling the external
     4268function chip.host, providing the identifier of the chip in
     4269question. This returns an appropriate host. The copy.image function
     4270copies the file and also sends a message to the summit system to
     4271inform it that the image has been successfully copied.
     4272
     4273\begin{verbatim}
     4274verbose on
     4275 queueinit newImages
     4276 exec echo 0 > new.last
     4277 exec cp -f raw.list new.list
     4278 
     4279 controller host add po01
     4280 controller host add po02
     4281 controller host add po03
     4282 controller host add po04
     4283 
     4284 # identify the images ready for copy
     4285 # new entries are added to queue newImages
     4286 # need to compare the new list with the ones already being processed
     4287 task          new.images
     4288   command      new.images
     4289   host         local
     4290 
     4291   periods      -poll 1
     4292   periods      -exec 5
     4293   periods      -timeout 5
     4294 
     4295   # success
     4296   task.exit    0
     4297     local i j Nstdout Nimages
     4298     # compare output with new.image queue
     4299     # keep only new entries
     4300     queuesize stdout -var Nstdout
     4301     for i 0 $Nstdout
     4302       queuepop stdout -var line
     4303       queuepush newImages -uniq -key 0 "$line"
     4304     end
     4305   end
     4306 
     4307   # locked list
     4308   task.exit    1
     4309     echo       "new.images: exec failure"
     4310     $new.image.failure ++
     4311   end
     4312 
     4313   # default exit status
     4314   task.exit    default
     4315     echo       "new.images: unknown exit status: $EXIT"
     4316     $new.image.failure ++
     4317   end
     4318 
     4319   # operation times out?
     4320   task.exit    timeout
     4321     echo       "new.images: timeout"
     4322     $new.image.failure ++
     4323   end
     4324 end
     4325 
     4326 # copy new images, sending job to desired host
     4327 task          copy.images
     4328   periods      -poll 0.2
     4329   periods      -exec 1
     4330   periods      -timeout 5
     4331 
     4332   task.exec
     4333     queuesize  newImages -var N
     4334     if ($N == 0) break
     4335     # if ($network == 0) break
     4336     # if ($filesystem == 1) break
     4337     
     4338     queuepop newImages -var line
     4339     list tmp -split $line
     4340     $filename   = $tmp:0
     4341     $chip       = $tmp:1
     4342     $state      = $tmp:2
     4343     if ($state == new)
     4344       # copy this image
     4345       queuepush newImages -replace -key 0 "$filename $chip run"
     4346     else
     4347       # ignore this image
     4348       queuepush newImages -replace -key 0 "$filename $chip $state"
     4349       break
     4350     end
     4351     # echo $chip
     4352     $host = `chip.host $chip`
     4353     # echo $host
     4354     host $host
     4355     # echo "starting copy for $filename on $host..."
     4356     command copy.image $filename $chip
     4357   end
     4358 
     4359   # can I have access to argc,argv?
     4360 
     4361   # success
     4362   task.exit    0
     4363     echo "done copy..."
     4364     queuepop stdout -var line
     4365     list tmp -split $line
     4366     $filename   = $tmp:0
     4367     $chip       = $tmp:1
     4368     exec mark.image $filename
     4369     queuepush newImages -replace -key 0 "$filename $chip copy"
     4370   end
     4371 
     4372   # default exit status
     4373   task.exit    default
     4374     echo       "new.images: unknown exit status: $EXIT"
     4375     $new.image.failure ++
     4376   end
     4377 
     4378   # operation times out?
     4379   task.exit    timeout
     4380     echo       "new.images: timeout"
     4381     $new.image.failure ++
     4382   end
     4383 end
     4384 
     4385\end{verbatim}
     4386
    39704387\input{glossary.tex}
    39714388
     
    39764393* output data products
    39774394* DVO
    3978 * PanTasks
    39794395* ipptools / ippMonitor?
    39804396* analysis stages, versions and iterations
  • trunk/doc/dvo/dvo.tex

    r6035 r6055  
    1919\pagenumbering{arabic}
    2020
    21 \subsection{Photometric systems and the DVO Photcodes}
     21\section{Overview}
     22
     23DVO, the Desktop Virtual Observatory, is a software system which
     24stores data related to astronomical objects derived from various
     25sources, and provides mechanisms to related multiple detections
     26together as astronomical objects.  DVO deals with two related
     27concepts: {\em objects} and {\em detections}.  The {\em objects} are
     28descriptions of astronomical objects while the {\em detections} are
     29the specific measurements of those objects, typically measured from
     30astronomical images.  A collection of {\em detections} may be used to
     31derive average quantities which describe a particular {\em object}.  A
     32third class of measurement to be considered are those supplied by
     33external references.  Such measurements may be treated as {\em
     34detections}, with the caveat that access to the raw measurements and
     35metadata are usually unavailable: the reported measurements and errors
     36must be accepted as they are reported.
     37
     38DVO stores the collections of detections which were derived from
     39specific images.  It provides a mechanism to determine the image from
     40which a specific detection was derived, and in conjunction with the
     41Image Server locate the corresponding data file.  DVO also makes it
     42possible to extract all detections derived from a specific image and
     43to determine quantities such as the pixel coordinates of the detection
     44on the image.
     45
     46DVO also has the capability to associate multiple detections of a
     47specific object.  Several major classes of objects will be present,
     48each of which must be handled correctly.  DVO distinguished the
     49following types of objects.
     50
     51{\bf Stars, compact galaxies, and QSOs} will have nearly fixed
     52locations relative to other distant stars, with only small deviations
     53for individual measurements.  The association between multiple
     54detections of such objects is made on the basis of their coincident
     55positions.  DVO determines the average position of the object and the
     56deviations of the individual detections from that average on the basis
     57of the ensemble of individual detection.
     58
     59{\bf Solar System Objects} do not have a fixed location.  Detections
     60of such objects are linked by their orbits, and depend on both the
     61position and the time of the image.  DVO does not attempt to make this
     62link; this is the role of the MOPS system.  However, it has the
     63ability to accept identifications made externally with specified
     64detections and to return the identifier of the moving object
     65associated with the specific detections.  These associations also
     66include descriptive information such as the offset of the detection
     67from the predicted location of the detection based on the orbit.  This
     68functionality is required to allow DVO to ignore known moving object
     69detections from other types of queries.
     70
     71{\bf High-proper-motion objects} in the general vicinity of the solar
     72system fall in between these first two classes of objects.  Their
     73proper motion and parallax response is significant enough ($>0.2$
     74arcsec in 1 year) that they are not well-described by an average
     75location and a collection of offsets.  These objects are better
     76described by a distance and a proper motion vector.  DVO provides the
     77association between the specific detections and an average object
     78which includes finite parallax and proper motion.
     79
     80{\bf Orphaned detections} are not associated with a specific
     81astronomical object of any of the above classes.  Most of these will
     82be spurious (not representing real objects), some will be from solar
     83system objects for which orbits are not yet determined, some will be
     84from faint stars near the detection limits, and some will be from
     85short-term transients which have only been detected once.  DVO
     86maintains these detections until they have been associated with one of
     87the objects above.  DVO provides mechanisms by which individual
     88detections may be migrated back and forth between the orphan state and
     89association with an astronomical object.
     90
     91DVO stores the information about the detection, the related objects,
     92and the images which provided the measurements.  For every detection,
     93DVO provides the mechanisms to link the detection back to the image
     94which supplied it.  DVO also provides the capability to determine the
     95images containing a specific location but for which no detection was
     96made.  The minimum set of information which must be carried for these
     97non-detections is the image and the associated object or orphan.
     98
     99DVO also stores the relationships between various
     100photometric systems and the evolution of that relationship.  It
     101provides mechanisms to convert between the measured instrumental
     102magnitude of a detection with a specific filter, detector, and
     103telescope, and at a particular time and the implied magnitude in the
     104average Pan-STARRS photometry system, given a determined set of
     105calibrations.  It also provides the capability to convert magnitudes
     106in one system to the magnitudes in another system; an example of such
     107a conversion is between the average Pan-STARRS filter systems and the
     108various reference systems appropriate for those filters.
     109
     110\section{Photometric systems and the DVO Photcodes}
    22111
    23112One of the major roles of DVO is to relate different photometric
     
    26115number of different detectors.  We may have observations from
    27116different telescopes in similar filters.  We may have reference data
    28 related to some filter, but obtained and published by other
    29 observers.  We would like to related these measurements together in
    30 optimal ways, making use of whatever information we have available.
    31 DVO provides several mechanisms to enable these relationships.
     117related to some filter, but obtained and published by other observers.
     118We would like to related these measurements together in optimal ways,
     119making use of whatever information we have available.  DVO provides
     120several mechanisms to enable these relationships.
    32121
    33122We identify three distinct types of photometry measurements within
     
    208297parameters.
    209298
    210 \section{Overview}
    211 
    212 DVO, the Desktop Virtual Observatory, is a software system which
    213 stores data related to astronomical objects derived from various
    214 sources, and provides mechanisms to related multiple detections
    215 together as astronomical objects.  DVO deals with two related
    216 concepts: {\em objects} and {\em detections}.  The {\em objects} are
    217 descriptions of astronomical objects while the {\em detections} are
    218 the specific measurements of those objects, typically measured from
    219 astronomical images.  A collection of {\em detections} may be used to
    220 derive average quantities which describe a particular {\em object}.  A
    221 third class of measurement to be considered are those supplied by
    222 external references.  Such measurements may be treated as {\em
    223 detections}, with the caveat that access to the raw measurements and
    224 metadata are usually unavailable: the reported measurements and errors
    225 must be accepted as they are reported.
    226 
    227 DVO stores the collections of detections which were derived from
    228 specific images.  It provides a mechanism to determine the image from
    229 which a specific detection was derived, and in conjunction with the
    230 Image Server locate the corresponding data file.  DVO also makes it
    231 possible to extract all detections derived from a specific image and
    232 to determine quantities such as the pixel coordinates of the detection
    233 on the image.
    234 
    235 DVO also has the capability to associate multiple detections of a
    236 specific object.  Several major classes of objects will be present,
    237 each of which must be handled correctly.  DVO distinguished the
    238 following types of objects.
    239 
    240 {\bf Stars, compact galaxies, and QSOs} will have nearly fixed
    241 locations relative to other distant stars, with only small deviations
    242 for individual measurements.  The association between multiple
    243 detections of such objects is made on the basis of their coincident
    244 positions.  DVO determines the average position of the object and the
    245 deviations of the individual detections from that average on the basis
    246 of the ensemble of individual detection.
    247 
    248 {\bf Solar System Objects} do not have a fixed location.  Detections
    249 of such objects are linked by their orbits, and depend on both the
    250 position and the time of the image.  DVO does not attempt to make this
    251 link; this is the role of the MOPS system.  However, it has the
    252 ability to accept identifications made externally with specified
    253 detections and to return the identifier of the moving object
    254 associated with the specific detections.  These associations also
    255 include descriptive information such as the offset of the detection
    256 from the predicted location of the detection based on the orbit.  This
    257 functionality is required to allow DVO to ignore known moving object
    258 detections from other types of queries.
    259 
    260 {\bf High-proper-motion objects} in the general vicinity of the solar
    261 system fall in between these first two classes of objects.  Their
    262 proper motion and parallax response is significant enough ($>0.2$
    263 arcsec in 1 year) that they are not well-described by an average
    264 location and a collection of offsets.  These objects are better
    265 described by a distance and a proper motion vector.  DVO provides the
    266 association between the specific detections and an average object
    267 which includes finite parallax and proper motion.
    268 
    269 {\bf Orphaned detections} are not associated with a specific
    270 astronomical object of any of the above classes.  Most of these will
    271 be spurious (not representing real objects), some will be from solar
    272 system objects for which orbits are not yet determined, some will be
    273 from faint stars near the detection limits, and some will be from
    274 short-term transients which have only been detected once.  DVO
    275 maintains these detections until they have been associated with one of
    276 the objects above.  DVO provides mechanisms by which individual
    277 detections may be migrated back and forth between the orphan state and
    278 association with an astronomical object.
    279 
    280 DVO stores the information about the detection, the related objects,
    281 and the images which provided the measurements.  For every detection,
    282 DVO provides the mechanisms to link the detection back to the image
    283 which supplied it.  DVO also provides the capability to determine the
    284 images containing a specific location but for which no detection was
    285 made.  The minimum set of information which must be carried for these
    286 non-detections is the image and the associated object or orphan.
    287 
    288 DVO also stores the relationships between various
    289 photometric systems and the evolution of that relationship.  It
    290 provides mechanisms to convert between the measured instrumental
    291 magnitude of a detection with a specific filter, detector, and
    292 telescope, and at a particular time and the implied magnitude in the
    293 average Pan-STARRS photometry system, given a determined set of
    294 calibrations.  It also provides the capability to convert magnitudes
    295 in one system to the magnitudes in another system; an example of such
    296 a conversion is between the average Pan-STARRS filter systems and the
    297 various reference systems appropriate for those filters.
    298 
    299299\section{DVO Database Tables}
    300300
     
    499499data types and input/output methods without significant re-coding.
    500500
     501\tbd{DVO mysql table storage is not yet implemented}
     502
    501503\section{addstar : Insert Image \& Detection Set}
    502504
     
    505507\caption{\label{catalog} \small a figure }
    506508\end{figure}
    507 
    508 \tbd{fill out discussion of the addstar client/server implementation}
    509509
    510510One of the most basic operations needed by DVO is to insert a
     
    527527faint orphans.
    528528
    529 \subsection{addstar -refs : Insert Reference Objects}
    530 
    531 This operation is very similar to the previous one.  A collection of
    532 reference objects are added to the database as a collection of
    533 detections.  The reference photometry should in general be given its
    534 own photometry code.  The reference data is different from the image
    535 detection set because the associated image information is not
    536 included.  Thus, no corresponding images are added to the database.
    537 
    538 \section{relphot : Relative Photometry Analysis}
     529A wide range of options are available to addstar.  These can be used
     530to modify the object matching rules, to reduce the number of tables
     531which are updated, to specify the output data format, and so forth.  A
     532few options modify the behavoir in substantial ways, as discussed in
     533the two sections below.
     534
     535\tbd{flesh out discussion of the options}
     536
     537\subsection{Insert Reference Objects}
     538
     539\code{addstar -ref (filename)}
     540
     541This mode of addstar reads a text file and adds the listed objects to
     542the database as a reference photcode type.  A collection of reference
     543objects are added to the database as a collection of detections.  The
     544reference photometry should in general be given its own photometry
     545code.  The reference data is different from the image detection set
     546because the associated image information is not included.  Thus, no
     547corresponding images are added to the database.
     548
     549\subsection{Insert Catalog Objects}
     550
     551\code{addstar -cat (name) -region ra ra dec dec}
     552
     553In this mode, any of several all-sky or large-scale reference catalogs
     554are used for the input sources.  The catalog objects are added to the
     555database as reference objects.  The valid catalogs consist of 2MASS,
     556USNO, GSC.  Tycho and USNO-B will be added shortly.  Specific
     557photcode names are defined for each of these catalogs, and must be
     558appropriately requested and defined in the photcode table.  The
     559optional region restriction limits the insert to a subset of the sky.
     560The user does not always want to add 50GB of 2MASS detections to any
     561DVO database...
     562
     563\subsection{Addstar Client/Server Interactions}
     564
     565DVO currently uses stand-alone programs which are run from the command
     566line (like addstar, or the programs listed below), or it works with
     567the interactive DVO shell, which allows the user to query portions of
     568the database.  These programs all interact with the database tables
     569directly, making use of file locking to prevent conflicts. 
     570
     571Unlike the other DVO programs (currently), it is possible to run
     572addstar as a client/server system.  In this configuration, the program
     573\code{addstard} is launched to run in the background as a server.  It
     574monitors a socket waiting for clients to contact it.  The client
     575program, \code{addstarc} appears to the user identical to the
     576stand-alone addstar.  However, rather than directly insert data into
     577the database, \code{addstarc} contacts the addstar server and sends it
     578the detections and associated image data (along with the information
     579about the user options).  The daemons accepts the incoming data and
     580then loads this data into the database, just as the stand-alone
     581addstar does.
     582
     583The purpose of the addstar client/server design is three-fold.  First,
     584the client can be used by processes to send data to the DVO database
     585and then immediately exit.  The addstar loading process is one of the
     586more time-critical functions within the IPP.  However, unlike the
     587other portions of the IPP, the addstar processes must operate in
     588serial, at least when they are updating the same portion of the sky
     589(or the image table).  If the IPP analysis routines all needed to run
     590the stand-alone addstar program, they would eventually block waiting
     591for each addstar to complete, preventing other processing from
     592continuing.  The addstar client / server model allows the processing
     593node to invoke the addstar client, sending the data to the addstar
     594server.  The addstar server will then be the entity that manages the
     595serialization of the incoming data stream.  The addstar server has two
     596threads which run in parallel.  One thread monitors the socket and
     597accepts new data sets from addstar clients, adding the data to an
     598internal queue.  The other thread pulls data off of the queue and
     599updates the database with the data. 
     600
     601A second advantage of the client/server interaction is that only the
     602new detections need to be sent across the network.  To update the
     603database, addstar must load the average objects for the region from
     604the database tables.  In the stand-alone mode, the addstar program
     605loads this data via NFS across the network from whatever device stores
     606the addstar tables.  In the client/server model, the addstar server
     607always runs locally on the machine which holds the database tables.
     608Thus, for the server, all database access is local disk access.
     609
     610The final advantage of the client/server model is that it enables the
     611parallel database model, which is not yet implemented as of Jan
     6122006. In this model, there are multiple addstar servers.  Each one has
     613a fraction of the sky in the local tables.  The identification of
     614which table is managed by this host/addstar server is stored in the
     615SkyRegion table.  The addstar server simply accepts incoming
     616detections from the addstar clients.  Any detections which it receives
     617which fall within the boundaries of tables that it manages are updated
     618as normal.  The server then identifies the other addstar servers which
     619are responsible for the other detections.  It then sends these
     620detections to those servers using the same socket communication used
     621by the addstar clients.  The addstar server must also be ready accept
     622detections from other addstar servers.  This relationship is
     623completely parallel, and any addstar client may send its data to any
     624addstar server, letting the servers hash out who owns what.  The only
     625difficulty with this model is in handling sources near the boundaries
     626of the tables.  Note that this issues exists whether those tables are
     627distributed across multiple machines or not.
     628
     629Addstar uses the following strategy to handle detections on the table
     630boundaries.  Detections are first added to each table completely
     631ignoring the neighboring tables.  A detection which is close to the
     632boundary may either be associated with an average object contained
     633within the table, or not.  If it is, the detection is associated with
     634that average object.  If not, a new average object is created at the
     635location of the detection.  So far, this process is identical to the
     636behavoir in the middle of the table.  One a longer time-scale, a
     637process is run which mediates the table boundaries. In this analysis,
     638the two neighboring tables are simultaneously examined.  The border
     639region, in a strip wider than the correlation radius, is examined in
     640detail.  If two objects within the border region fall within 2x the
     641correlation radius of each other, their individual detections are
     642re-examined.  These detections are re-added to a temporary table which
     643encompases the overlap.  the resulting objects will in general have
     644detections from either side of the boundary.  The average objects are
     645kept within the table as normal, but the detections are allowed to
     646migrate between the tables to stay with their object.  \tbd{this
     647boundary cleanup process is not implemented to date}.
     648
     649\section{Relphot : Relative Photometry Analysis}
    539650
    540651This operation uses the overlaps of images and multiple observations
    541652of the same objects to determine the relative photometry zero-points
    542 for a collection of images.  This is a task that wil be run much more
     653for a collection of images.  This is a task that is run much more
    543654infrequently than the object insertion tasks.
    544655
    545 \section{relphot}
    546 
    547 \begin{verbatim}
    548     * load data
    549           o images: match photcode and time range, reset flags
    550           o measure: select subset matching restritions on: photcode, time, dM, Minst, Mag, dophot == 1
    551     * iterate to find Mcal, image.flags:
    552     * write out modified Mcal values to image table
    553     * write out modified Mcal values to measure table
    554     * write out modified Mrel values to average table
    555 \end{verbatim}
    556 
    557 relphot has two primary purposes:
    558 
    559 \begin{verbatim}
    560     * calculate Mcal for images / measures
    561     * calculate Mrel for stars
    562 \end{verbatim}
    563 
    564 relphot can also be used to determine the mosaic grid used to generate photometrically corrected flats (-grid option).
    565 
    566 \subsection{data exclusion}
    567 
    568 relphot uses only a subset of the photometry data to calculate Mcal
    569 and Mrel. In the first stage, calculation of the Mcal values, relphot
    570 loads the photometry data from each relevant catalog and creates an
    571 internal subset catalog with the function bcatalog, excluding some of
    572 the irrelevant data. In addition, it uses flags to mark some of the
    573 data as invalid for the processing. bcatalog exclusions
    574 
    575 \begin{verbatim}
    576     * measure.photcode not equivalent to requested photcode
    577     * measure.dophot != 1
    578     * measure.Mcat > MAG_LIM
    579     * measure.dM > SIGMA_LIM
    580     * measure.Minst out of range (ImagMin - ImagMax) [optional]
    581     * measure.t out of range (TSTART, TSTOP)
    582 \end{verbatim}
    583 
    584 flagged data
    585 flagged image data
    586 
    587 images can be flagged by setting bits of image.code stars can be
    588 flagged by setting bits of average.code measures can be flagged by
    589 setting bits of measure.flag
    590 
    591 \begin{verbatim}
    592 image.code
    593 ID_IMAGE_NOCAL : ignore, irrelevant
    594 ID_IMAGE_POOR : image measured bad
    595 ID_IMAGE_SKIP : externally known bad dMcal > VALUE
    596 FLAG_IMAGE_SCATTER clean_images fabs(Mcal) > VALUE
    597 FLAG_IMAGE_ZEROPT clean_images dMcal > VALUE
    598 FLAG_IMAGE_SCATTER clean_mosaics fabs(Mcal) > VALUE
    599 FLAG_IMAGE_ZEROPT clean_mosaics mark_images does not seem to do
    600 anything useful?
    601 average.code Ngood < MEAS_TOOFEW setMrel Ngood <
    602 MEAS_TOOFEW clean_measures ChiSq > STAR_CHISQ clean_stars dM >
    603 STAR_SCATTER clean_stars average.code (STAR_BAD) is not saved by
    604 relphot: it is set by clean_stars, clean_measures, and setMrel, but
    605 not setMrelOutput. STAR_BAD should only be internal since it depends
    606 on the photcode, but is not associated with a specific photcode in the
    607 data. Just in case, it is reset to 0 in setMrelFinal. measure.flag X,Y
    608 out of range setExclusions 3 sigma clipping clean_measures
    609 \end{verbatim}
    610 
    611 setting Mrel final value
    612 
    613 setMrelFinal is used to set the final average.Mrel values. We do this
    614 in 4 stages. In each stage, we set the Mrel values for stars which
    615 have not already been set, based on the current exclusion settings. At
    616 successive stages, we relax the exclusions, allowing the more spurious
    617 objects to have a valid Mrel value to be set. In this loop, we
    618 actually run setMrelOutput twice: once to get the approximate Mrel
    619 value, then we flag the outlier measurements with
    620 \code{clean_measure}, then we redetermine the Mrel values on this
    621 basis, and mark the stars for exclusion from the next iteration.
    622 
    623 \begin{verbatim}
    624  exclude on
    625   photcode       0 1 2 3
    626   time range     0 1 2 3
    627   MEAS_POOR      0 1 2 3
    628   MEAS_TOOFEW    0 1 2 3
    629   dophot == 10   0 1 2
    630   inst mag       0 1 2
    631   dophot != 1,2  0 1 
    632   ID_IMAGE_POOR  0 1
    633   ID_IMAGE_SKIP  0 1
    634   dophot != 1    0
    635   measure.dM     0
    636 \end{verbatim}
    637  
    638 for all relphot runs, Mrel is re-calculated, and measures are marked at least if they are outliers in mag or ccd area. setMrel.output needs to do a few things differently from setMrel:
    639 
    640 \begin{verbatim}
    641     * set measure.Mcal (skipped in setMrel.basic)
    642     * set average.Mrel if N < TOO_FEW (not STAR_BAD) (optional!)
    643     * use MAX (stats.error, stats.sigma) (optionally)
    644     * allow STAR_BAD?
    645 \end{verbatim}
    646 
    647 \section{uniphot : Zero Point Analysis}
     656The relphot analysis is currently performed with a single Sky region
     657as the starting point.  All images (or all chips from all mosaic
     658iamges) which overlap the sky region are identified in the image
     659table.  This set of images are considered set A.  Next, all skyregions
     660which are overlapped by all of these images are selected.  Finally,
     661all additional images which overlapped the new regions only are
     662selected.  These are considered as image set B.  The image selections
     663are also restricted to images of a single, user-selected photcode. 
     664
     665All of the objects and detections which are contributed by the images
     666in sample A are extracted from the average and measure tables.  Only a
     667subset of the detections for which the S/N is greater than a
     668user-selected limit are kept.  Other restrictions, such as time range
     669or instrumental magnitude ranges may also be specified.  The
     670collection of average objects, their detections, and the images from
     671which they were derived now define a system of photometry equations.
     672In this system, every image has a calibration offset magnitude
     673($M_{cal}$), every object has an average magnitude in a relative
     674system ($M_{rel}$), and every detection of that object has a magnitude
     675defined by the equation $M = M_{rel} + M_{cal}$.  The goal is to solve
     676for the values of $M_{ref}$ and $M_{cal}$. 
     677
     678There are two points to note about this operation.  First, the system
     679of equations is generally much too large to solve directly; we must
     680use an iterative technique to converge on a solution. Second, it is
     681important in the analysis to use robust averaging and identify
     682detections, stars, or images which are deviant in some way.  These
     683should be marked and given set weight in the solution.  These cases
     684may represent poorly measured objects (perhaps detections on or near a
     685bad column), variable stars, and images obtained in poor weather
     686conditions.
     687
     688Relphot can also be used to determine the mosaic grid used to generate
     689photometrically corrected flats (-grid option).
     690
     691\section{Uniphot : Zero Point Analysis}
    648692
    649693This operation uses the time history of relative photometry zero
     
    14821526\end{itemize}
    14831527
     1528
     1529
     1530\subsection{Relphot data exclusion}
     1531
     1532relphot uses only a subset of the photometry data to calculate Mcal
     1533and Mrel. In the first stage, calculation of the Mcal values, relphot
     1534loads the photometry data from each relevant catalog and creates an
     1535internal subset catalog with the function bcatalog, excluding some of
     1536the irrelevant data. In addition, it uses flags to mark some of the
     1537data as invalid for the processing. bcatalog exclusions
     1538
     1539\begin{verbatim}
     1540    * measure.photcode not equivalent to requested photcode
     1541    * measure.dophot != 1
     1542    * measure.Mcat > MAG_LIM
     1543    * measure.dM > SIGMA_LIM
     1544    * measure.Minst out of range (ImagMin - ImagMax) [optional]
     1545    * measure.t out of range (TSTART, TSTOP)
     1546\end{verbatim}
     1547
     1548flagged data
     1549flagged image data
     1550
     1551images can be flagged by setting bits of image.code stars can be
     1552flagged by setting bits of average.code measures can be flagged by
     1553setting bits of measure.flag
     1554
     1555\begin{verbatim}
     1556image.code
     1557ID_IMAGE_NOCAL : ignore, irrelevant
     1558ID_IMAGE_POOR : image measured bad
     1559ID_IMAGE_SKIP : externally known bad dMcal > VALUE
     1560FLAG_IMAGE_SCATTER clean_images fabs(Mcal) > VALUE
     1561FLAG_IMAGE_ZEROPT clean_images dMcal > VALUE
     1562FLAG_IMAGE_SCATTER clean_mosaics fabs(Mcal) > VALUE
     1563FLAG_IMAGE_ZEROPT clean_mosaics mark_images does not seem to do
     1564anything useful?
     1565average.code Ngood < MEAS_TOOFEW setMrel Ngood <
     1566MEAS_TOOFEW clean_measures ChiSq > STAR_CHISQ clean_stars dM >
     1567STAR_SCATTER clean_stars average.code (STAR_BAD) is not saved by
     1568relphot: it is set by clean_stars, clean_measures, and setMrel, but
     1569not setMrelOutput. STAR_BAD should only be internal since it depends
     1570on the photcode, but is not associated with a specific photcode in the
     1571data. Just in case, it is reset to 0 in setMrelFinal. measure.flag X,Y
     1572out of range setExclusions 3 sigma clipping clean_measures
     1573\end{verbatim}
     1574
     1575setting Mrel final value
     1576
     1577setMrelFinal is used to set the final average.Mrel values. We do this
     1578in 4 stages. In each stage, we set the Mrel values for stars which
     1579have not already been set, based on the current exclusion settings. At
     1580successive stages, we relax the exclusions, allowing the more spurious
     1581objects to have a valid Mrel value to be set. In this loop, we
     1582actually run setMrelOutput twice: once to get the approximate Mrel
     1583value, then we flag the outlier measurements with
     1584\code{clean_measure}, then we redetermine the Mrel values on this
     1585basis, and mark the stars for exclusion from the next iteration.
     1586
     1587\begin{verbatim}
     1588 exclude on
     1589  photcode       0 1 2 3
     1590  time range     0 1 2 3
     1591  MEAS_POOR      0 1 2 3
     1592  MEAS_TOOFEW    0 1 2 3
     1593  dophot == 10   0 1 2
     1594  inst mag       0 1 2
     1595  dophot != 1,2  0 1 
     1596  ID_IMAGE_POOR  0 1
     1597  ID_IMAGE_SKIP  0 1
     1598  dophot != 1    0
     1599  measure.dM     0
     1600\end{verbatim}
     1601 
     1602for all relphot runs, Mrel is re-calculated, and measures are marked at least if they are outliers in mag or ccd area. setMrel.output needs to do a few things differently from setMrel:
     1603
     1604\begin{verbatim}
     1605    * set measure.Mcal (skipped in setMrel.basic)
     1606    * set average.Mrel if N < TOO_FEW (not STAR_BAD) (optional!)
     1607    * use MAX (stats.error, stats.sigma) (optionally)
     1608    * allow STAR_BAD?
     1609\end{verbatim}
     1610
  • trunk/doc/pantasks/pantasks.tex

    r6033 r6055  
    2424tool which manages the sequencing of data analysis steps and, with the
    2525related tool `PControl', distributes the data processing across a
    26 cluster of computers.
     26cluster of computers. \tbd{uses the 'opihi' shell-scripting system}
    2727
    2828The purpose of PanTasks is to manage the automatic construction and
     
    3030uses a set of rules to define UNIX commands, and their corresponding
    3131command-line arguments, to be performed on some regular, repeated
    32 basis.  The utility of PanTasks is that it can easily define an
    33 analysis system which is completely state-based, as opposed to an
    34 event-driven system. 
    35 
    36 The two basic units of PanTasks operation are the 'task' and the
    37 'job'.  A 'job' is simply a command the user would execute on a
    38 command line; it consists of a command along with optional command
    39 line arguments.  A 'task' is a generic description of a type of job in
    40 which the details of any specific piece of data are omitted.  The task
    41 defines the UNIX command which corresponds to the job, and it provides
    42 rules for determining the identity of data for the job.  The task also
    43 defines tests which are used to decide if the job may be executed.
    44 Finally, it defines a polling frequency in which PanTasks should
    45 attempt to construct a new job for the task.
    46 
    47 For example, we may want to regularly copy files from one location to
    48 another.  Perhaps the name of the next available file is available in
    49 a database table, and can be retrieved with the command 'nextFile'.
    50 Perhaps we wish to check for new files every 60 seconds.  Thus, the
    51 task is to copy files, while a specific job of this task might be of
    52 the form \code{cp newfile newpath}.  With PanTasks, we would define a
    53 copy task somewhat like the following:
    54 
    55 \begin{verbatim}
    56   task copyfile
    57     periods -exec 60.0
    58 
    59     task.exec
    60       $file = `nextFile`
    61       if ($file == "none")
    62         break
    63       end
    64       command cp $file $newpath
    65     end
    66 
    67     task.exit 0
    68       queuepush copied $file
    69     end
    70 
    71     task.exit 1
    72       queuepush failure $file
    73     end
    74   end
    75 \end{verbatim}
    76 
    77 In this simple example, the task is attempted every 60 seconds.  If
    78 there is no new file (output of 'nextFile' is 'none'), then no job
    79 results from this task.  If there is a new file, the copy command is
    80 performed.  This example is deceptively simple because one could
    81 easily imagine writing a stand-along program which performs the same
    82 thing.  The important advantages of using PanTasks for this type of
    83 operation are:
    84 \begin{itemize}
    85 \item the output from one job can be used to spawn a number of other tasks.
    86 \item the success or failure state of each job can be used to spawn
    87   other tasks.
    88 \item the details of the job and data test are kept separated from the
    89   rules which connect tasks together. 
    90 \item the relationships between tasks are kept together in a single
    91   location.
    92 \end{itemize}
    93 
    94 In addition to these organizational advantages, PanTasks also provides
    95 a direct connection to the tool for monitoring parallel jobs,
    96 pcontrol.  Thus the jobs spawned by PanTasks can be defined to run in
    97 the background locally or on any of the computers in the parallel
    98 processing cluster.
    99 
    100 
    101 \section{PanTasks : the Scheduler}
    102 
    103 The purpose of PanTasks is to manage the automatic construction and
    104 execution of inter-related (often repetative) operations. PanTasks uses
    105 a set of rules to define UNIX commands, and their corresponding
    106 command-line arguments, to be performed on some regular, repeated
    107 basis. The utility of PanTasks is that it can easily define an analysis
    108 system which is completely state-based, as opposed to an event-driven
    109 system.
     32basis.  The utility of PanTasks is that it can easily define and
     33manage an analysis system which is completely state-based, as opposed
     34to an event-driven system.
    11035
    11136Consider, for example, a telescope which obtains a collection of
     
    14974\subsection{Tasks vs Jobs}
    15075
    151 The primary function of PanTasks is to repeatedly perform tasks, and
    152 execute jobs on the basis of those tasks. A task consists of a set of
    153 rules which describe system state tests to perform on a regular time
    154 scale. Based on the results of those state tests, the task will then
    155 choose whether or not to construct a job. The task also defines
    156 actions to perform upon the completion of a job, based upon the output
    157 and exit status of the job. A task thus defines the repeat period. It
    158 may optionally define valid or invalid time ranges (eg, Mon-Fri or
    159 10:00-17:00, etc). The task may also specify that the job be run
    160 locally (ie, in the background on the same computer as PanTasks) or
    161 remotely by the parallel process controller (pcontrol). A job may even
    162 be restricted to a specific computer managed by pcontrol. An example
    163 of a simple tasks is given below.
    164 
    165 \begin{verbatim}
    166    task datalist
    167      command ls /data/foo
    168      periods -exec 5.0
    169      periods -timeout 50.0
    170      periods -poll 1.0
    171  
    172      task.exit 0
    173        queueprint stdout
    174        queuedelete stdout
    175      end
    176  
    177      task.exit 1
    178        queuepush failure "task failed"
    179      end
    180    end
    181  \end{verbatim}
    182 
    183 
    184 This task does not perform any system state tests; it is simply
    185 constructs a new job every 5.0 seconds. The job in this case is always
    186 the same: ls /data/foo . When the job finished, if the job exit status
    187 is 0 (normal UNIX success status), the resulting output is printed to
    188 the screen. If the job returns an exit status of 1 (a failure), the
    189 failure queue receives a single entry. Although they are not defined
    190 in this case, it is also possible to specify the action to be taken if
    191 the job crashes (does not exit normally) or if it times out (runs
    192 beyond the specified timeout period). A slightly more complex task
    193 which performs a state test and constructs a command based on that
    194 test is shown below
    195 
    196 \begin{verbatim}
    197    task datalist
    198      periods -exec 5.0
    199      periods -timeout 50.0
    200      periods -poll 1.0
    201  
    202      task.exec
    203        $file = `next.file`
    204        if ($file == "none")
    205          break
    206        end
    207        command cp /data/foo/$file /data/bar
    208      end
    209  
    210      task.exit 0
    211        queueprint stdout
    212        queuedelete stdout
    213        queuepush copied $file
    214      end
    215  
    216      task.exit 1
    217        queuepush failure $file
    218      end
    219    end
    220 \end{verbatim}
    221 
    222  The task.exec macro is executed by PanTasks every 5.0 seconds. This
    223  macro executes a (hypothetical user-defined) UNIX command (next.file)
    224  which examines the system state, return either a filename or the word
    225  "none". If the result of this test is "none", the task does nothing:
    226  no job is constructed. Otherwise, a job is constructed using the name
    227  of the file returned by the state test. Successful jobs have the
    228  filename added to the 'copied' queue, while failed jobs add the
    229  filename to the 'failure' queue.
     76The two basic units of PanTasks operation are the 'task' and the
     77'job'.  A 'job' is simply a command the user would execute on a
     78command line; it consists of a command along with optional command
     79line arguments.  A 'task' is a generic description of a type of job in
     80which the details of any specific piece of data are omitted.  The task
     81defines the UNIX command which corresponds to the job, and it provides
     82rules for determining the identity of data for the job.  The task also
     83defines tests which are used to decide if the job may be executed.
     84Finally, it defines a polling frequency in which PanTasks should
     85attempt to construct a new job for the task.
     86
     87For example, we may want to regularly copy files from one location to
     88another.  Perhaps the name of the next available file is available in
     89a database table, and can be retrieved with the command 'nextFile'.
     90Perhaps we wish to check for new files every 60 seconds.  Thus, the
     91task is to copy files, while a specific job of this task might be of
     92the form \code{cp newfile newpath}.  With PanTasks, we would define a
     93copy task somewhat like the following:
     94
     95\begin{verbatim}
     96  task copyfile
     97    periods -exec 60.0
     98
     99    task.exec
     100      $file = `nextFile`
     101      if ($file == "none")
     102        break
     103      end
     104      command cp $file $newpath
     105    end
     106
     107    task.exit 0
     108      queuepush copied $file
     109    end
     110
     111    task.exit 1
     112      queuepush failure $file
     113    end
     114  end
     115\end{verbatim}
     116
     117In this simple example, the task is attempted every 60 seconds.  If
     118there is no new file (output of 'nextFile' is 'none'), then no job
     119results from this task.  If there is a new file, the copy command is
     120performed.  This example is deceptively simple because one could
     121easily imagine writing a stand-along program which performs the same
     122thing.  The important advantages of using PanTasks for this type of
     123operation are:
     124\begin{itemize}
     125\item the output from one job can be used to spawn a number of other tasks.
     126\item the success or failure state of each job can be used to spawn
     127  other tasks.
     128\item the details of the job and data test are kept separated from the
     129  rules which connect tasks together. 
     130\item the relationships between tasks are kept together in a single
     131  location.
     132\end{itemize}
     133
     134In addition to these organizational advantages, PanTasks also provides
     135a direct connection to the tool for monitoring parallel jobs,
     136pcontrol.  Thus the jobs spawned by PanTasks can be defined to run in
     137the background locally or on any of the computers in the parallel
     138processing cluster.
    230139
    231140\subsection{Parallel vs Local Job Processing}
    232141
    233142Jobs which are generated by PanTasks tasks may either be run locally
    234 (forked in the background on the same machine as PanTasks) or run on the
    235 IPP parallel process controller, pcontrol. The default is for the job
    236 to be run locally. If a job should be run on the parallel controller,
    237 this can be specified by including the command host (hostname) in the
    238 definition of a task. If the value of (hostname) is 'anyhost', then
    239 pcontrol may select any of its host computers to run the job according
    240 to its own rules. If the value of (hostname) is one of the computers
    241 managed by pcontrol, then that machine will be selected for the job,
    242 if it is available. This amounts to a preference to use that machine,
    243 but pcontrol is allowed to substitute a different machine if it
    244 chooses. If the host command is given the option -required, then
    245 pcontrol is forced to use the named host, even if the machine is down,
    246 unknown, or otherwise unavailable. If the machine is not available,
    247 pcontrol will simply hold onto the job until the machine is available
    248 or the job is deleted. Note that PanTasks may delete jobs from pcontrol
    249 if they remain pending for too long (see period -timeout).
     143(forked in the background on the same machine as PanTasks) or run on
     144the IPP parallel process controller, pcontrol. The default is for the
     145job to be run locally. If a job should be run on the parallel
     146controller, this can be specified by including the command host
     147(hostname) in the definition of a task. If the value of (hostname) is
     148'anyhost', then pcontrol may select any of its host computers to run
     149the job according to its own rules. If the value of (hostname) is one
     150of the computers managed by pcontrol, then that machine will be
     151selected for the job, if it is available. This amounts to a preference
     152to use that machine, but pcontrol is allowed to substitute a different
     153machine if it chooses. If the host command is given the option
     154-required, then pcontrol is forced to use the named host, even if the
     155machine is down, unknown, or otherwise unavailable. If the machine is
     156not available, pcontrol will simply hold onto the job until the
     157machine is available or the job is deleted. Note that PanTasks may
     158delete jobs from pcontrol if they remain pending for too long.
    250159
    251160It is possible to interact directly with the parallel processor to
     
    287196identified to the controller. If such a host is required, the
    288197controller will simply keep the associated jobs in the pending state
    289 until such a machine exists. See the pcontrol documentation for
     198until such a machine exists. See the pcontrol section below for
    290199further discussion of the controller manipuation of jobs and hosts.
    291200
     
    373282\item external communications
    374283\item job exit status
    375 \item job stdout parsing
     284\item job stdout/stderr parsing
    376285\end{itemize}
    377286
     
    399308value of the stdout lines from the UNIX command, and the value
    400309\code{$var:n} is set to the number of output lines.
     310% $
    401311
    402312Fine-grained control over the job exit status is available with the
     
    411321status.
    412322
    413 Jobs may transmit their results back to PanTasks for further evaluation
    414 through the standard output and standard error streams. Whenever a job
    415 exits, the complete stdout and stderr streams from the job are pushed
    416 onto the PanTasks queues stdout and stderr. The job exit macros may then
    417 parse these queues, moving the results into other PanTasks / Opihi data
    418 containers (queues, variables, vectors, whatever is appropriate). Note
    419 that currently, the output data is simply pushed onto these output
    420 queues. It is currently the responsibility of the PanTasks programmer to
    421 use or dispose of the data in these queues. This may change in the
    422 future: the queues may be flushed for each job completion.
     323Jobs may transmit their results back to PanTasks for further
     324evaluation through the standard output and standard error
     325streams. Whenever a job exits, the complete stdout and stderr streams
     326from the job are pushed onto the PanTasks queues \code{stdout} and
     327\code{stderr}. The job exit macros may then parse these queues, moving
     328the results into other PanTasks / Opihi data containers (queues,
     329variables, vectors, whatever is appropriate). Note that currently, the
     330output data is simply pushed onto these output queues. It is currently
     331the responsibility of the PanTasks programmer to use or dispose of the
     332data in these queues. This may change in the future: the queues may be
     333flushed for each job completion.
     334
     335\subsection{PanTasks Monitoring Loop}
     336
     337\begin{figure}
     338\begin{center}
     339\includegraphics[scale=0.85,angle=-90]{pics/pantasks.01.ps}
     340\caption{\label{MonitorLoop} PanTasks Monitor Loop}
     341\end{center}
     342\end{figure}
     343
     344Figure~\ref{MonitorLoop} illustrates the operation of PanTasks.
     345Currently, PanTasks is run as a stand-alone foreground process, not a
     346server.  In this current operating mode, PanTasks accepts commands
     347from the user (left side) via a GNU readline interface.  Readline
     348provides a mechanism to schedule an background process which is
     349executed on a regular basis, or in the interval after each keystroke.
     350This background processing is represented as the loop on the right.
     351In this loop, PanTasks checks on the status of pcontrol and on any
     352locally spawned background jobs.  It also checks the list of tasks for
     353tasks which are ready to be executed.  The tasks and the background
     354jobs are kept in rotating queues.  Every time the loop is processed,
     355PanTasks runs through a number of the background jobs and tasks,
     356attempting to evaluate as many as possible, but stopping after a
     357limited number of milliseconds.  This test stage cycles through the
     358tasks and/or jobs in their queue, but stops if it examines all of the
     359entries in the queue.  If this testing process runs out of time before
     360the entire queue is searched, it leaves the sequence intact for the
     361next pass.  The timeout is set to keep the keyboard small enough to
     362keep the human interaction from being troublesome.
     363
     364\begin{figure}
     365\begin{center}
     366\includegraphics[scale=0.85,angle=-90]{pics/pantasks.02.ps}
     367\caption{\label{TaskLoop} PanTasks Task Check Loop}
     368\end{center}
     369\end{figure}
     370
     371Figure~\ref{TaskLoop} shows the interactions performed for each check
     372of the list of tasks.  The task timers are examined to see if the
     373specific task is ready to be executed.  If so, then the task exec
     374macro is executed.  If this macro exit status is false, the loop goes
     375to the next task.  If the task exec macro is true, the job command is
     376constructed and the job is submitted to the correct location, either
     377the controller (pcontrol) or to the queue of local, background jobs.
     378
     379\begin{figure}
     380\begin{center}
     381\includegraphics[scale=0.85,angle=-90]{pics/pantasks.03.ps}
     382\caption{\label{JobLoop} PanTasks Job Check Loop}
     383\end{center}
     384\end{figure}
     385
     386Figure~\ref{JobLoop} shows the interactions performed for each check
     387of a single background job.  The job timer is checked to see if the
     388job has timed out.  Next, the job run status is examined to see if the
     389job has finished or not.  If the job has finished, the appropriate
     390exit macro is executed and the job results are returned to the rest of
     391the PanTasks data structures (ie, stderr and stdout queues are filled
     392out).  Users should not define exit macros which perform long running
     393jobs, or PanTasks will become quite sluggish to keyboard strokes.
     394
     395PanTasks also checks the current status of pcontrol on each loop.
     396In this test, PanTasks requests from pcontrol a list of the jobs which
     397have finished.  It then attempts to harvest the finished jobs one by
     398one and place the results in the approrpiate locations.  This loop is
     399also limited to a fixed amount of time; any pcontrol jobs which remain
     400unharvested are left for the next pass by PanTasks.
    423401
    424402\subsection{Running the scheduler}
     
    458436\end{verbatim}
    459437
    460 \begin{figure}
    461 \begin{center}
    462 \includegraphics[scale=0.85]{pics/pantasks.01.ps}
    463 \caption{\label{queues} PanTasks queues and MDDB tables}
    464 \end{center}
    465 \end{figure}
    466 
    467 \begin{figure}
    468 \begin{center}
    469 \includegraphics[scale=0.85]{pics/pantasks.02.ps}
    470 \caption{\label{queues} PanTasks queues and MDDB tables}
    471 \end{center}
    472 \end{figure}
    473 
    474 \begin{figure}
    475 \begin{center}
    476 \includegraphics[scale=0.85]{pics/pantasks.03.ps}
    477 \caption{\label{queues} PanTasks queues and MDDB tables}
    478 \end{center}
    479 \end{figure}
    480 
    481438\newpage
    482439\section{pcontrol : the PanTasks parallel controller}
     
    494451\subsection{Host States}
    495452
     453\begin{figure}
     454\begin{center}
     455\includegraphics[scale=0.85,angle=-90]{pics/pantasks.04.ps}
     456\caption{\label{HostStates} PanTasks Host States}
     457\end{center}
     458\end{figure}
     459
    496460pcontrol maintains a table of available processing computers (hosts)
    497461and tracks their status. Hosts managed by pcontrol are allowed to be
    498 in one of several states: off, down, idle, busy, and done. These
    499 states have the following meanings:
    500 
    501 If the host is off, it is known to pcontrol, but pcontrol does not
    502 have an active connection to the machine. Hosts which are off are not
    503 available for jobs, and pcontrol does not attempt to initiate a
    504 connection to them.
     462in one of several states: \code{off}, \code{down}, \code{idle},
     463\code{busy}, and \code{done} (see Figure~\ref{HostStates}). There are
     464also two virtual states: \code{new} and \code{delete}.  These states
     465have the following meanings:
     466
     467If the host is \code{off}, it is known to pcontrol, but pcontrol does
     468not have an active connection to the machine. Hosts which are
     469\code{off} are not available for jobs, and pcontrol does not attempt to
     470initiate a connection to them.  A pcontrol user may force a host to
     471transition to the \code{off} state with the command host
     472\code{off~(hostname)}. (Note that this command will set only one of
     473the connections to the named host to \code{off}. If multiple
     474connections to a machine have been defined, multiple \code{off}
     475commands must be sent).
    505476
    506477When pcontrol is told to consider a machine on, the machine is moved
    507 from the off state to the down state. Pcontrol attempts to initiate a
    508 connection to the host. Connections are made by running a remote
    509 client on the host, using the specified connection method. The
    510 connection method may be ssh, rsh, or an equivalent remote shell
    511 connection. The choice is specified by the COMMAND Opihi variable. The
    512 remote connection starts a dedicated remote client which must accept
    513 the pcontrol client commands and respond appropriately. The provided
    514 remote client is called pclient, though in principal other equivalent
    515 programs could be used by setting the Opihi variable SHELL (this
    516 feature more generally allows a user to specify a path to the remote
    517 client, if it is not in the user's path). A pcontrol user may force a
    518 host to transition to the off state with the command host off
    519 (hostname). ( Note that this command will set only one of the
    520 connections to the named host to off. If multiple connections to a
    521 machine have been defined, multiple off commands must be sent).
     478from the \code{off} state to the \code{down} state. Pcontrol attempts
     479to initiate a connection to the host. Connections are made by running
     480a remote client on the host, using the specified connection
     481method. The connection method may be ssh, rsh, or an equivalent remote
     482shell connection. The choice is specified by the \code{COMMAND} Opihi
     483variable. The remote connection starts a dedicated remote client which
     484must accept the pcontrol client commands and respond
     485appropriately. The provided remote client is called {\em pclient},
     486though in principal other equivalent programs could be used by setting
     487the Opihi variable \code{SHELL}.  This feature more generally allows a
     488user to specify a path to the remote client, if it is not in the
     489user's path.
    522490
    523491If the remote connection is successful, the connected host is moved by
    524 pcontrol from the down state to the idle state. If the connection is
    525 unsuccessful, pcontrol will try again after a certain period of
    526 time. If the connection continues to be unsuccessful, the retry period
    527 is doubled for each successiver connection attempt. If the user wants
    528 to force pcontrol to retry the connection to a machine (if, for
    529 example, the timeout is now very long, but the user knows the
     492pcontrol from the \code{down} state to the \code{idle} state. If the
     493connection is unsuccessful, pcontrol will try again after a certain
     494period of time. If the connection continues to be unsuccessful, the
     495retry period is doubled for each successiver connection attempt. If
     496the user wants to force pcontrol to retry the connection to a machine
     497(if, for example, the timeout is now very long, but the user knows the
    530498machine's ethernet cable has been re-inserted...), this can be
    531 achieved with the command host retry (hostname). A host which is down
    532 is in the limbo state between off and idle.
     499achieved with the command host \code{retry (hostname)}. A host which
     500is \code{down} is in the limbo state between \code{off} and
     501\code{idle}.
    533502
    534503Once pcontrol has made a successful connection to the host, the host
    535 is in the idle state. At this point, it is ready to accept jobs from
    536 pcontrol for execution. Pcontrol repeatedly queries the hosts to check
    537 that they are still alive. If a host is discovered to be unresponsive,
    538 and particularly if the remote pipe connection has closed, then the
    539 machine is moved back to the down state.
    540 
    541 Hosts which are idle may accept a job from pcontrol. A job simply
    542 consists of a bare UNIX command, without redirection of standard input
    543 or standard output. The host will initiate the job, and pcontrol will
    544 place the host into the busy state. The remote client, pclient, runs
    545 the job in the background and will continue to accept input from
    546 pcontrol. pcontrol will continue to check the status of the host, and
    547 now also the status of the specific job. As before, if the connection
    548 breaks, pcontrol will migrate the host to the down state. Any job
    549 already initiated on a host which goes down will be returned for later
    550 processing, so the job will not be lost.
     504is in the \code{idle} state. At this point, it is ready to accept jobs
     505from pcontrol for execution. Pcontrol periodically queries the hosts
     506to check that they are still alive. If a host is discovered to be
     507unresponsive, and particularly if the remote pipe connection has
     508closed, then the machine is moved back to the \code{down} state.
     509
     510Hosts which are \code{idle} may accept a job from pcontrol. A job
     511simply consists of a bare UNIX command, without redirection of
     512standard input or standard output. The host will initiate the job, and
     513pcontrol will place the host into the \code{busy} state. The remote
     514client, pclient, runs the job in the background and will continue to
     515accept input from pcontrol. pcontrol will continue to check the status
     516of the host, and now also the status of the specific job. As before,
     517if the connection breaks, pcontrol will migrate the host to the
     518\code{down} state. Any job already initiated on a host which goes down
     519will be returned to the pool of unexecuted jobs for later processing,
     520so the job will not be lost.
    551521
    552522When the job exits, pclient tells pcontrol that the job is completed,
    553523and specifies the exit status. At this point, pcontrol will move the
    554 host from busy to done state. It will stay in this state until
    555 pcontrol can determine the ending conditions and reset the remote
    556 client. pcontrol requests the standard error and standard output from
    557 the job from pclient. pcontrol stores this data with its information
    558 about the completed job, and send a reset command to the remote
    559 client. Once these cleanup tasks are successfully completed, pcontrol
    560 will move the host to the idle state, ready for further jobs.
     524host from \code{busy} to \code{done} state. It will stay in this state
     525until pcontrol can determine the ending conditions and reset the
     526remote client. pcontrol requests the standard error and standard
     527output from the job from pclient. pcontrol stores this data with its
     528information about the completed job, and send a reset command to the
     529remote client. Once these cleanup tasks are successfully completed,
     530pcontrol will move the host to the \code{idle} state, ready for
     531further jobs.
    561532
    562533Each physical computer may have multiple processors. pcontrol treats
     
    574545\subsection{Jobs}
    575546
    576 The pcontrol accepts new jobs with the command job ..., in which the
    577 ellipsis represents the command and arguments of a valid UNIX
    578 command. The commands are run under sh, and are executed in the user's
    579 home directory. (If it is desired, we can easily add a command to tell
    580 pclient to perform cd). Users should be wary of the conditions under
    581 which the remote jobs are run. If the nodes in question all
     547The pcontrol accepts new jobs with the command \code{job ...}, in
     548which the ellipsis represents the command and arguments of a valid
     549UNIX command. The commands are run under \code{sh}, and are executed
     550in the user's home directory. Users should be wary of the conditions
     551under which the remote jobs are run. If the nodes in question all
    582552cross-mount the same home directories, multiple jobs which interact
    583553with the same named file may produce unexpected results. The
     
    590560not realize that specific jobs do not behave the same on all machines,
    591561or if a necessary resource (eg, some input data file) is only
    592 available or accessible from some of the hosts. It is the
     562available or accessible from some of the hosts. It is also the
    593563responsibility of the task to wait for network lags (ie, NFS delays).
    594564
     
    597567pcontrol, the command echoes back the Job ID. This ID may be used by
    598568other pcontrol commands to obtain information about or interact with
    599 the job.
     569the job.  For example, PanTasks uses the Job ID to examine specific
     570jobs.
    600571
    601572A job may specify a specific host for the task execution. The host
     
    634605(JobID).
    635606
    636 Jobs are moved between the following states by pcontrol:
    637 
     607\begin{figure}
     608\begin{center}
     609\includegraphics[scale=0.85,angle=-90]{pics/pantasks.05.ps}
     610\caption{\label{queues} pcontrol job states.  Transitions labeled Ux
     611  are issued by the pcontrol user (including PanTasks).  Transitions
     612  labeled Px are initiated by pcontrol.  Transitions labeled Tx are
     613  the result of the job completion}
     614\end{center}
     615\end{figure}
     616
     617Jobs are moved between the following states by pcontrol (see
     618Figure~\ref{JobStates}):
    638619\begin{itemize}
    639620\item pending: the job has not yet been executed.
     
    647628
    648629It is possible to check the status of a single host or job with the
    649 user command check.
     630user command \code{check}.
    650631
    651632pcontrol continuously examines the stack of jobs, adjusting their
     
    658639number of microseconds for the timeout.
    659640
    660 the pcontrol system status may be examined with the command
     641The pcontrol system status may be examined with the command
    661642status. This provides a dump of the job stacks and the host stacks.
    662643
     
    668649have exited or crashed.
    669650
    670 A specific job may be killed with the command kill (JobID). This
    671 command is only valid for a job in the busy state. Any job in the
    672 pending, exit, or crash state may be deleted with the delete (JobID)
    673 command. This is necessary to free the memory associated with the job
    674 and its output streams.
    675 
    676 The command verbose (mode) turns the verbosity of the pcontrol
     651A specific job may be killed with the command \code{kill
     652(JobID)}. This command is only valid for a job in the busy state. Any
     653job in the pending, exit, or crash state may be deleted with the
     654\code{delete (JobID)} command. This is necessary to free the memory
     655associated with the job and its output streams.  PanTasks
     656automatically performs these job harvesting functions.
     657
     658The command \code{verbose (mode)} turns the verbosity of the pcontrol
    677659operations on or off.
    678660
    679 The pcontrol and the IPP Image Server have related needs for
    680 information from the combined storage-and-processing nodes regarding
    681 which nodes are available. It is not yet clear if this information is
    682 best stored in a single location (either pcontrol or IPP Image
    683 Server), which provides the information to other systems on demand, or
    684 if both systems should maintain the information. Also, it may be
    685 necessary to distinguish nodes which are available for processing from
    686 those that are available to serve data as part of the IPP Image
    687 Server.
    688 
    689 \subsection{Command Summary}
     661The pcontrol and Nebulous have related needs for information from the
     662combined storage-and-processing nodes regarding which nodes are
     663available. Currently, the two systems independently examine the
     664hardware to judge the availability.  It is not yet clear if this
     665information is best stored in a single location (either pcontrol or
     666Nebulous), which provides the information to other systems on demand.
     667The current implementation allows the IPP system as a whole to
     668distinguih nodes which are available for processing from those that
     669are available to serve data as part of Nebulous.
     670
     671\begin{figure}
     672\begin{center}
     673\includegraphics[scale=0.85,angle=-90]{pics/pantasks.06.ps}
     674\caption{\label{PControlLoop} PControl Job Monitor Loop}
     675\end{center}
     676\end{figure}
     677
     678Figure~\ref{PControlLoop} illustrated the pcontrol job monitor loop.
     679This is very similar to the loop in PanTasks.  A background process
     680launched by readline during idle periods cycles through the list of
     681hosts (children) and migrates jobs to and from them as needed.
     682
     683\subsection{pcontrol Command Summary}
    690684
    691685\begin{verbatim}
     
    703697\end{verbatim}
    704698
    705 \begin{figure}
    706 \begin{center}
    707 \includegraphics[scale=0.85]{pics/pantasks.04.ps}
    708 \caption{\label{queues} PanTasks queues and MDDB tables}
    709 \end{center}
    710 \end{figure}
    711 
    712 \begin{figure}
    713 \begin{center}
    714 \includegraphics[scale=0.85]{pics/pantasks.05.ps}
    715 \caption{\label{queues} PanTasks queues and MDDB tables}
    716 \end{center}
    717 \end{figure}
    718 
    719 \begin{figure}
    720 \begin{center}
    721 \includegraphics[scale=0.85]{pics/pantasks.06.ps}
    722 \caption{\label{queues} PanTasks queues and MDDB tables}
    723 \end{center}
    724 \end{figure}
    725 
    726699\newpage
    727700\section{pclient}
     
    739712recommended practice is to set up ssh to allow the connection to the
    740713remote host without additional authentication using the appropriate
    741 authorized keys (see this article on ssh issues).
     714authorized keys.  The security is maintained by the security of ssh
     715logins to the computers used by PanTask and pcontrol. 
    742716
    743717It is convenient to keep a continuous connection to the remote
     
    768742\begin{figure}
    769743\begin{center}
    770 \includegraphics[scale=0.85]{pics/pantasks.07.ps}
     744\includegraphics[scale=0.85,angle=-90]{pics/pantasks.07.ps}
    771745\caption{\label{queues} PanTasks queues and MDDB tables}
    772746\end{center}
Note: See TracChangeset for help on using the changeset viewer.