00001
00002
00003
00004
00005 #ifndef windows_platform
00006
00007 #include <sys/types.h>
00008 #include <sys/wait.h>
00009 #endif
00010 #include "reServerLib.h"
00011 #if 0
00012 #include "resource.h"
00013 #include "collection.h"
00014 #include "specColl.h"
00015 #include "modDataObjMeta.h"
00016 #endif
00017 #include "ruleExecSubmit.h"
00018 #include "ruleExecDel.h"
00019 #include "genQuery.h"
00020 #include "icatHighLevelRoutines.h"
00021 #include "reSysDataObjOpr.h"
00022 #include "miscUtil.h"
00023 #include "rodsClient.h"
00024 #include "rsIcatOpr.h"
00025 #include "resource.h"
00026 #include "eirods_stacktrace.h"
00027
00028 int
00029 getReInfo (rsComm_t *rsComm, genQueryOut_t **genQueryOut)
00030 {
00031 genQueryInp_t genQueryInp;
00032 int status;
00033
00034 *genQueryOut = NULL;
00035 memset (&genQueryInp, 0, sizeof (genQueryInp_t));
00036
00037
00038 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ID, ORDER_BY);
00039 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_NAME, 1);
00040 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_REI_FILE_PATH, 1);
00041 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_USER_NAME, 1);
00042 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ADDRESS, 1);
00043 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_TIME, 1);
00044 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_FREQUENCY, 1);
00045 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_PRIORITY, 1);
00046 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ESTIMATED_EXE_TIME, 1);
00047 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_NOTIFICATION_ADDR, 1);
00048 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_LAST_EXE_TIME, 1);
00049 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_STATUS, 1);
00050
00051 genQueryInp.maxRows = MAX_SQL_ROWS;
00052
00053 status = rsGenQuery (rsComm, &genQueryInp, genQueryOut);
00054
00055 if (status >= 0) svrCloseQueryOut (rsComm, *genQueryOut);
00056 clearGenQueryInp (&genQueryInp);
00057
00058 if (*genQueryOut != NULL) {
00059 if (status < 0) {
00060 free (*genQueryOut);
00061 *genQueryOut = NULL;
00062 } else {
00063 svrCloseQueryOut (rsComm, *genQueryOut);
00064 }
00065 }
00066 return (status);
00067 }
00068
00069 int
00070 getReInfoById (rsComm_t *rsComm, char *ruleExecId, genQueryOut_t **genQueryOut)
00071 {
00072 genQueryInp_t genQueryInp;
00073 char tmpStr[NAME_LEN];
00074 int status;
00075
00076 memset (&genQueryInp, 0, sizeof (genQueryInp_t));
00077
00078 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ID, 1);
00079 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_NAME, 1);
00080 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_REI_FILE_PATH, 1);
00081 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_USER_NAME, 1);
00082 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ADDRESS, 1);
00083 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_TIME, 1);
00084 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_FREQUENCY, 1);
00085 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_PRIORITY, 1);
00086 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_ESTIMATED_EXE_TIME, 1);
00087 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_NOTIFICATION_ADDR, 1);
00088 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_LAST_EXE_TIME, 1);
00089 addInxIval (&genQueryInp.selectInp, COL_RULE_EXEC_STATUS, 1);
00090
00091 snprintf (tmpStr, NAME_LEN, "='%s'", ruleExecId);
00092 addInxVal (&genQueryInp.sqlCondInp, COL_RULE_EXEC_ID, tmpStr);
00093
00094 genQueryInp.maxRows = MAX_SQL_ROWS;
00095
00096 status = rsGenQuery (rsComm, &genQueryInp, genQueryOut);
00097
00098 clearGenQueryInp (&genQueryInp);
00099
00100 return (status);
00101 }
00102
00103
00104
00105
00106
00107
00108 int
00109 getNextQueuedRuleExec (rsComm_t *rsComm, genQueryOut_t **inGenQueryOut,
00110 int startInx, ruleExecSubmitInp_t *queuedRuleExec,
00111 reExec_t *reExec, int jobType)
00112 {
00113 sqlResult_t *ruleExecId, *ruleName, *reiFilePath, *userName, *exeAddress,
00114 *exeTime, *exeFrequency, *priority, *lastExecTime, *exeStatus,
00115 *estimateExeTime, *notificationAddr;
00116 int i, status;
00117 genQueryOut_t *genQueryOut;
00118
00119 if (inGenQueryOut == NULL || *inGenQueryOut == NULL ||
00120 queuedRuleExec == NULL || queuedRuleExec->packedReiAndArgBBuf == NULL ||
00121 queuedRuleExec->packedReiAndArgBBuf->buf == NULL) {
00122 rodsLog (LOG_ERROR,
00123 "getNextQueuedRuleExec: NULL input");
00124 return (SYS_INTERNAL_NULL_INPUT_ERR);
00125 }
00126
00127 genQueryOut = *inGenQueryOut;
00128 if ((ruleExecId = getSqlResultByInx (genQueryOut,
00129 COL_RULE_EXEC_ID)) == NULL) {
00130 rodsLog (LOG_NOTICE,
00131 "getNextQueuedRuleExec: getSqlResultByInx for EXEC_ID failed");
00132 return (UNMATCHED_KEY_OR_INDEX);
00133 }
00134 if ((ruleName = getSqlResultByInx (genQueryOut,
00135 COL_RULE_EXEC_NAME)) == NULL) {
00136 rodsLog (LOG_NOTICE,
00137 "getNextQueuedRuleExec: getSqlResultByInx for EXEC_NAME failed");
00138 return (UNMATCHED_KEY_OR_INDEX);
00139 }
00140 if ((reiFilePath = getSqlResultByInx (genQueryOut,
00141 COL_RULE_EXEC_REI_FILE_PATH)) == NULL) {
00142 rodsLog (LOG_NOTICE,
00143 "getNextQueuedRuleExec: getSqlResultByInx for REI_FILE_PATH failed");
00144 return (UNMATCHED_KEY_OR_INDEX);
00145 }
00146 if ((userName = getSqlResultByInx (genQueryOut,
00147 COL_RULE_EXEC_USER_NAME)) == NULL) {
00148 rodsLog (LOG_NOTICE,
00149 "getNextQueuedRuleExec: getSqlResultByInx for USER_NAME failed");
00150 return (UNMATCHED_KEY_OR_INDEX);
00151 }
00152 if ((exeAddress = getSqlResultByInx (genQueryOut,
00153 COL_RULE_EXEC_ADDRESS)) == NULL) {
00154 rodsLog (LOG_NOTICE,
00155 "getNextQueuedRuleExec: getSqlResultByInx for EXEC_ADDRESS failed");
00156 return (UNMATCHED_KEY_OR_INDEX);
00157 }
00158 if ((exeTime = getSqlResultByInx (genQueryOut,
00159 COL_RULE_EXEC_TIME)) == NULL) {
00160 rodsLog (LOG_NOTICE,
00161 "getNextQueuedRuleExec: getSqlResultByInx for EXEC_TIME failed");
00162 return (UNMATCHED_KEY_OR_INDEX);
00163 }
00164 if ((exeFrequency = getSqlResultByInx (genQueryOut,
00165 COL_RULE_EXEC_FREQUENCY)) == NULL) {
00166 rodsLog (LOG_NOTICE,
00167 "getNextQueuedRuleExec:getResultByInx for RULE_EXEC_FREQUENCY failed");
00168 return (UNMATCHED_KEY_OR_INDEX);
00169 }
00170 if ((priority = getSqlResultByInx (genQueryOut,
00171 COL_RULE_EXEC_PRIORITY)) == NULL) {
00172 rodsLog (LOG_NOTICE,
00173 "getNextQueuedRuleExec: getSqlResultByInx for PRIORITY failed");
00174 return (UNMATCHED_KEY_OR_INDEX);
00175 }
00176 if ((lastExecTime = getSqlResultByInx (genQueryOut,
00177 COL_RULE_EXEC_LAST_EXE_TIME)) == NULL) {
00178 rodsLog (LOG_NOTICE,
00179 "getNextQueuedRuleExec: getSqlResultByInx for LAST_EXE_TIME failed");
00180 return (UNMATCHED_KEY_OR_INDEX);
00181 }
00182 if ((exeStatus = getSqlResultByInx (genQueryOut,
00183 COL_RULE_EXEC_STATUS)) == NULL) {
00184 rodsLog (LOG_NOTICE,
00185 "getNextQueuedRuleExec: getSqlResultByInx for EXEC_STATUS failed");
00186 return (UNMATCHED_KEY_OR_INDEX);
00187 }
00188 if ((estimateExeTime = getSqlResultByInx (genQueryOut,
00189 COL_RULE_EXEC_ESTIMATED_EXE_TIME)) == NULL) {
00190 rodsLog (LOG_NOTICE,
00191 "getNextQueuedRuleExec: getResultByInx for ESTIMATED_EXE_TIME failed");
00192 return (UNMATCHED_KEY_OR_INDEX);
00193 }
00194 if ((notificationAddr = getSqlResultByInx (genQueryOut,
00195 COL_RULE_EXEC_NOTIFICATION_ADDR)) == NULL) {
00196 rodsLog (LOG_NOTICE,
00197 "getNextQueuedRuleExec:getResultByInx for NOTIFICATION_ADDR failed");
00198 return (UNMATCHED_KEY_OR_INDEX);
00199 }
00200
00201 for (i = startInx; i < genQueryOut->rowCnt; i++) {
00202 char *exeStatusStr, *exeTimeStr, *ruleExecIdStr;
00203 #if 0
00204 struct stat statbuf;
00205 int fd;
00206 #endif
00207
00208
00209 exeStatusStr = &exeStatus->value[exeStatus->len * i];
00210 exeTimeStr = &exeTime->value[exeTime->len * i];
00211 ruleExecIdStr = &ruleExecId->value[ruleExecId->len * i];
00212
00213 if ((jobType & RE_FAILED_STATUS) == 0 &&
00214 strcmp (exeStatusStr, RE_FAILED) == 0) {
00215
00216 continue;
00217 } else if (atoi (exeTimeStr) > time (0)) {
00218
00219 continue;
00220 } else if (strcmp (exeStatusStr, RE_RUNNING) == 0) {
00221
00222 if (reExec->doFork == 1 &&
00223 matchRuleExecId (reExec, ruleExecIdStr, RE_PROC_RUNNING)) {
00224
00225 continue;
00226 } else {
00227 rodsLog (LOG_NOTICE,
00228 "getNextQueuedRuleExec: reId %s in RUNNING state. Run again",
00229 ruleExecIdStr);
00230 }
00231 }
00232 #if 0
00233 rstrcpy (queuedRuleExec->reiFilePath,
00234 &reiFilePath->value[reiFilePath->len * i], MAX_NAME_LEN);
00235 if (stat (queuedRuleExec->reiFilePath, &statbuf) < 0) {
00236 status = UNIX_FILE_STAT_ERR - errno;
00237 rodsLog (LOG_ERROR,
00238 "getNextQueuedRuleExec: stat error for rei file %s, status = %d",
00239 queuedRuleExec->reiFilePath, status);
00240 continue;
00241 }
00242
00243 if (statbuf.st_size > queuedRuleExec->packedReiAndArgBBuf->len) {
00244 free (queuedRuleExec->packedReiAndArgBBuf->buf);
00245 queuedRuleExec->packedReiAndArgBBuf->buf =
00246 malloc ((int) statbuf.st_size);
00247 queuedRuleExec->packedReiAndArgBBuf->len = statbuf.st_size;
00248 }
00249
00250 fd = open (queuedRuleExec->reiFilePath, O_RDONLY,0);
00251 if (fd < 0) {
00252 status = UNIX_FILE_OPEN_ERR - errno;
00253 rodsLog (LOG_ERROR,
00254 "getNextQueuedRuleExec: open error for rei file %s, status = %d",
00255 queuedRuleExec->reiFilePath, status);
00256 return (status);
00257 }
00258
00259 status = read (fd, queuedRuleExec->packedReiAndArgBBuf->buf,
00260 queuedRuleExec->packedReiAndArgBBuf->len);
00261
00262 close (fd);
00263 if (status != statbuf.st_size) {
00264 if (status < 0) {
00265 status = UNIX_FILE_READ_ERR - errno;
00266 rodsLog (LOG_ERROR,
00267 "getNextQueuedRuleExec: read error for file %s, status = %d",
00268 queuedRuleExec->reiFilePath, status);
00269 } else {
00270 rodsLog (LOG_ERROR,
00271 "getNextQueuedRuleExec:read error for %s,toRead %d, read %d",
00272 queuedRuleExec->reiFilePath,
00273 queuedRuleExec->packedReiAndArgBBuf->len, status);
00274 return (SYS_COPY_LEN_ERR);
00275 }
00276 }
00277
00278 rstrcpy (queuedRuleExec->exeTime, exeTimeStr, NAME_LEN);
00279 rstrcpy (queuedRuleExec->exeStatus, exeStatusStr, NAME_LEN);
00280 rstrcpy (queuedRuleExec->ruleExecId, ruleExecIdStr, NAME_LEN);
00281
00282 rstrcpy (queuedRuleExec->ruleName,
00283 &ruleName->value[ruleName->len * i], META_STR_LEN);
00284 rstrcpy (queuedRuleExec->userName,
00285 &userName->value[userName->len * i], NAME_LEN);
00286 rstrcpy (queuedRuleExec->exeAddress,
00287 &exeAddress->value[exeAddress->len * i], NAME_LEN);
00288 rstrcpy (queuedRuleExec->exeFrequency,
00289 &exeFrequency->value[exeFrequency->len * i], NAME_LEN);
00290 rstrcpy (queuedRuleExec->priority,
00291 &priority->value[priority->len * i], NAME_LEN);
00292 rstrcpy (queuedRuleExec->estimateExeTime,
00293 &estimateExeTime->value[estimateExeTime->len * i], NAME_LEN);
00294 rstrcpy (queuedRuleExec->notificationAddr,
00295 ¬ificationAddr->value[notificationAddr->len * i], NAME_LEN);
00296 #else
00297 status = fillExecSubmitInp (queuedRuleExec, exeStatusStr, exeTimeStr,
00298 ruleExecIdStr,
00299 &reiFilePath->value[reiFilePath->len * i],
00300 &ruleName->value[ruleName->len * i],
00301 &userName->value[userName->len * i],
00302 &exeAddress->value[exeAddress->len * i],
00303 &exeFrequency->value[exeFrequency->len * i],
00304 &priority->value[priority->len * i],
00305 &estimateExeTime->value[estimateExeTime->len * i],
00306 ¬ificationAddr->value[notificationAddr->len * i]);
00307 if (status < 0) continue;
00308 #endif
00309 return (i);
00310 }
00311 return (-1);
00312 }
00313
00314 int
00315 modExeInfoForRepeat(rsComm_t *rsComm, char *ruleExecId, char* pastTime,
00316 char *delay, int opStatus) {
00317 keyValPair_t *regParam;
00318 int status, status1;
00319 char myTimeNow[200];
00320 char myTimeNext[200];
00321 ruleExecModInp_t ruleExecModInp;
00322 ruleExecDelInp_t ruleExecDelInp;
00323
00324 if (opStatus > 0) opStatus = 0;
00325
00326 rstrcpy (myTimeNext, pastTime, 200);
00327 getOffsetTimeStr((char*)&myTimeNow, " ");
00328
00329 status1 = getNextRepeatTime(myTimeNow, delay,myTimeNext);
00330
00331
00332
00333
00334
00335
00336
00337 rodsLog (LOG_NOTICE,"modExeInfoForRepeat: rulId=%s,opStatus=%d,nextRepeatStatus=%d",ruleExecId,opStatus,status1);
00338 regParam = &(ruleExecModInp.condInput);
00339 rstrcpy (ruleExecModInp.ruleId, ruleExecId, NAME_LEN);
00340 memset (regParam, 0, sizeof (keyValPair_t));
00341 if (status1 == 0) {
00342 addKeyVal (regParam, RULE_EXE_STATUS_KW, "");
00343 addKeyVal (regParam, RULE_LAST_EXE_TIME_KW, myTimeNow);
00344 addKeyVal (regParam, RULE_EXE_TIME_KW, myTimeNext);
00345 status = rsRuleExecMod(rsComm, &ruleExecModInp);
00346 }
00347 else if (status1 == 1) {
00348 if (opStatus == 0) {
00349
00350 rstrcpy (ruleExecDelInp.ruleExecId, ruleExecId, NAME_LEN);
00351 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00352 }
00353 else {
00354 addKeyVal (regParam, RULE_EXE_STATUS_KW, "");
00355 addKeyVal (regParam, RULE_LAST_EXE_TIME_KW, myTimeNow);
00356 addKeyVal (regParam, RULE_EXE_TIME_KW, myTimeNext);
00357 status = rsRuleExecMod(rsComm, &ruleExecModInp);
00358 }
00359 }
00360 else if (status1 == 2 ) {
00361
00362 rstrcpy (ruleExecDelInp.ruleExecId, ruleExecId, NAME_LEN);
00363 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00364 }
00365 else if (status1 == 3 ) {
00366 addKeyVal (regParam, RULE_EXE_STATUS_KW, "");
00367 addKeyVal (regParam, RULE_LAST_EXE_TIME_KW, myTimeNow);
00368 addKeyVal (regParam, RULE_EXE_TIME_KW, myTimeNext);
00369 addKeyVal (regParam, RULE_EXE_FREQUENCY_KW,delay);
00370 status = rsRuleExecMod(rsComm, &ruleExecModInp);
00371 }
00372 else if (status1 == 4 ) {
00373 if (opStatus == 0) {
00374
00375 rstrcpy (ruleExecDelInp.ruleExecId, ruleExecId, NAME_LEN);
00376 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00377 }
00378 else {
00379 addKeyVal (regParam, RULE_EXE_STATUS_KW, "");
00380 addKeyVal (regParam, RULE_LAST_EXE_TIME_KW, myTimeNow);
00381 addKeyVal (regParam, RULE_EXE_TIME_KW, myTimeNext);
00382 addKeyVal (regParam, RULE_EXE_FREQUENCY_KW,delay);
00383 status = rsRuleExecMod(rsComm, &ruleExecModInp);
00384 }
00385 }
00386 if (regParam->len > 0)
00387 clearKeyVal (regParam);
00388
00389 if (status < 0) {
00390 rodsLog (LOG_ERROR,
00391 "modExeInfoForRepeat: rsRuleExecMod/rsRuleExecDel Error of id %s failed, status = %d",
00392 ruleExecId, status);
00393 }
00394 else {
00395 if (status1 == 3 || (status1 != 2 && opStatus != 0))
00396 rodsLog (LOG_NOTICE,
00397 "Rule id %s set to run again at %s (frequency %s seconds)",
00398 ruleExecId, myTimeNext, delay);
00399 }
00400
00401 return (status);
00402 }
00403
00404 int
00405 regExeStatus (rsComm_t *rsComm, char *ruleExecId, char *exeStatus)
00406 {
00407 keyValPair_t *regParam;
00408 ruleExecModInp_t ruleExecModInp;
00409 int status;
00410
00411 regParam = &(ruleExecModInp.condInput);
00412 memset (regParam, 0, sizeof (keyValPair_t));
00413 rstrcpy (ruleExecModInp.ruleId, ruleExecId, NAME_LEN);
00414 addKeyVal (regParam, RULE_EXE_STATUS_KW, exeStatus);
00415 status = rsRuleExecMod(rsComm, &ruleExecModInp);
00416
00417
00418 clearKeyVal (regParam);
00419
00420 if (status < 0) {
00421 rodsLog (LOG_ERROR,
00422 "regExeStatus: rsRuleExecMod of id %s failed, status = %d",
00423 ruleExecId, status);
00424 }
00425
00426 return (status);
00427 }
00428
00429
00430
00431
00432
00433
00434
00435 int
00436 runQueuedRuleExec (rsComm_t *rsComm, reExec_t *reExec,
00437 genQueryOut_t **genQueryOut, time_t endTime, int jobType)
00438 {
00439 int inx, status;
00440 ruleExecSubmitInp_t *myRuleExecInp;
00441 int runCnt = 0;
00442 int thrInx;
00443
00444 inx = -1;
00445 while (time(NULL) <= endTime && (thrInx = allocReThr (rsComm, reExec)) >= 0) {
00446 myRuleExecInp = &reExec->reExecProc[thrInx].ruleExecSubmitInp;
00447 chkAndUpdateResc (rsComm);
00448 if ((inx = getNextQueuedRuleExec (rsComm, genQueryOut, inx + 1,
00449 myRuleExecInp, reExec, jobType)) < 0) {
00450
00451 freeReThr (reExec, thrInx);
00452 break;
00453 } else {
00454 reExec->reExecProc[thrInx].jobType = jobType;
00455 }
00456
00457
00458 status = regExeStatus (rsComm, myRuleExecInp->ruleExecId,
00459 RE_RUNNING);
00460 if (status < 0) {
00461 rodsLog (LOG_ERROR,
00462 "runQueuedRuleExec: regExeStatus of id %s failed,stat = %d",
00463 myRuleExecInp->ruleExecId, status);
00464 freeReThr (reExec, thrInx);
00465 continue;
00466 }
00467
00468 runCnt ++;
00469 if (reExec->doFork == 0) {
00470
00471 status = execRuleExec (&reExec->reExecProc[thrInx]);
00472 postProcRunRuleExec (rsComm, &reExec->reExecProc[thrInx]);
00473 freeReThr (reExec, thrInx);
00474 continue;
00475 } else {
00476 #ifdef RE_EXEC_PROC
00477 if ((reExec->reExecProc[thrInx].pid = fork()) == 0) {
00478
00479
00480 if ((status = resetRcatHost (rsComm, MASTER_RCAT,
00481 rsComm->myEnv.rodsZone)) == LOCAL_HOST) {
00482 #ifdef RODS_CAT
00483 resetRcat (rsComm);
00484 #endif
00485 }
00486
00487 execRuleExec (&reExec->reExecProc[thrInx]);
00488 #else
00489 if ((reExec->reExecProc[thrInx].pid = fork()) == 0) {
00490 status = postForkExecProc (rsComm,
00491 &reExec->reExecProc[thrInx]);
00492 if (status >= 0) {
00493 exit (0);
00494 } else {
00495 exit (1);
00496 }
00497 #endif
00498 } else {
00499 #ifdef RE_SERVER_DEBUG
00500 rodsLog (LOG_NOTICE,
00501 "runQueuedRuleExec: started proc %d, thrInx %d",
00502 reExec->reExecProc[thrInx].pid, thrInx);
00503 #endif
00504
00505 reExec->runCnt++;
00506 continue;
00507 }
00508 }
00509 }
00510 if (reExec->doFork == 1) {
00511
00512 while (reExec->runCnt + 1 >= reExec->maxRunCnt &&
00513 waitAndFreeReThr (rsComm, reExec) >= 0);
00514 }
00515
00516 return (runCnt);
00517 }
00518
00519 int
00520 postForkExecProc (rsComm_t *rsComm, reExecProc_t *reExecProc)
00521 {
00522 int status;
00523
00524
00525 rodsServerHost_t *rodsServerHost = NULL;
00526
00527 if ((status = resetRcatHost (rsComm, MASTER_RCAT, rsComm->myEnv.rodsZone))
00528 == LOCAL_HOST) {
00529 #ifdef RODS_CAT
00530 resetRcat (rsComm);
00531 #endif
00532 }
00533 if ((status = getAndConnRcatHost (rsComm, MASTER_RCAT,
00534 rsComm->myEnv.rodsZone, &rodsServerHost)) == LOCAL_HOST) {
00535 #ifdef RODS_CAT
00536 status = connectRcat (rsComm);
00537 if (status < 0) {
00538 rodsLog (LOG_ERROR,
00539 "runQueuedRuleExec: connectRcat error. status=%d", status);
00540 }
00541 #endif
00542 }
00543 seedRandom ();
00544 status = runRuleExec (reExecProc);
00545 postProcRunRuleExec (rsComm, reExecProc);
00546 #ifdef RE_SERVER_DEBUG
00547 rodsLog (LOG_NOTICE,
00548 "runQueuedRuleExec: process %d exiting", getpid ());
00549 #endif
00550 return (reExecProc->status);
00551 }
00552
00553 int
00554 execRuleExec (reExecProc_t *reExecProc)
00555 {
00556 int status;
00557 char *av[NAME_LEN];
00558 int avInx = 0;
00559
00560
00561 av[avInx] = strdup (RE_EXE);
00562 avInx++;
00563 av[avInx] = strdup ("-j");
00564 avInx++;
00565 av[avInx] = strdup (reExecProc->ruleExecSubmitInp.ruleExecId);
00566 avInx++;
00567 av[avInx] = strdup ("-t");
00568 avInx++;
00569 av[avInx] = (char*)malloc (sizeof (int) * 2);
00570 sprintf (av[avInx], "%d", reExecProc->jobType);
00571 avInx++;
00572 av[avInx] = NULL;
00573
00574 status = execv (av[0], av);
00575 if (status < 0) {
00576 rodsLog (LOG_ERROR,
00577 "execExecProc: execv of ID %s error, errno = %d",
00578 reExecProc->ruleExecSubmitInp.ruleExecId, errno);
00579 }
00580 return status;
00581 }
00582
00583 #ifndef windows_platform
00584 int
00585 initReExec (rsComm_t *rsComm, reExec_t *reExec)
00586 {
00587 int i;
00588 ruleExecInfo_t rei;
00589 int status;
00590
00591 if (reExec == NULL) return SYS_INTERNAL_NULL_INPUT_ERR;
00592
00593 bzero (reExec, sizeof (reExec_t));
00594 bzero (&rei, sizeof (ruleExecInfo_t));
00595
00596 rei.rsComm = rsComm;
00597 status = applyRule ("acSetReServerNumProc", NULL, &rei, NO_SAVE_REI);
00598 if (status < 0) {
00599 rodsLog (LOG_ERROR,
00600 "initReExec: rule acSetReServerNumProc error, status = %d",
00601 status);
00602 reExec->maxRunCnt = 1;
00603 reExec->doFork = 0;
00604 } else {
00605 reExec->maxRunCnt = rei.status;
00606 if (reExec->maxRunCnt <= 0) {
00607 reExec->maxRunCnt = 1;
00608 reExec->doFork = 0;
00609 } else {
00610 if (reExec->maxRunCnt > MAX_RE_PROCS)
00611 reExec->maxRunCnt = MAX_RE_PROCS;
00612 reExec->doFork = 1;
00613 }
00614 }
00615 for (i = 0; i < reExec->maxRunCnt; i++) {
00616 reExec->reExecProc[i].procExecState = RE_PROC_IDLE;
00617 reExec->reExecProc[i].ruleExecSubmitInp.packedReiAndArgBBuf =
00618 (bytesBuf_t *) malloc (sizeof (bytesBuf_t));
00619 reExec->reExecProc[i].ruleExecSubmitInp.packedReiAndArgBBuf->buf =
00620 malloc (REI_BUF_LEN);
00621 reExec->reExecProc[i].ruleExecSubmitInp.packedReiAndArgBBuf->len =
00622 REI_BUF_LEN;
00623
00624
00625 reExec->reExecProc[i].reComm.proxyUser = rsComm->proxyUser;
00626 reExec->reExecProc[i].reComm.myEnv = rsComm->myEnv;
00627 }
00628 return 0;
00629 }
00630
00631 int
00632 allocReThr (rsComm_t *rsComm, reExec_t *reExec)
00633 {
00634 int i;
00635 int thrInx = SYS_NO_FREE_RE_THREAD;
00636
00637 if (reExec == NULL) return SYS_INTERNAL_NULL_INPUT_ERR;
00638
00639 if (reExec->doFork == 0) {
00640
00641 reExec->runCnt = 1;
00642 return 0;
00643 }
00644
00645 reExec->runCnt = 0;
00646 for (i = 0; i < reExec->maxRunCnt; i++) {
00647 if (reExec->reExecProc[i].procExecState == RE_PROC_IDLE) {
00648 if (thrInx == SYS_NO_FREE_RE_THREAD) {
00649 thrInx = i;
00650 }
00651 } else {
00652 reExec->runCnt++;
00653 }
00654 }
00655 if (thrInx == SYS_NO_FREE_RE_THREAD) {
00656 thrInx = waitAndFreeReThr (rsComm, reExec);
00657 }
00658 if (thrInx >= 0)
00659 reExec->reExecProc[thrInx].procExecState = RE_PROC_RUNNING;
00660
00661 return (thrInx);
00662 }
00663
00664 int
00665 waitAndFreeReThr (rsComm_t *rsComm, reExec_t *reExec)
00666 {
00667 pid_t childPid;
00668 int status = 0;
00669 int thrInx = SYS_NO_FREE_RE_THREAD;
00670
00671 childPid = waitpid (-1, &status, WUNTRACED);
00672 if (childPid < 0) {
00673 if (reExec->runCnt > 0) {
00674 int i;
00675 rodsLog (LOG_NOTICE,
00676 "waitAndFreeReThr: no outstanding child. but runCnt=%d",
00677 reExec->runCnt);
00678 for (i = 0; i < reExec->maxRunCnt; i++) {
00679 if (reExec->reExecProc[i].procExecState != RE_PROC_IDLE) {
00680 freeReThr (reExec, i);
00681 }
00682 }
00683 reExec->runCnt = 0;
00684 thrInx = 0;
00685 }
00686 } else {
00687 thrInx = matchPidInReExec (reExec, childPid);
00688
00689
00690 if (thrInx >= 0) {
00691 genQueryOut_t *genQueryOut = NULL;
00692 int status1;
00693 reExecProc_t *reExecProc = &reExec->reExecProc[thrInx];
00694 char *ruleExecId = reExecProc->ruleExecSubmitInp.ruleExecId;
00695
00696 status1 = getReInfoById (rsComm, ruleExecId, &genQueryOut);
00697 if (status1 >= 0) {
00698 sqlResult_t *exeFrequency, *exeStatus;
00699 if ((exeFrequency = getSqlResultByInx (genQueryOut,
00700 COL_RULE_EXEC_FREQUENCY)) == NULL) {
00701 rodsLog (LOG_NOTICE,
00702 "waitAndFreeReThr:getResultByInx for RULE_EXEC_FREQUENCY failed");
00703 }
00704 if ((exeStatus = getSqlResultByInx (genQueryOut,
00705 COL_RULE_EXEC_STATUS)) == NULL) {
00706 rodsLog (LOG_NOTICE,
00707 "waitAndFreeReThr:getResultByInx for RULE_EXEC_STATUS failed");
00708 }
00709
00710 if(exeFrequency == NULL || strlen(exeFrequency->value) == 0 || strcmp(exeStatus->value, RE_RUNNING) == 0) {
00711
00712
00713 if ((reExecProc->jobType & RE_FAILED_STATUS) == 0) {
00714
00715 regExeStatus (rsComm, ruleExecId, RE_FAILED);
00716 } else {
00717 ruleExecDelInp_t ruleExecDelInp;
00718 rodsLog (LOG_ERROR,
00719 "waitAndFreeReThr: %s executed but still in iCat. Job deleted",
00720 ruleExecId);
00721 rstrcpy (ruleExecDelInp.ruleExecId, ruleExecId, NAME_LEN);
00722 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00723 }
00724 }
00725 freeGenQueryOut (&genQueryOut);
00726 }
00727 freeReThr (reExec, thrInx);
00728 }
00729
00730 }
00731 return thrInx;
00732 }
00733 #endif
00734
00735 int
00736 matchPidInReExec (reExec_t *reExec, pid_t pid)
00737 {
00738 int i;
00739
00740 for (i = 0; i < reExec->maxRunCnt; i++) {
00741 if (reExec->reExecProc[i].pid == pid) return i;
00742 }
00743 rodsLog (LOG_ERROR,
00744 "matchPidInReExec: no match for pid %d", pid);
00745
00746 return SYS_NO_FREE_RE_THREAD;
00747 }
00748
00749 int
00750 freeReThr (reExec_t *reExec, int thrInx)
00751 {
00752 bytesBuf_t *packedReiAndArgBBuf;
00753
00754 if( NULL == reExec ) {
00755 rodsLog( LOG_ERROR, "freeReThr :: NULL reExec ptr" );
00756 return SYS_INTERNAL_NULL_INPUT_ERR;
00757 }
00758 #ifdef RE_SERVER_DEBUG
00759 rodsLog (LOG_NOTICE,
00760 "freeReThr: thrInx %d, pid %d",thrInx, reExec->reExecProc[thrInx].pid);
00761 #endif
00762
00763 if (thrInx < 0 || thrInx >= reExec->maxRunCnt) {
00764 rodsLog (LOG_ERROR, "freeReThr: Bad input thrInx %d", thrInx);
00765 return (SYS_BAD_RE_THREAD_INX);
00766 }
00767 reExec->runCnt--;
00768 reExec->reExecProc[thrInx].procExecState = RE_PROC_IDLE;
00769 reExec->reExecProc[thrInx].status = 0;
00770 reExec->reExecProc[thrInx].jobType = 0;
00771 reExec->reExecProc[thrInx].pid = 0;
00772
00773 packedReiAndArgBBuf =
00774 reExec->reExecProc[thrInx].ruleExecSubmitInp.packedReiAndArgBBuf;
00775
00776 bzero (packedReiAndArgBBuf->buf, REI_BUF_LEN);
00777 bzero (&reExec->reExecProc[thrInx].ruleExecSubmitInp,
00778 sizeof (ruleExecSubmitInp_t));
00779 reExec->reExecProc[thrInx].ruleExecSubmitInp.packedReiAndArgBBuf =
00780 packedReiAndArgBBuf;
00781
00782 return 0;
00783 }
00784
00785 int
00786 runRuleExec (reExecProc_t *reExecProc)
00787 {
00788 ruleExecSubmitInp_t *myRuleExec;
00789 ruleExecInfoAndArg_t *reiAndArg = NULL;
00790 rsComm_t *reComm;
00791
00792 if (reExecProc == NULL) {
00793 rodsLog (LOG_ERROR, "runRuleExec: NULL reExecProc input");
00794
00795 return SYS_INTERNAL_NULL_INPUT_ERR;
00796 }
00797
00798 reComm = &reExecProc->reComm;
00799 myRuleExec = &reExecProc->ruleExecSubmitInp;
00800
00801 reExecProc->status = unpackReiAndArg (reComm, &reiAndArg,
00802 myRuleExec->packedReiAndArgBBuf);
00803
00804 if (reExecProc->status < 0 || NULL == reiAndArg ) {
00805 rodsLog (LOG_ERROR,
00806 "runRuleExec: unpackReiAndArg of id %s failed, status = %d",
00807 myRuleExec->ruleExecId, reExecProc->status);
00808 return reExecProc->status;
00809 }
00810
00811
00812 reExecProc->status = applyRule (myRuleExec->ruleName,
00813 reiAndArg->rei->msParamArray,
00814 reiAndArg->rei, SAVE_REI);
00815
00816 if (reiAndArg->rei->status < 0) {
00817 reExecProc->status = reiAndArg->rei->status;
00818 }
00819 freeRuleExecInfoStruct (reiAndArg->rei, FREE_MS_PARAM | FREE_DOINP);
00820 free (reiAndArg);
00821
00822 return reExecProc->status;
00823 }
00824
00825 int
00826 postProcRunRuleExec (rsComm_t *rsComm, reExecProc_t *reExecProc)
00827 {
00828 int status = 0;
00829 int savedStatus = 0;
00830 ruleExecDelInp_t ruleExecDelInp;
00831 ruleExecSubmitInp_t *myRuleExecInp;
00832
00833 myRuleExecInp = &reExecProc->ruleExecSubmitInp;
00834
00835 if (strlen (myRuleExecInp->exeFrequency) > 0 ) {
00836 rodsLog(LOG_NOTICE, "postProcRunRuleExec: exec of freq: %s",
00837 myRuleExecInp->exeFrequency);
00838
00839 savedStatus = modExeInfoForRepeat (rsComm, myRuleExecInp->ruleExecId,
00840 myRuleExecInp->exeTime, myRuleExecInp->exeFrequency,
00841 reExecProc->status);
00842 }
00843 else if (reExecProc->status < 0) {
00844 rodsLog (LOG_ERROR,
00845 "postProcRunRuleExec: ruleExec of id %s failed, status = %d",
00846 myRuleExecInp->ruleExecId, reExecProc->status);
00847 if ((reExecProc->jobType & RE_FAILED_STATUS) == 0) {
00848
00849 regExeStatus (rsComm, myRuleExecInp->ruleExecId, RE_FAILED);
00850 } else {
00851
00852
00853 rodsLog (LOG_ERROR,
00854 "postProcRunRuleExec: ruleExec of %s: %s failed again.Removed",
00855 myRuleExecInp->ruleExecId, myRuleExecInp->ruleName);
00856 rstrcpy (ruleExecDelInp.ruleExecId, myRuleExecInp->ruleExecId,
00857 NAME_LEN);
00858 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00859 if (status < 0) {
00860 rodsLog (LOG_ERROR,
00861 "postProcRunRuleExec: rsRuleExecDel failed for %s, stat=%d",
00862 myRuleExecInp->ruleExecId, status);
00863 }
00864 }
00865 } else {
00866 rstrcpy (ruleExecDelInp.ruleExecId, myRuleExecInp->ruleExecId,
00867 NAME_LEN);
00868 rodsLog (LOG_NOTICE,
00869 "postProcRunRuleExec: exec of %s done", myRuleExecInp->ruleExecId);
00870 status = rsRuleExecDel (rsComm, &ruleExecDelInp);
00871 if (status < 0) {
00872 rodsLog (LOG_ERROR,
00873 "postProcRunRuleExec: rsRuleExecDel failed for %s, status = %d",
00874 myRuleExecInp->ruleExecId, status);
00875 }
00876 }
00877 if (status >= 0 && savedStatus < 0) return savedStatus;
00878
00879 return status;
00880 }
00881
00882 int
00883 matchRuleExecId (reExec_t *reExec, char *ruleExecIdStr,
00884 procExecState_t execState)
00885 {
00886 int i;
00887
00888 if (reExec == NULL || ruleExecIdStr == NULL ||
00889 execState == RE_PROC_IDLE) return 0;
00890
00891 for (i = 0; i < reExec->maxRunCnt; i++) {
00892 if (reExec->reExecProc[i].procExecState == execState &&
00893 strcmp (reExec->reExecProc[i].ruleExecSubmitInp.ruleExecId,
00894 ruleExecIdStr) == 0) {
00895 return 1;
00896 }
00897 }
00898 return 0;
00899 }
00900
00901 int
00902 chkAndUpdateResc (rsComm_t *rsComm)
00903 {
00904 time_t curTime;
00905 int status = 0;
00906
00907 curTime = time (NULL);
00908
00909 if (LastRescUpdateTime > curTime) {
00910 LastRescUpdateTime = curTime;
00911 return 0;
00912 }
00913
00914 if (curTime >= LastRescUpdateTime + RESC_UPDATE_TIME) {
00915
00916 resc_mgr.init_from_catalog( rsComm );
00917
00918 LastRescUpdateTime = curTime;
00919 return status;
00920 } else {
00921 return 0;
00922 }
00923 }
00924
00925 int
00926 fillExecSubmitInp (ruleExecSubmitInp_t *ruleExecSubmitInp, char *exeStatus,
00927 char *exeTime, char *ruleExecId, char *reiFilePath, char *ruleName,
00928 char *userName, char *exeAddress, char *exeFrequency, char *priority,
00929 char *estimateExeTime, char *notificationAddr)
00930 {
00931 int status;
00932 #ifndef USE_BOOST_FS
00933 struct stat statbuf;
00934 #endif
00935 int fd;
00936 rodsLong_t st_size;
00937
00938 rstrcpy (ruleExecSubmitInp->reiFilePath, reiFilePath, MAX_NAME_LEN);
00939 #ifdef USE_BOOST_FS
00940 path p (ruleExecSubmitInp->reiFilePath);
00941 if (!exists (p)) {
00942 #else
00943 if (stat (ruleExecSubmitInp->reiFilePath, &statbuf) < 0) {
00944 #endif
00945 status = UNIX_FILE_STAT_ERR - errno;
00946 rodsLogError (LOG_ERROR, status,
00947 "fillExecSubmitInp: stat error for rei file %s, id %s rule %s",
00948 ruleExecSubmitInp->reiFilePath, ruleExecId, ruleName);
00949
00950 return status;
00951 }
00952
00953 #ifdef USE_BOOST_FS
00954 st_size = file_size (p);
00955 #else
00956 st_size = statbuf.st_size;
00957 #endif
00958 if (st_size > ruleExecSubmitInp->packedReiAndArgBBuf->len) {
00959 if (ruleExecSubmitInp->packedReiAndArgBBuf->buf != NULL)
00960 free (ruleExecSubmitInp->packedReiAndArgBBuf->buf);
00961 ruleExecSubmitInp->packedReiAndArgBBuf->buf =
00962 malloc ((int) st_size);
00963 ruleExecSubmitInp->packedReiAndArgBBuf->len = st_size;
00964 }
00965
00966 fd = open (ruleExecSubmitInp->reiFilePath, O_RDONLY,0);
00967 if (fd < 0) {
00968 status = UNIX_FILE_OPEN_ERR - errno;
00969 rodsLog (LOG_ERROR,
00970 "fillExecSubmitInp: open error for rei file %s, status = %d",
00971 ruleExecSubmitInp->reiFilePath, status);
00972 return (status);
00973 }
00974
00975 status = read (fd, ruleExecSubmitInp->packedReiAndArgBBuf->buf,
00976 ruleExecSubmitInp->packedReiAndArgBBuf->len);
00977
00978 close (fd);
00979 if (status != (int) st_size) {
00980 if (status < 0) {
00981 status = UNIX_FILE_READ_ERR - errno;
00982 rodsLog (LOG_ERROR,
00983 "fillExecSubmitInp: read error for file %s, status = %d",
00984 ruleExecSubmitInp->reiFilePath, status);
00985 } else {
00986 rodsLog (LOG_ERROR,
00987 "fillExecSubmitInp:read error for %s,toRead %d, read %d",
00988 ruleExecSubmitInp->reiFilePath,
00989 ruleExecSubmitInp->packedReiAndArgBBuf->len, status);
00990 return (SYS_COPY_LEN_ERR);
00991 }
00992 }
00993
00994 rstrcpy (ruleExecSubmitInp->exeTime, exeTime, NAME_LEN);
00995 rstrcpy (ruleExecSubmitInp->exeStatus, exeStatus, NAME_LEN);
00996 rstrcpy (ruleExecSubmitInp->ruleExecId, ruleExecId, NAME_LEN);
00997
00998 rstrcpy (ruleExecSubmitInp->ruleName, ruleName, META_STR_LEN);
00999 rstrcpy (ruleExecSubmitInp->userName, userName, NAME_LEN);
01000 rstrcpy (ruleExecSubmitInp->exeAddress, exeAddress, NAME_LEN);
01001 rstrcpy (ruleExecSubmitInp->exeFrequency, exeFrequency, NAME_LEN);
01002 rstrcpy (ruleExecSubmitInp->priority, priority, NAME_LEN);
01003 rstrcpy (ruleExecSubmitInp->estimateExeTime, estimateExeTime, NAME_LEN);
01004 rstrcpy (ruleExecSubmitInp->notificationAddr, notificationAddr, NAME_LEN);
01005
01006 return 0;
01007 }
01008
01009 int
01010 reServerSingleExec (rsComm_t *rsComm, char *ruleExecId, int jobType)
01011 {
01012 reExecProc_t reExecProc;
01013 int status;
01014 sqlResult_t *ruleName, *reiFilePath, *userName, *exeAddress,
01015 *exeTime, *exeFrequency, *priority, *lastExecTime, *exeStatus,
01016 *estimateExeTime, *notificationAddr;
01017 genQueryOut_t *genQueryOut = NULL;
01018
01019 bzero (&reExecProc, sizeof (reExecProc));
01020
01021 reExecProc.reComm.proxyUser = rsComm->proxyUser;
01022 reExecProc.reComm.myEnv = rsComm->myEnv;
01023 reExecProc.ruleExecSubmitInp.packedReiAndArgBBuf =
01024 (bytesBuf_t *) calloc (1, sizeof (bytesBuf_t));
01025 reExecProc.procExecState = RE_PROC_RUNNING;
01026 reExecProc.jobType = jobType;
01027
01028 status = getReInfoById (rsComm, ruleExecId, &genQueryOut);
01029 if (status < 0) {
01030 rodsLog (LOG_ERROR,
01031 "reServerSingleExec: getReInfoById error for %s, status = %d",
01032 ruleExecId, status);
01033 return status;
01034 }
01035
01036 bzero (&reExecProc, sizeof (reExecProc));
01037
01038 reExecProc.reComm.proxyUser = rsComm->proxyUser;
01039 reExecProc.reComm.myEnv = rsComm->myEnv;
01040 reExecProc.ruleExecSubmitInp.packedReiAndArgBBuf =
01041 (bytesBuf_t *) calloc (1, sizeof (bytesBuf_t));
01042 reExecProc.procExecState = RE_PROC_RUNNING;
01043 reExecProc.jobType = jobType;
01044
01045 if ((ruleName = getSqlResultByInx (genQueryOut,
01046 COL_RULE_EXEC_NAME)) == NULL) {
01047 rodsLog (LOG_NOTICE,
01048 "reServerSingleExec: getSqlResultByInx for EXEC_NAME failed");
01049 return (UNMATCHED_KEY_OR_INDEX);
01050 }
01051 if ((reiFilePath = getSqlResultByInx (genQueryOut,
01052 COL_RULE_EXEC_REI_FILE_PATH)) == NULL) {
01053 rodsLog (LOG_NOTICE,
01054 "reServerSingleExec: getSqlResultByInx for REI_FILE_PATH failed");
01055 return (UNMATCHED_KEY_OR_INDEX);
01056 }
01057 if ((userName = getSqlResultByInx (genQueryOut,
01058 COL_RULE_EXEC_USER_NAME)) == NULL) {
01059 rodsLog (LOG_NOTICE,
01060 "reServerSingleExec: getSqlResultByInx for USER_NAME failed");
01061 return (UNMATCHED_KEY_OR_INDEX);
01062 }
01063 if ((exeAddress = getSqlResultByInx (genQueryOut,
01064 COL_RULE_EXEC_ADDRESS)) == NULL) {
01065 rodsLog (LOG_NOTICE,
01066 "reServerSingleExec: getSqlResultByInx for EXEC_ADDRESS failed");
01067 return (UNMATCHED_KEY_OR_INDEX);
01068 }
01069 if ((exeTime = getSqlResultByInx (genQueryOut,
01070 COL_RULE_EXEC_TIME)) == NULL) {
01071 rodsLog (LOG_NOTICE,
01072 "reServerSingleExec: getSqlResultByInx for EXEC_TIME failed");
01073 return (UNMATCHED_KEY_OR_INDEX);
01074 }
01075 if ((exeFrequency = getSqlResultByInx (genQueryOut,
01076 COL_RULE_EXEC_FREQUENCY)) == NULL) {
01077 rodsLog (LOG_NOTICE,
01078 "reServerSingleExec:getResultByInx for RULE_EXEC_FREQUENCY failed");
01079 return (UNMATCHED_KEY_OR_INDEX);
01080 }
01081 if ((priority = getSqlResultByInx (genQueryOut,
01082 COL_RULE_EXEC_PRIORITY)) == NULL) {
01083 rodsLog (LOG_NOTICE,
01084 "reServerSingleExec: getSqlResultByInx for PRIORITY failed");
01085 return (UNMATCHED_KEY_OR_INDEX);
01086 }
01087 if ((lastExecTime = getSqlResultByInx (genQueryOut,
01088 COL_RULE_EXEC_LAST_EXE_TIME)) == NULL) {
01089 rodsLog (LOG_NOTICE,
01090 "reServerSingleExec: getSqlResultByInx for LAST_EXE_TIME failed");
01091 return (UNMATCHED_KEY_OR_INDEX);
01092 }
01093 if ((exeStatus = getSqlResultByInx (genQueryOut,
01094 COL_RULE_EXEC_STATUS)) == NULL) {
01095 rodsLog (LOG_NOTICE,
01096 "reServerSingleExec: getSqlResultByInx for EXEC_STATUS failed");
01097 return (UNMATCHED_KEY_OR_INDEX);
01098 }
01099 if ((estimateExeTime = getSqlResultByInx (genQueryOut,
01100 COL_RULE_EXEC_ESTIMATED_EXE_TIME)) == NULL) {
01101 rodsLog (LOG_NOTICE,
01102 "reServerSingleExec: getResultByInx for ESTIMATED_EXE_TIME failed");
01103 return (UNMATCHED_KEY_OR_INDEX);
01104 }
01105 if ((notificationAddr = getSqlResultByInx (genQueryOut,
01106 COL_RULE_EXEC_NOTIFICATION_ADDR)) == NULL) {
01107 rodsLog (LOG_NOTICE,
01108 "reServerSingleExec:getResultByInx for NOTIFICATION_ADDR failed");
01109 return (UNMATCHED_KEY_OR_INDEX);
01110 }
01111
01112 status = fillExecSubmitInp (&reExecProc.ruleExecSubmitInp,
01113 exeStatus->value, exeTime->value, ruleExecId, reiFilePath->value,
01114 ruleName->value, userName->value, exeAddress->value, exeFrequency->value,
01115 priority->value, estimateExeTime->value, notificationAddr->value);
01116
01117 if (status < 0) return status;
01118 seedRandom ();
01119 status = runRuleExec (&reExecProc);
01120 postProcRunRuleExec (rsComm, &reExecProc);
01121
01122 freeGenQueryOut( &genQueryOut );
01123
01124 return (reExecProc.status);
01125 }
01126