Esempio n. 1
0
int 
freeRuleExecInfoInternals(ruleExecInfo_t *rs, int freeSpeialStructFlag)
{
  if (rs->msParamArray != NULL && (freeSpeialStructFlag & FREE_MS_PARAM) > 0) {
    clearMsParamArray (rs->msParamArray, 1);
    free (rs->msParamArray);
  }

  if (rs->doinp != NULL && (freeSpeialStructFlag & FREE_DOINP) > 0) {
     clearDataObjInp (rs->doinp);
     free (rs->doinp);
  }
 
  if (rs->doi != NULL) 
    freeAllDataObjInfo(rs->doi);
  if (rs->rgi != NULL)
    freeRescGrpInfo(rs->rgi);
  if (rs->uoic != NULL)
    freeUserInfo(rs->uoic);
  if (rs->uoip != NULL)
    freeUserInfo(rs->uoip);
  if (rs->coi != NULL)
    freeCollInfo(rs->coi);
#if 0	/* XXXXX deplicate rgio */
  if (rs->rgio != NULL)
    freeRescGrpInfo(rs->rgio);
#endif
  if (rs->uoio != NULL)
    freeUserInfo(rs->uoio);
  if (rs->condInputData != NULL) 
    freeKeyValPairStruct(rs->condInputData);
  if (rs->next != NULL) 
    freeRuleExecInfoStruct(rs->next, freeSpeialStructFlag);
  return(0);
}
Esempio n. 2
0
int 
freeRescGrpInfo( rescGrpInfo_t *rs)
{
  if (rs->next != NULL) 
    freeRescGrpInfo(rs->next);
  free(rs);
  return(0);
}
Esempio n. 3
0
int
getNumThreads (rsComm_t *rsComm, rodsLong_t dataSize, int inpNumThr,
               keyValPair_t *condInput, char *destRescName, char *srcRescName)
{
    ruleExecInfo_t rei;
    dataObjInp_t doinp;
    int status;
    int numDestThr = -1;
    int numSrcThr = -1;
    rescGrpInfo_t *rescGrpInfo;

    if (inpNumThr == NO_THREADING)
        return 0;

    if (dataSize < 0)
        return 0;

    if (dataSize <= MIN_SZ_FOR_PARA_TRAN) {
        if (inpNumThr > 0) {
            inpNumThr = 1;
        } else {
            return 0;
        }
    }

    if (getValByKey (condInput, NO_PARA_OP_KW) != NULL) {
        /* client specify no para opr */
        return (1);
    }

#ifndef PARA_OPR
    return (1);
#endif

    memset (&doinp, 0, sizeof (doinp));
    doinp.numThreads = inpNumThr;

    doinp.dataSize = dataSize;

    initReiWithDataObjInp (&rei, rsComm, &doinp);

    if (destRescName != NULL) {
        rescGrpInfo = NULL;
        status = resolveAndQueResc (destRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numDestThr = rei.status;
                if (numDestThr == 0) {
                    return 0;
                } else if (numDestThr == 1 && srcRescName == NULL &&
                           isLocalHost (rescGrpInfo->rescInfo->rescLoc)) {
                    /* one thread and resouce on local host */
                    return 0;
                }
            }
        }
    }

    if (srcRescName != NULL) {
        if (numDestThr > 0 && strcmp (destRescName, srcRescName) == 0)
            return numDestThr;
        rescGrpInfo = NULL;
        status = resolveAndQueResc (srcRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numSrcThr = rei.status;
                if (numSrcThr == 0) return 0;
            }
        }
    }

    /* At this point, number of threads for both source and destination
       have been set based on acSetNumThreads policy point, and neither
       of them are set to 0 (to turn off threading). If both numDestThr
       and numSrcThr are set, choose the smallest one. The reasoning is
       that acSetNumThreads is used by a site to limit the default
       maximum parallel threads, so we should honor the most restrictive
       setting. */
    if (numDestThr > 0 && numSrcThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else if (numDestThr < numSrcThr) {
            return numDestThr;
        } else {
            return numSrcThr;
        }
    }
    if (numDestThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numDestThr;
        }
    }
    if (numSrcThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numSrcThr;
        }
    }
    /* should not be here. do one with no resource */
    rei.rgi = NULL;
    status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
    if (status < 0) {
        rodsLog (LOG_ERROR,
                 "getNumThreads: acGetNumThreads error, status = %d",
                 status);
        return 0;
    } else {
        if (rei.status > 0)
            return rei.status;
        else
            return 0;
    }
}
Esempio n. 4
0
int
getNumThreads (rsComm_t *rsComm, rodsLong_t dataSize, int inpNumThr,
               keyValPair_t *condInput, char *destRescName, char *srcRescName)
{
    ruleExecInfo_t rei;
    dataObjInp_t doinp;
    int status;
    int numDestThr = -1;
    int numSrcThr = -1;
    rescGrpInfo_t *rescGrpInfo;

    if (inpNumThr == NO_THREADING)
        return 0;

    if (dataSize < 0)
        return 0;

    if (dataSize <= MIN_SZ_FOR_PARA_TRAN) {
        if (inpNumThr > 0) {
            inpNumThr = 1;
        } else {
            return 0;
        }
    }

    if (getValByKey (condInput, NO_PARA_OP_KW) != NULL) {
        /* client specify no para opr */
        return (1);
    }

#ifndef PARA_OPR
    return (1);
#endif

    memset (&doinp, 0, sizeof (doinp));
    doinp.numThreads = inpNumThr;

    doinp.dataSize = dataSize;

    initReiWithDataObjInp (&rei, rsComm, &doinp);

    if (destRescName != NULL) {
        rescGrpInfo = NULL;
        status = resolveAndQueResc (destRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numDestThr = rei.status;
                if (numDestThr == 0) {
                    return 0;
                } else if (numDestThr == 1 && srcRescName == NULL &&
                           isLocalHost (rescGrpInfo->rescInfo->rescLoc)) {
                    /* one thread and resouce on local host */
                    return 0;
                }
            }
        }
    }

    if (srcRescName != NULL) {
        if (numDestThr > 0 && strcmp (destRescName, srcRescName) == 0)
            return numDestThr;
        rescGrpInfo = NULL;
        status = resolveAndQueResc (srcRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numSrcThr = rei.status;
                if (numSrcThr == 0) return 0;
            }
        }
    }

    if (numDestThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numDestThr;
        }
    }
    if (numSrcThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numSrcThr;
        }
    }
    /* should not be here. do one with no resource */
    rei.rgi = NULL;
    status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
    if (status < 0) {
        rodsLog (LOG_ERROR,
                 "getNumThreads: acGetNumThreads error, status = %d",
                 status);
        return 0;
    } else {
        if (rei.status > 0)
            return rei.status;
        else
            return 0;
    }
}