Beispiel #1
0
int
ngisSSHjobPBSprepare(ngisSSHjob_t *job)
{
    int result;
    ngisLog_t *log;
    static const char fName[] = "ngisSSHjobPBSprepare";

    NGIS_ASSERT(job != NULL);

    log = job->ngsj_log;

    /* Common? */
    result = ngisSSHjobPrepareCommon(job);
    if (result == 0) {
        ngisErrorPrint(log, fName, "Can't prepare.\n");
        return 0;
    }

    result = ngisSSHjobFunctionPush(job, ngislSSHjobPBScreateScript);
    if (result == 0) {
        ngisErrorPrint(log, fName, 
            "Can't register function for create PBS script.\n");
        return 0;
    }

    result = ngisSSHjobFunctionPush(job, ngisSSHjobStagingScript);
    if (result == 0) {
        ngisErrorPrint(log, fName, 
            "Can't register function for transfer PBS script.\n");
        return 0;
    }

    if ((job->ngsj_attributes->ngsja_jobBackend == NGIS_BACKEND_NORMAL) && 
        (job->ngsj_attributes->ngsja_count > 1)) {
        /* For Array Job */
        result = ngisSSHjobFunctionPush(job,
            ngisSSHjobStagingScriptForArrayJob);
        if (result == 0) {
            ngisErrorPrint(log, fName,
                "Can't register function "
                "for transfer SGE script for array job.\n");
            return 0;
        }
    }

    result = ngisSSHjobFunctionPush(job, ngislSSHjobPBSsubmitStart);
    if (result == 0) {
        ngisErrorPrint(log, fName, 
            "Can't register function for transfer PBS script.\n");
        return 0;
    }

    return 1;
}
Beispiel #2
0
int
ngisSSHjobProcessAfterExit(
    ngisSSHjob_t *job)
{
    int result;
    ngisLog_t *log = NULL;
    int i;
    ngisExecutable_t *exe = NULL;
    ngisExecutableStatus_t jobStatus;
    static const char fName[] = "ngisSSHjobProcessAfterExit";
    
    NGIS_ASSERT(job != NULL);

    log  = job->ngsj_log;
    jobStatus = ngisSSHjobGetStatus(job);

    ngisSSHjobFunctionReset(job);
    job->ngsj_iExecutables = 0;

    /* Stop polling */
    if (ngisCallbackIsValid(job->ngsj_timerCallback)) {
        ngisCallbackCancel(job->ngsj_timerCallback);
        job->ngsj_timerCallback = NULL;
    }

    if (job->ngsj_afterExit != 0) {
        goto error;
    }
    job->ngsj_afterExit = 1;

    if ((job->ngsj_attributes->ngsja_redirectEnable != 0) &&
        (jobStatus > NGIS_EXECUTABLE_STATUS_SUBMITTING)   &&
        (jobStatus < NGIS_EXECUTABLE_STATUS_STAGEOUT)) {

        for (i = 0;i < job->ngsj_nExecutables;++i) {
            exe = &job->ngsj_executables[i];
            if (exe->nge_status == NGIS_EXECUTABLE_STATUS_FAILED) {
                result = ngisSSHjobExecutableSetStatus(
                    job, exe, NGIS_EXECUTABLE_STATUS_FAILED_STAGEOUT);
            } else {
                result = ngisSSHjobExecutableSetStatus(
                    job, exe, NGIS_EXECUTABLE_STATUS_STAGEOUT);
            }
            if (result == 0) {
                ngisErrorPrint(log, fName, "Can't set status.\n");            
                goto error;
            }
        }

        /* Redirect outerr */
        result = ngisSSHjobFunctionPush(job, ngislSSHjobTransferStdout);
        if (result == 0) {
            ngisErrorPrint(log, fName,
                "Can't register the function for transfer STDOUT.\n");
            goto error;
        }
        result = ngisSSHjobFunctionPush(job, ngislSSHjobTransferStderr);
        if (result == 0) {
            ngisErrorPrint(log, fName,
                "Can't register the function for transfer STDERR.\n");
            goto error;
        }
    } 

    result = ngisSSHjobFunctionPush(job, ngisSSHjobDone);
    if (result == 0) {
        ngisErrorPrint(log, fName,
            "Can't register the function for transfer job done.\n");
        goto error;
    }

    result = ngisSSHjobFunctionPop(job);
    if (result == 0) {
        ngisErrorPrint(NULL, fName,
            "Fails the registered function.\n");
        return 0;
    }
    
    return 1;
error:
    result = ngisSSHjobDone(job);
    if (result == 0) {
        ngisErrorPrint(NULL, fName, "Can't done the job.\n");
    }
    return 0;
}