Пример #1
0
int getRescGrpForCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp, rescGrpInfo_t** myRescGrpInfo ) {
    int            status;
    ruleExecInfo_t rei;

    /* query rcat for resource info and sort it */
    initReiWithDataObjInp( &rei, rsComm, dataObjInp );

    if ( dataObjInp->oprType == REPLICATE_OPR ) { // JMC - backport 4660
        status = applyRule( "acSetRescSchemeForRepl", NULL, &rei, NO_SAVE_REI );

    }
    else {
        status = applyRule( "acSetRescSchemeForCreate", NULL, &rei, NO_SAVE_REI );

    }

    if ( status < 0 ) {
        if ( rei.status < 0 ) {
            status = rei.status;
        }

        rodsLog( LOG_NOTICE, "getRescGrpForCreate:acSetRescSchemeForCreate error for %s,status=%d",
                 dataObjInp->objPath, status );

        return ( status );
    }

    if ( rei.rgi == NULL ) {
        /* def resc group has not been initialized yet */
        // JMC - legacy resource status = setDefaultResc (rsComm, NULL, NULL, &dataObjInp->condInput, myRescGrpInfo );
        //if( !(*myRescGrpInfo) ) {
        ( *myRescGrpInfo ) = new rescGrpInfo_t;
        bzero( ( *myRescGrpInfo ), sizeof( rescGrpInfo_t ) );
        ( *myRescGrpInfo )->rescInfo = new rescInfo_t;
        //}

        irods::error set_err = irods::set_default_resource( rsComm, "", "", &dataObjInp->condInput, *( *myRescGrpInfo ) );
        if ( !set_err.ok() ) {
            irods::log( PASS( set_err ) );
            return SYS_INVALID_RESC_INPUT;
        }

    }
    else {
        *myRescGrpInfo = rei.rgi;
    }

    status = setRescQuota( rsComm, dataObjInp->objPath, myRescGrpInfo, dataObjInp->dataSize );

    if ( status == SYS_RESC_QUOTA_EXCEEDED ) {
        return SYS_RESC_QUOTA_EXCEEDED;
    }

    return 0; // JMC - should this be 1 per above block?
}
Пример #2
0
int getRescForCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp, std::string& _resc_name ) {
    int            status;
    ruleExecInfo_t rei;

    /* query rcat for resource info and sort it */
    initReiWithDataObjInp( &rei, rsComm, dataObjInp );

    if ( dataObjInp->oprType == REPLICATE_OPR ) { // JMC - backport 4660
        status = applyRule( "acSetRescSchemeForRepl", NULL, &rei, NO_SAVE_REI );

    }
    else {
        status = applyRule( "acSetRescSchemeForCreate", NULL, &rei, NO_SAVE_REI );

    }

    if ( status < 0 ) {
        if ( rei.status < 0 ) {
            status = rei.status;
        }

        rodsLog( LOG_NOTICE, "getRescForCreate:acSetRescSchemeForCreate error for %s,status=%d",
                 dataObjInp->objPath, status );

        return status;
    }

    // get resource name
    if ( !strlen( rei.rescName ) ) {
        irods::error set_err = irods::set_default_resource( rsComm, "", "", &dataObjInp->condInput, _resc_name );

        if ( !set_err.ok() ) {
            irods::log( PASS( set_err ) );
            return SYS_INVALID_RESC_INPUT;
        }
    }
    else {
        _resc_name = rei.rescName;
    }

#if 0	// #1472
    status = setRescQuota( rsComm, dataObjInp->objPath, myRescGrpInfo, dataObjInp->dataSize );

    if ( status == SYS_RESC_QUOTA_EXCEEDED ) {
        if ( rei.rgi == NULL ) {
            delete( *myRescGrpInfo )->rescInfo;
            delete( *myRescGrpInfo );
            *myRescGrpInfo = NULL;
        }
        return SYS_RESC_QUOTA_EXCEEDED;
    }
#endif

    return 0; // JMC - should this be 1 per above block?
}