Ejemplo n.º 1
0
int
initDataObjInfoWithInp (dataObjInfo_t *dataObjInfo, dataObjInp_t *dataObjInp)
{
    char *rescName, *dataType, *filePath;
    keyValPair_t *condInput;

    condInput = &dataObjInp->condInput;

    memset (dataObjInfo, 0, sizeof (dataObjInfo_t));
    rstrcpy (dataObjInfo->objPath, dataObjInp->objPath, MAX_NAME_LEN);
    rescName = getValByKey (condInput, RESC_NAME_KW);
    if (rescName != NULL) {
        rstrcpy (dataObjInfo->rescName, rescName, LONG_NAME_LEN);
    }
    snprintf (dataObjInfo->dataMode, SHORT_STR_LEN, "%d", dataObjInp->createMode);

    dataType = getValByKey (condInput, DATA_TYPE_KW);
    if (dataType != NULL) {
        rstrcpy (dataObjInfo->dataType, dataType, NAME_LEN);
    } else {
        rstrcpy (dataObjInfo->dataType, "generic", NAME_LEN);
    }

    filePath = getValByKey (condInput, FILE_PATH_KW);
    if (filePath != NULL) {
        rstrcpy (dataObjInfo->filePath, filePath, MAX_NAME_LEN);
    }

#ifdef FILESYSTEM_META
    /* copy over the source file metadata if provided */
    copyFilesystemMetadata(condInput, &dataObjInfo->condInput);
#endif /* FILESYSTEM_META */

    return (0);
}
Ejemplo n.º 2
0
// =-=-=-=-=-=-=-
// function which determines resource name based on
// keyval pair and a given string
    error resolve_resource_name(
        const std::string& _resc_name,
        keyValPair_t* _cond_input,
        std::string& _out ) {
        if ( _resc_name.empty() ) {
            char* name = 0;
            name = getValByKey( _cond_input, BACKUP_RESC_NAME_KW );
            if ( name ) {
                _out = std::string( name );
                return SUCCESS();
            }

            name = getValByKey( _cond_input, DEST_RESC_NAME_KW );
            if ( name ) {
                _out = std::string( name );
                return SUCCESS();
            }

            name = getValByKey( _cond_input, DEF_RESC_NAME_KW );
            if ( name ) {
                _out = std::string( name );
                return SUCCESS();
            }

            return ERROR( INT_RESC_STATUS_DOWN, "failed to resolve resource name" );

        }
        else {
            _out = _resc_name;
            return SUCCESS();
        }

    } // resolve_resource_name
Ejemplo n.º 3
0
int
_rsProcStat (rsComm_t *rsComm, procStatInp_t *procStatInp,
             genQueryOut_t **procStatOut)
{
    int status;
    rodsServerHost_t *rodsServerHost;
    int remoteFlag;
    rodsHostAddr_t addr;
    procStatInp_t myProcStatInp;
    char *tmpStr;

    if (getValByKey (&procStatInp->condInput, ALL_KW) != NULL) {
        status = _rsProcStatAll (rsComm, procStatInp, procStatOut);
        return status;
    }
    if (getValByKey (&procStatInp->condInput, EXEC_LOCALLY_KW) != NULL) {
        status = localProcStat (rsComm, procStatInp, procStatOut);
        return status;
    }

    bzero (&addr, sizeof (addr));
    bzero (&myProcStatInp, sizeof (myProcStatInp));
    if (*procStatInp->addr != '\0') {	/* given input addr */
        rstrcpy (addr.hostAddr, procStatInp->addr, LONG_NAME_LEN);
        remoteFlag = resolveHost (&addr, &rodsServerHost);
    } else if ((tmpStr = getValByKey (&procStatInp->condInput, RESC_NAME_KW))
               != NULL) {
        rescGrpInfo_t *rescGrpInfo = NULL;
        status = _getRescInfo (rsComm, tmpStr, &rescGrpInfo);
        if (status < 0) {
            rodsLog (LOG_ERROR,
                     "_rsProcStat: _getRescInfo of %s error. stat = %d",
                     tmpStr, status);
            return status;
        }
        rstrcpy (procStatInp->addr, rescGrpInfo->rescInfo->rescLoc, NAME_LEN);
        rodsServerHost = (rodsServerHost_t*)rescGrpInfo->rescInfo->rodsServerHost;
        if (rodsServerHost == NULL) {
            remoteFlag = SYS_INVALID_SERVER_HOST;
        } else {
            remoteFlag = rodsServerHost->localFlag;
        }
    } else {
        /* do the IES server */
        remoteFlag = getRcatHost (MASTER_RCAT, NULL, &rodsServerHost);
    }
    if (remoteFlag < 0) {
        rodsLog (LOG_ERROR,
                 "_rsProcStat: getRcatHost() failed. erro=%d", remoteFlag);
        return (remoteFlag);
    } else if (remoteFlag == REMOTE_HOST) {
        addKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW, "");
        status = remoteProcStat (rsComm, &myProcStatInp, procStatOut,
                                 rodsServerHost);
        rmKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW);
    } else {
        status = localProcStat (rsComm, procStatInp, procStatOut);
    }
    return status;
}
Ejemplo n.º 4
0
int
rsRsyncFileToData( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {

    char * fileChksumStr = getValByKey( &dataObjInp->condInput, RSYNC_CHKSUM_KW );

    if ( fileChksumStr == NULL ) {
        rodsLog( LOG_ERROR,
                 "rsRsyncFileToData: RSYNC_CHKSUM_KW input is missing" );
        return CHKSUM_EMPTY_IN_STRUCT_ERR;
    }

    addKeyVal( &dataObjInp->condInput, ORIG_CHKSUM_KW, fileChksumStr );

    // =-=-=-=-=-=-=-
    // determine the resource hierarchy if one is not provided
    if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
        std::string       hier;
        irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION,
                           rsComm, dataObjInp, hier );
        if ( !ret.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " :: failed in irods::resolve_resource_hierarchy for [";
            msg << dataObjInp->objPath << "]";
            irods::log( PASSMSG( msg.str(), ret ) );
            return ret.code();
        }

        // =-=-=-=-=-=-=-
        // we resolved the redirect and have a host, set the hier str for subsequent
        // api calls, etc.
        addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

    } // if keyword

    char *dataObjChksumStr = NULL;
    dataObjInfo_t *dataObjInfoHead = NULL;
    int status = _rsDataObjChksum( rsComm, dataObjInp, &dataObjChksumStr,
                                   &dataObjInfoHead );

    if ( status < 0 && status != CAT_NO_ACCESS_PERMISSION &&
            status != CAT_NO_ROWS_FOUND ) {
        /* XXXXX CAT_NO_ACCESS_PERMISSION mean the chksum was calculated but
         * cannot be registered. But the chksum value is OK.
         */
        rodsLog( LOG_ERROR,
                 "rsRsyncFileToData: _rsDataObjChksum of %s error. status = %d",
                 dataObjInp->objPath, status );
    }

    freeAllDataObjInfo( dataObjInfoHead );
    if ( dataObjChksumStr != NULL &&
            strcmp( dataObjChksumStr, fileChksumStr ) == 0 ) {
        free( dataObjChksumStr );
        return 0;
    }
    free( dataObjChksumStr );
    return SYS_SVR_TO_CLI_PUT_ACTION;
}
Ejemplo n.º 5
0
int
fillL1desc( int l1descInx, dataObjInp_t *dataObjInp,
            dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize ) {
    keyValPair_t *condInput;
    char *tmpPtr;


    char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
    if ( dataObjInfo->rescHier[0] == '\0' && resc_hier ) {
        snprintf( dataObjInfo->rescHier, sizeof( dataObjInfo->rescHier ), "%s", resc_hier );
    }


    condInput = &dataObjInp->condInput;
    char* in_pdmo = getValByKey( condInput, IN_PDMO_KW );
    if ( in_pdmo != NULL ) {
        rstrcpy( L1desc[l1descInx].in_pdmo, in_pdmo, MAX_NAME_LEN );
    }
    else {
        rstrcpy( L1desc[l1descInx].in_pdmo, "", MAX_NAME_LEN );
    }

    if ( dataObjInp != NULL ) {
        /* always repl the .dataObjInp */
        L1desc[l1descInx].dataObjInp = ( dataObjInp_t* )malloc( sizeof( dataObjInp_t ) );
        replDataObjInp( dataObjInp, L1desc[l1descInx].dataObjInp );
        L1desc[l1descInx].dataObjInpReplFlag = 1;
    }
    else {
        /* XXXX this can be a problem in rsDataObjClose */
        L1desc[l1descInx].dataObjInp = NULL;
    }

    L1desc[l1descInx].dataObjInfo = dataObjInfo;
    if ( dataObjInp != NULL ) {
        L1desc[l1descInx].oprType = dataObjInp->oprType;
    }
    L1desc[l1descInx].replStatus = replStatus;
    L1desc[l1descInx].dataSize = dataSize;
    if ( condInput != NULL && condInput->len > 0 ) {
        if ( ( tmpPtr = getValByKey( condInput, REG_CHKSUM_KW ) ) != NULL ) {
            L1desc[l1descInx].chksumFlag = REG_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
        else if ( ( tmpPtr = getValByKey( condInput, VERIFY_CHKSUM_KW ) ) !=
                  NULL ) {
            L1desc[l1descInx].chksumFlag = VERIFY_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
    }
#ifdef LOG_TRANSFERS
    ( void )gettimeofday( &L1desc[l1descInx].openStartTime,
                          ( struct timezone * )0 );
#endif
    return 0;
}
Ejemplo n.º 6
0
/* resolveDataObjReplStatus - a dirty copy may be deleted leaving no
 * dirty copy. In that case, pick the newest copy and mark it dirty
 */
int
resolveDataObjReplStatus( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp ) {
    int status;
    dataObjInfo_t *dataObjInfoHead = NULL;
    dataObjInfo_t *newestDataObjInfo = NULL;
    dataObjInfo_t *tmpDataObjInfo;

    if ( getValByKey( &dataObjUnlinkInp->condInput, RESC_NAME_KW ) == NULL &&
            getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) == NULL ) {
        return 0;
    }
    status = getDataObjInfo( rsComm, dataObjUnlinkInp,
                             &dataObjInfoHead, ACCESS_DELETE_OBJECT, 1 );

    if ( status < 0 ) {
        return status;
    }

    tmpDataObjInfo = dataObjInfoHead;
    while ( tmpDataObjInfo != NULL ) {
        if ( tmpDataObjInfo->replStatus == 0 ) {
            if ( newestDataObjInfo == NULL ) {
                newestDataObjInfo = tmpDataObjInfo;
            }
            else if ( atoi( tmpDataObjInfo->dataModify ) >
                      atoi( newestDataObjInfo->dataModify ) ) {
                newestDataObjInfo = tmpDataObjInfo;
            }
        }
        else {
            newestDataObjInfo = NULL;
            break;
        }
        tmpDataObjInfo = tmpDataObjInfo->next;
    }

    /* modify the repl status */
    if ( newestDataObjInfo != NULL ) {
        keyValPair_t regParam;
        char tmpStr[MAX_NAME_LEN];
        modDataObjMeta_t modDataObjMetaInp;

        memset( &regParam, 0, sizeof( regParam ) );
        memset( &modDataObjMetaInp, 0, sizeof( modDataObjMetaInp ) );
        snprintf( tmpStr, MAX_NAME_LEN, "%d", NEWLY_CREATED_COPY );
        addKeyVal( &regParam, REPL_STATUS_KW, tmpStr );
        modDataObjMetaInp.dataObjInfo = newestDataObjInfo;
        modDataObjMetaInp.regParam = &regParam;

        status = rsModDataObjMeta( rsComm, &modDataObjMetaInp );

        clearKeyVal( &regParam );
    }
    freeAllDataObjInfo( dataObjInfoHead );
    return status;
}
Ejemplo n.º 7
0
int
_rsRmCollRecur( rsComm_t *rsComm, collInp_t *rmCollInp,
                collOprStat_t **collOprStat ) {
    int status;
    ruleExecInfo_t rei;
    int trashPolicy;
    dataObjInfo_t *dataObjInfo = NULL;
    /* check for specColl and permission */
    status = resolvePathInSpecColl( rsComm, rmCollInp->collName,
                                    WRITE_COLL_PERM, 0, &dataObjInfo );

    if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
        return status;
    }
    if ( status == COLL_OBJ_T && dataObjInfo->specColl != NULL &&
            dataObjInfo->specColl->collClass == LINKED_COLL ) {
        rstrcpy( rmCollInp->collName, dataObjInfo->objPath,
                 MAX_NAME_LEN );
        free( dataObjInfo->specColl );
        dataObjInfo->specColl = NULL;
    }
    if ( status != COLL_OBJ_T || dataObjInfo->specColl == NULL ) {
        /* a normal coll */
        if ( rmCollInp->oprType != UNREG_OPR &&
                getValByKey( &rmCollInp->condInput, FORCE_FLAG_KW ) == NULL &&
                getValByKey( &rmCollInp->condInput, RMTRASH_KW ) == NULL &&
                getValByKey( &rmCollInp->condInput, ADMIN_RMTRASH_KW ) == NULL ) {
            initReiWithDataObjInp( &rei, rsComm, NULL );
            status = applyRule( "acTrashPolicy", NULL, &rei, NO_SAVE_REI );
            trashPolicy = rei.status;
            if ( trashPolicy != NO_TRASH_CAN ) {
                status = rsMvCollToTrash( rsComm, rmCollInp );
                if ( status >= 0 && collOprStat != NULL ) {
                    if ( *collOprStat == NULL ) {
                        *collOprStat = ( collOprStat_t* )malloc( sizeof( collOprStat_t ) );
                        memset( *collOprStat, 0, sizeof( collOprStat_t ) );
                    }
                    ( *collOprStat )->filesCnt = 1;
                    ( *collOprStat )->totalFileCnt = 1;
                    rstrcpy( ( *collOprStat )->lastObjPath, rmCollInp->collName,
                             MAX_NAME_LEN );
                }
                return status;
            }
        }
    }
    /* got here. will recursively phy delete the collection */
    status = _rsPhyRmColl( rsComm, rmCollInp, dataObjInfo, collOprStat );

    if ( dataObjInfo != NULL ) {
        freeDataObjInfo( dataObjInfo );
    }
    return status;
}
Ejemplo n.º 8
0
int
fillL1desc (int l1descInx, dataObjInp_t *dataObjInp,
            dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize)
{
    keyValPair_t *condInput = NULL;
    char *tmpPtr;


    if (dataObjInp != NULL) {
        condInput = &dataObjInp->condInput;
#if 0
        if (getValByKey (&dataObjInp->condInput, REPL_DATA_OBJ_INP_KW) !=
                NULL) {
            L1desc[l1descInx].dataObjInp = malloc (sizeof (dataObjInp_t));
            replDataObjInp (dataObjInp, L1desc[l1descInx].dataObjInp);
            L1desc[l1descInx].dataObjInpReplFlag = 1;
        } else {
            L1desc[l1descInx].dataObjInp = dataObjInp;
        }
#else
        /* always repl the .dataObjInp */
        L1desc[l1descInx].dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
        replDataObjInp (dataObjInp, L1desc[l1descInx].dataObjInp);
        L1desc[l1descInx].dataObjInpReplFlag = 1;
#endif
    } else {
        /* XXXX this can be a problem in rsDataObjClose */
        L1desc[l1descInx].dataObjInp = NULL;
    }

    L1desc[l1descInx].dataObjInfo = dataObjInfo;
    if (dataObjInp != NULL) {
        L1desc[l1descInx].oprType = dataObjInp->oprType;
    }
    L1desc[l1descInx].replStatus = replStatus;
    L1desc[l1descInx].dataSize = dataSize;
    if (condInput != NULL && condInput->len > 0) {
        if ((tmpPtr = getValByKey (condInput, REG_CHKSUM_KW)) != NULL) {
            L1desc[l1descInx].chksumFlag = REG_CHKSUM;
            rstrcpy (L1desc[l1descInx].chksum, tmpPtr, NAME_LEN);
        } else if ((tmpPtr = getValByKey (condInput, VERIFY_CHKSUM_KW)) !=
                   NULL) {
            L1desc[l1descInx].chksumFlag = VERIFY_CHKSUM;
            rstrcpy (L1desc[l1descInx].chksum, tmpPtr, NAME_LEN);
        }
    }
#ifdef LOG_TRANSFERS
    (void)gettimeofday(&L1desc[l1descInx].openStartTime,
                       (struct timezone *)0);
#endif
    return (0);
}
Ejemplo n.º 9
0
int _call_file_modified_for_replica(
    rsComm_t*     rsComm,
    regReplica_t* regReplicaInp ) {
    int status = 0;
    dataObjInfo_t* destDataObjInfo = regReplicaInp->destDataObjInfo;

    irods::file_object_ptr file_obj(
        new irods::file_object(
            rsComm,
            destDataObjInfo ) );

    char* pdmo_kw = getValByKey( &regReplicaInp->condInput, IN_PDMO_KW );
    if ( pdmo_kw != NULL ) {
        file_obj->in_pdmo( pdmo_kw );
    }

    irods::error ret = fileModified( rsComm, file_obj );
    if ( !ret.ok() ) {
        std::stringstream msg;
        msg << __FUNCTION__;
        msg << " - Failed to signal resource that the data object \"";
        msg << destDataObjInfo->objPath;
        msg << "\" was registered";
        ret = PASSMSG( msg.str(), ret );
        irods::log( ret );
        status = ret.code();
    }

    return status;

} // _call_file_modified_for_replica
Ejemplo n.º 10
0
int
rsNcGetVarsByType (rsComm_t *rsComm, ncGetVarInp_t *ncGetVarInp,
ncGetVarOut_t **ncGetVarOut)
{
    int l1descInx;
    int status = 0;

    if (getValByKey (&ncGetVarInp->condInput, NATIVE_NETCDF_CALL_KW) != 
      NULL) {
	/* just do nc_inq_YYYY */
	status = _rsNcGetVarsByType (ncGetVarInp->ncid, ncGetVarInp,
	  ncGetVarOut);
        return status;
    }
    l1descInx = ncGetVarInp->ncid;
    if (l1descInx < 2 || l1descInx >= NUM_L1_DESC) {
        rodsLog (LOG_ERROR,
          "rsNcGetVarsByType: l1descInx %d out of range",
          l1descInx);
        return (SYS_FILE_DESC_OUT_OF_RANGE);
    }
    if (L1desc[l1descInx].inuseFlag != FD_INUSE) return BAD_INPUT_DESC_INDEX;
    if (L1desc[l1descInx].openedAggInfo.ncAggInfo != NULL) {
        status = rsNcGetVarsByTypeForColl (rsComm, ncGetVarInp, ncGetVarOut);
    } else {
        status = rsNcGetVarsByTypeForObj (rsComm, ncGetVarInp, ncGetVarOut);
    }
    return status;
}
Ejemplo n.º 11
0
int
getSetValFromKeyValPair(char *varMap, keyValPair_t **inptr, char **varValue, void *newVarValue)
{
  char varName[NAME_LEN];
  char *varMapCPtr;
  char *Cptr;
  int i;
  keyValPair_t *ptr;

  ptr = *inptr;

  if (varMap == NULL) {
    i = getSetLeafValue(varValue,inptr, (void **) inptr, (char*)newVarValue, RE_PTR);
    return(i);
  }
  
  if (ptr == NULL)
    return(NULL_VALUE_ERR);
  i = getVarNameFromVarMap(varMap, varName, &varMapCPtr);
  if (i != 0)
    return(i);
  Cptr = (char *) getValByKey(ptr,varName);
  /**** may need to do a st value by key ****/
  if (Cptr == NULL)
    return(UNMATCHED_KEY_OR_INDEX);
  *varValue = Cptr;
  return(0);
}
Ejemplo n.º 12
0
/* rsDataCopy - Do the copy data transfer.
 * Input -
 *   dataCopyInp_t dataCopyInp:
 *      dataOprInp:  - mostly setup by initDataOprInp()
 *         int oprType - SAME_HOST_COPY_OPR, COPY_TO_REM_OPR, COPY_TO_LOCAL_OPR
 *         int numThreads
 *         int srcL3descInx - the source L3descInx
 *         int destL3descInx - the target L3descInx
 *         int srcRescTypeInx;
 *         int destRescTypeInx;
 *         rodsLong_t offset
 *         rodsLong_t dataSize
 *         keyValPair_t condInput - valid input -
 *            EXEC_LOCALLY_KW - all operations except remote-remote copy
 *               have the keyword set.
 *
 *   portalOprOut_t portalOprOut - the resource server portal info.
 */
int
rsDataCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
    int status;
    int l3descInx;
    rodsServerHost_t *rodsServerHost;
    dataOprInp_t *dataOprInp;

    dataOprInp = &dataCopyInp->dataOprInp;


    if ( getValByKey( &dataOprInp->condInput, EXEC_LOCALLY_KW ) != NULL ||
            dataCopyInp->portalOprOut.numThreads == 0 ) {
        /* XXXXX do it locally if numThreads == 0 */
        status = _rsDataCopy( rsComm, dataCopyInp );
    }
    else {
        if ( dataOprInp->destL3descInx > 0 ) {
            l3descInx = dataOprInp->destL3descInx;
        }
        else {
            l3descInx = dataOprInp->srcL3descInx;
        }
        rodsServerHost = FileDesc[l3descInx].rodsServerHost;
        if ( rodsServerHost != NULL && rodsServerHost->localFlag != LOCAL_HOST ) {
            addKeyVal( &dataOprInp->condInput, EXEC_LOCALLY_KW, "" );
            status = remoteDataCopy( rsComm, dataCopyInp, rodsServerHost );
            clearKeyVal( &dataOprInp->condInput );
        }
        else {
            status = _rsDataCopy( rsComm, dataCopyInp );
        }
    }
    return status;
}
Ejemplo n.º 13
0
    int
    rsNcGetVarsByType( rsComm_t *rsComm, ncGetVarInp_t *ncGetVarInp,
                       ncGetVarOut_t **ncGetVarOut ) {
        int l1descInx;
        int status = 0;

        if ( getValByKey( &ncGetVarInp->condInput, NATIVE_NETCDF_CALL_KW ) !=
                NULL ) {
            /* just do nc_inq_YYYY */
            status = _rsNcGetVarsByType( ncGetVarInp->ncid, ncGetVarInp,
                                         ncGetVarOut );
            return status;
        }
        l1descInx = ncGetVarInp->ncid;
        l1desc_t& my_desc = irods::get_l1desc( l1descInx );
        if ( l1descInx < 2 || l1descInx >= NUM_L1_DESC ) {
            rodsLog( LOG_ERROR,
                     "rsNcGetVarsByType: l1descInx %d out of range",
                     l1descInx );
            return ( SYS_FILE_DESC_OUT_OF_RANGE );
        }
        if ( my_desc.inuseFlag != FD_INUSE ) {
            return BAD_INPUT_DESC_INDEX;
        }
        openedAggInfo_t * openedAggInfo = boost::any_cast< openedAggInfo_t >( &my_desc.pluginData );
        if (openedAggInfo != NULL && openedAggInfo->ncAggInfo != NULL ) {
            status = _rsNcGetVarsByTypeForColl( rsComm, ncGetVarInp, ncGetVarOut );
        }
        else {
            status = _rsNcGetVarsByTypeForObj( rsComm, ncGetVarInp, ncGetVarOut );
        }
        return status;
    }
Ejemplo n.º 14
0
// =-=-=-=-=-=-=-
// JMC - backport 4590
int
procDataObjOpenForWrite( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
                         dataObjInfo_t **dataObjInfoHead,
                         dataObjInfo_t **compDataObjInfo ) {
    int status = 0;

    /* put the copy with destResc on top */
    status = requeDataObjInfoByDestResc( dataObjInfoHead, &dataObjInp->condInput, 1, 1 );

    /* status < 0 means there is no copy in the DEST_RESC */
    if ( status < 0 && ( *dataObjInfoHead )->specColl == NULL &&
            getValByKey( &dataObjInp->condInput, DEST_RESC_NAME_KW ) != NULL ) {

        /* we don't have a copy, so create an empty dataObjInfo */
        status = createEmptyRepl( rsComm, dataObjInp, dataObjInfoHead );
        if ( status < 0 ) {
            rodsLogError( LOG_ERROR, status,
                          "procDataObjForOpenWrite: createEmptyRepl of %s failed",
                          ( *dataObjInfoHead )->objPath );
            return status;
        }

    }
    else {     /*  The target data object exists */
        status = 0;
    }

    if ( *compDataObjInfo != NULL ) {
        dequeDataObjInfo( dataObjInfoHead, *compDataObjInfo );
    }
    return status;
}
Ejemplo n.º 15
0
int
rsDataGet( rsComm_t *rsComm, dataOprInp_t *dataOprInp,
           portalOprOut_t **portalOprOut ) {
    int status;
    int remoteFlag;
    int l3descInx;
    rodsServerHost_t *rodsServerHost;

    l3descInx = dataOprInp->srcL3descInx;

    if ( getValByKey( &dataOprInp->condInput, EXEC_LOCALLY_KW ) != NULL ) {
        remoteFlag = LOCAL_HOST;
    }
    else {
        rodsServerHost = FileDesc[l3descInx].rodsServerHost;
        if ( rodsServerHost == NULL ) {
            rodsLog( LOG_NOTICE, "rsDataGet: NULL rodsServerHost" );
            return SYS_INTERNAL_NULL_INPUT_ERR;
        }
        remoteFlag = rodsServerHost->localFlag;
    }

    if ( remoteFlag == LOCAL_HOST ) {
        status = _rsDataGet( rsComm, dataOprInp, portalOprOut );
    }
    else {
        addKeyVal( &dataOprInp->condInput, EXEC_LOCALLY_KW, "" );
        status = remoteDataGet( rsComm, dataOprInp, portalOprOut,
                                rodsServerHost );
        clearKeyVal( &dataOprInp->condInput );
    }


    return status;
}
Ejemplo n.º 16
0
        irods::error operator()( irods::plugin_context&, rsComm_t* _comm, types_t... _t )
        {
#ifdef IRODS_ENABLE_SYSLOG
            bool logger_updated = false;

            const auto update_logger = [&logger_updated](auto&& _arg)
            {
                // If there exists multiple objects containing verbose flags,
                // then only allow one update.  What happens if subsequent calls
                // are made (hopefully, the condition objects are passed through
                // unchanged)?
                if (logger_updated)
                {
                    return;
                }

                // _arg's type will be deduced as <type>& if it's an lvalue.
                // For pointers, this means the type will we T*&.  Therefore, we
                // must either remove the reference or add a reference so that
                // std::is_same compares the correct types.
                using T = std::remove_reference_t<decltype(_arg)>;

                if constexpr (std::is_same_v<dataObjInp_t*, T>)
                {
                    logger_updated = true;
                    const auto* value = getValByKey(&_arg->condInput, VERY_VERBOSE_KW);
                    irods::experimental::log::write_to_error_object(value); 
                }
                else if constexpr (std::is_same_v<dataObjCopyInp_t*, T>)
Ejemplo n.º 17
0
void createKVP(struct map *m, char *key, char *val){
	if(m->key == NULL){
		m->key = (char *) malloc(sizeof(strlen(key)));
		m->val = (char *) malloc(sizeof(strlen(val)));
		strcpy(m->key,key);
		strcpy(m->val,val);
		m->next = NULL;
		return;
	}
	if(getValByKey(m,key) != NULL){
		modifyValByKey(m,key,val);
		return;
	}	
	struct map *temp,*curr;
	temp=m;
	while(temp->next != NULL){
		temp=temp->next;
	}
	curr = (struct map *)malloc(sizeof(struct map));
	curr->key = (char *) malloc(sizeof(strlen(key)));
	curr->val = (char *) malloc(sizeof(strlen(val)));
	strcpy(curr->key,key);
	strcpy(curr->val,val);
	curr->next=NULL;
	
	temp->next=curr;
}
Ejemplo n.º 18
0
/// @brief Selects the dataObjInfo in the specified list whose resc hier matches that of the cond input
irods::error selectObjInfo(
    dataObjInfo_t * _dataObjInfoHead,
    keyValPair_t* _condInput,
    dataObjInfo_t** _rtn_dataObjInfo ) {
    irods::error result = SUCCESS();
    *_rtn_dataObjInfo = NULL;
    char* resc_hier = getValByKey( _condInput, RESC_HIER_STR_KW );
    if ( !resc_hier ) {
        std::stringstream msg;
        msg << __FUNCTION__;
        msg << " - No resource hierarchy specified in keywords.";
        result = ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
    }
    else {
        for ( dataObjInfo_t* dataObjInfo = _dataObjInfoHead;
                result.ok() && *_rtn_dataObjInfo == NULL && dataObjInfo != NULL;
                dataObjInfo = dataObjInfo->next ) {
            if ( strcmp( resc_hier, dataObjInfo->rescHier ) == 0 ) {
                *_rtn_dataObjInfo = dataObjInfo;
            }
        }
        if ( *_rtn_dataObjInfo == NULL ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - Failed to find a data obj matching resource hierarchy: \"";
            msg << resc_hier;
            msg << "\"";
            result = ERROR( HIERARCHY_ERROR, msg.str() );
        }
    }
    return result;
}
Ejemplo n.º 19
0
int
rsRuleExecSubmit (rsComm_t *rsComm, ruleExecSubmitInp_t *ruleExecSubmitInp,
char **ruleExecId)
{
    rodsServerHost_t *rodsServerHost;
    int status;

    *ruleExecId = NULL;

    if (ruleExecSubmitInp == NULL || 
      ruleExecSubmitInp->packedReiAndArgBBuf == NULL ||
      ruleExecSubmitInp->packedReiAndArgBBuf->len <= 0 ||
      ruleExecSubmitInp->packedReiAndArgBBuf->buf == NULL) {
       rodsLog(LOG_NOTICE,
        "rsRuleExecSubmit error. NULL input");
       return (SYS_INTERNAL_NULL_INPUT_ERR);
    }

#if 0
    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL,
                                &rodsServerHost);
#else
    status = getAndConnReHost (rsComm, &rodsServerHost);
#endif
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsRuleExecSubmit (rsComm, ruleExecSubmitInp);
        if (status >= 0) {
            *ruleExecId = strdup (ruleExecSubmitInp->ruleExecId);
        }
#else
       rodsLog(LOG_NOTICE,
               "rsRuleExecSubmit error. ICAT is not configured on this host");
       return (SYS_NO_ICAT_SERVER_ERR);
#endif
    } else {
	if (getValByKey (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW) != 
	  NULL) {
            rodsLog (LOG_ERROR,
              "rsRuleExecSubmit: reHost config error. reServer not running locally");
	    return SYS_CONFIG_FILE_ERR;
	} else {
	    addKeyVal (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW, "");
	}
        status = rcRuleExecSubmit(rodsServerHost->conn, ruleExecSubmitInp,
	  ruleExecId);
    }
    if (status < 0) {
        rodsLog (LOG_ERROR,
          "rsRuleExecSubmit: rcRuleExecSubmit failed, status = %d", 
	  status);
    }
    return (status);
}
Ejemplo n.º 20
0
int
_rsRegColl (rsComm_t *rsComm, collInp_t *collCreateInp)
{
#ifdef RODS_CAT
    int status;
    collInfo_t collInfo;
    char *tmpStr;

    memset (&collInfo, 0, sizeof (collInfo));

    rstrcpy (collInfo.collName, collCreateInp->collName, MAX_NAME_LEN);

    if ((tmpStr = getValByKey (&collCreateInp->condInput,
      COLLECTION_TYPE_KW)) != NULL) {
        rstrcpy (collInfo.collType, tmpStr, NAME_LEN);
	if ((tmpStr = getValByKey (&collCreateInp->condInput,
          COLLECTION_INFO1_KW)) != NULL) {
	    rstrcpy (collInfo.collInfo1, tmpStr, NAME_LEN);
	}
        if ((tmpStr = getValByKey (&collCreateInp->condInput,
          COLLECTION_INFO2_KW)) != NULL) {
            rstrcpy (collInfo.collInfo2, tmpStr, NAME_LEN);
        }
    }

#ifdef FILESYSTEM_META
    /* if the "collection" keyword has been set, it provides the
       name of another collection to retrieve directory metadata
       from (usually during a icp or irsync operation */
    tmpStr = getValByKey(&collCreateInp->condInput, COLLECTION_KW);
    if (tmpStr != NULL) {
        rsQueryDirectoryMeta(rsComm, tmpStr, &collInfo.condInput);
    }
    else {
        /* otherwise copy over the source directory metadata if provided */
        copyFilesystemMetadata(&collCreateInp->condInput, &collInfo.condInput);
    }
#endif /* FILESYSTEM_META */

    status = chlRegColl (rsComm, &collInfo);
    return (status);
#else
    return (SYS_NO_RCAT_SERVER_ERR);
#endif
}
Ejemplo n.º 21
0
int
filePathRegRepl (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
rescInfo_t *rescInfo)
{
    dataObjInfo_t destDataObjInfo, *dataObjInfoHead = NULL;
    regReplica_t regReplicaInp;
    char *rescGroupName = NULL;
    int status;

    status = getDataObjInfo (rsComm, phyPathRegInp, &dataObjInfoHead,
      ACCESS_READ_OBJECT, 0);

    if (status < 0) {
        rodsLog (LOG_ERROR,
          "filePathRegRepl: getDataObjInfo for %s", phyPathRegInp->objPath);
        return (status);
    }
    status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, NULL, 0);
    if (status < 0) return status;

    destDataObjInfo = *dataObjInfoHead;
    rstrcpy (destDataObjInfo.filePath, filePath, MAX_NAME_LEN);
    destDataObjInfo.rescInfo = rescInfo;
    rstrcpy (destDataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
    if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
      RESC_GROUP_NAME_KW)) != NULL) {
        rstrcpy (destDataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
    }
    memset (&regReplicaInp, 0, sizeof (regReplicaInp));
    regReplicaInp.srcDataObjInfo = dataObjInfoHead;
    regReplicaInp.destDataObjInfo = &destDataObjInfo;
    if (getValByKey (&phyPathRegInp->condInput, SU_CLIENT_USER_KW) != NULL) {
        addKeyVal (&regReplicaInp.condInput, SU_CLIENT_USER_KW, "");
        addKeyVal (&regReplicaInp.condInput, IRODS_ADMIN_KW, "");
    } else if (getValByKey (&phyPathRegInp->condInput,
      IRODS_ADMIN_KW) != NULL) {
        addKeyVal (&regReplicaInp.condInput, IRODS_ADMIN_KW, "");
    }
    status = rsRegReplica (rsComm, &regReplicaInp);
    clearKeyVal (&regReplicaInp.condInput);
    freeAllDataObjInfo (dataObjInfoHead);

    return status;
}
Ejemplo n.º 22
0
int
initDataObjInfoWithInp( dataObjInfo_t *dataObjInfo, dataObjInp_t *dataObjInp ) {
    char *rescName = 0, *dataType = 0, *filePath = 0;
    keyValPair_t *condInput = 0;

    condInput = &dataObjInp->condInput;
    memset( dataObjInfo, 0, sizeof( dataObjInfo_t ) );
    rstrcpy( dataObjInfo->objPath, dataObjInp->objPath, MAX_NAME_LEN );

    rescName = getValByKey( condInput, RESC_NAME_KW );
    if ( rescName != NULL ) {
        rstrcpy( dataObjInfo->rescName, rescName, NAME_LEN );
    }

    char* rescHier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
    if ( rescHier ) {
        rstrcpy( dataObjInfo->rescHier, rescHier, MAX_NAME_LEN );
    }
    else {
        rstrcpy( dataObjInfo->rescHier, rescName, MAX_NAME_LEN ); // in kw else
    }

    irods::error ret = resc_mgr.hier_to_leaf_id(dataObjInfo->rescHier,dataObjInfo->rescId);
    if( !ret.ok() ) {
        irods::log(PASS(ret));
    }

    snprintf( dataObjInfo->dataMode, SHORT_STR_LEN, "%d", dataObjInp->createMode );

    dataType = getValByKey( condInput, DATA_TYPE_KW );
    if ( dataType != NULL ) {
        rstrcpy( dataObjInfo->dataType, dataType, NAME_LEN );
    }
    else {
        rstrcpy( dataObjInfo->dataType, "generic", NAME_LEN );
    }

    filePath = getValByKey( condInput, FILE_PATH_KW );
    if ( filePath != NULL ) {
        rstrcpy( dataObjInfo->filePath, filePath, MAX_NAME_LEN );
    }

    return 0;
}
Ejemplo n.º 23
0
/**
 * \fn rcExecMyRule( rcComm_t *conn, execMyRuleInp_t *execMyRuleInp, msParamArray_t **outParamArray )
 *
 * \brief Execute my rule.
 *
 * \user client
 *
 * \ingroup rules
 *
 * \since 1.0
 *
 *
 * \remark none
 *
 * \note none
*
 * \param[in] conn - A rcComm_t connection handle to the server.
 * \param[in] execMyRuleInp
 * \param[out] outParamArray
 *
 * \return integer
 * \retval 0 on success.
 * \sideeffect none
 * \pre none
 * \post none
 * \sa none
**/
int
rcExecMyRule( rcComm_t *conn, execMyRuleInp_t *execMyRuleInp,
              msParamArray_t **outParamArray ) {

    int status = procApiRequest( conn, EXEC_MY_RULE_AN, execMyRuleInp, NULL,
                                 ( void ** )outParamArray, NULL );

    while ( status == SYS_SVR_TO_CLI_MSI_REQUEST ) {
        /* it is a server request */
        msParam_t *myParam = NULL, *putParam = NULL;

        if ( ( myParam = putParam = getMsParamByLabel( *outParamArray, CL_PUT_ACTION ) ) ||
                ( myParam = getMsParamByLabel( *outParamArray, CL_GET_ACTION ) ) ) {
            //putParam is non-null if it's a put, null if it's a get
            dataObjInp_t * dataObjInp = ( dataObjInp_t * ) myParam->inOutStruct;
            char * locFilePath;
            char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
            // locFilePath should be the return of getValByKey if it exists,
            // otherwise use the filename from splitPathByKey
            if ( ( locFilePath = getValByKey( &dataObjInp->condInput, LOCAL_PATH_KW ) ) ||
                    ( ( status = splitPathByKey( dataObjInp->objPath, myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) >= 0 &&
                      ( locFilePath = ( char * ) myFile ) ) ) {
                status = putParam ?
                         rcDataObjPut( conn, dataObjInp, locFilePath ) :
                         rcDataObjGet( conn, dataObjInp, locFilePath );
                rcOprComplete( conn, status );
            }
            else {
                rodsLogError( LOG_ERROR, status,
                              "rcExecMyRule: splitPathByKey for %s error",
                              dataObjInp->objPath );
                rcOprComplete( conn, USER_FILE_DOES_NOT_EXIST );
            }
            clearKeyVal( &dataObjInp->condInput );
        }
        else {
            rcOprComplete( conn, SYS_SVR_TO_CLI_MSI_NO_EXIST );
        }
        /* free outParamArray */
        clearMsParamArray( *outParamArray, 1 );
        free( *outParamArray );
        *outParamArray = NULL;

        /* read the reply from the earlier call */

        status = branchReadAndProcApiReply( conn, EXEC_MY_RULE_AN,
                                            ( void ** )outParamArray, NULL );
        if ( status < 0 ) {
            rodsLogError( LOG_DEBUG, status,
                          "rcExecMyRule: readAndProcApiReply failed. status = %d",
                          status );
        }
    }

    return status;
}
Ejemplo n.º 24
0
int
resolveLinkedPath( rsComm_t *rsComm, char *objPath,
                   specCollCache_t **specCollCache, keyValPair_t *condInput ) {
    int linkCnt = 0;
    specColl_t *curSpecColl;
    char prevNewPath[MAX_NAME_LEN];
    specCollCache_t *oldSpecCollCache = NULL;
    int status;

    *specCollCache = NULL;

    if ( getValByKey( condInput, TRANSLATED_PATH_KW ) != NULL ) {
        return 0;
    }

    addKeyVal( condInput, TRANSLATED_PATH_KW, "" );
    while ( getSpecCollCache( rsComm, objPath, 0,  specCollCache ) >= 0 &&
            ( *specCollCache )->specColl.collClass == LINKED_COLL ) {
        oldSpecCollCache = *specCollCache;
        if ( linkCnt++ >= MAX_LINK_CNT ) {
            rodsLog( LOG_ERROR,
                     "resolveLinkedPath: linkCnt for %s exceeds %d",
                     objPath, MAX_LINK_CNT );
            return SYS_LINK_CNT_EXCEEDED_ERR;
        }

        curSpecColl = &( *specCollCache )->specColl;
        if ( strcmp( curSpecColl->collection, objPath ) == 0 &&
                getValByKey( condInput, NO_TRANSLATE_LINKPT_KW ) != NULL ) {
            return 0;
        }
        rstrcpy( prevNewPath, objPath, MAX_NAME_LEN );
        status = getMountedSubPhyPath( curSpecColl->collection,
                                       curSpecColl->phyPath, prevNewPath, objPath );
        if ( status < 0 ) {
            return status;
        }
    }
    if ( *specCollCache == NULL ) {
        *specCollCache = oldSpecCollCache;
    }
    return linkCnt;
}
Ejemplo n.º 25
0
int
openSpecColl( rsComm_t *rsComm, dataObjInp_t *dataObjInp, int parentInx ) {
    int specCollInx;
    dataObjInfo_t *dataObjInfo = NULL;
    int status;
    int l3descInx;

    status = resolvePathInSpecColl( rsComm, dataObjInp->objPath,
                                    //READ_COLL_PERM, 0, &dataObjInfo);
                                    UNKNOWN_COLL_PERM, 0, &dataObjInfo );

    if ( status < 0 || NULL == dataObjInfo ) { // JMC cppcheck - nullptr
        rodsLog( LOG_NOTICE,
                 "rsQuerySpecColl: resolveSpecColl error for %s, status = %d",
                 dataObjInp->objPath, status );
        return status;
    }

    if ( dataObjInfo->specColl->collClass == LINKED_COLL ) {
        rodsLog( LOG_ERROR,
                 "rsQuerySpecColl: %s is a linked collection",
                 dataObjInp->objPath );
        return SYS_UNKNOWN_SPEC_COLL_CLASS;
    }

    char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
    if ( resc_hier ) {
        strncpy( dataObjInfo->rescHier, resc_hier, MAX_NAME_LEN );
        irods::error ret = resc_mgr.hier_to_leaf_id(resc_hier,dataObjInfo->rescId);
        if( !ret.ok() ) {
            irods::log(PASS(ret));
        }
    }

    l3descInx = l3Opendir( rsComm, dataObjInfo );

    if ( l3descInx < 0 ) {
        rodsLog( LOG_NOTICE,
                 "openSpecColl: specCollOpendir error for %s, status = %d",
                 dataObjInp->objPath, l3descInx );
        return l3descInx;
    }
    specCollInx = allocSpecCollDesc();
    if ( specCollInx < 0 ) {
        freeDataObjInfo( dataObjInfo );
        return specCollInx;
    }
    SpecCollDesc[specCollInx].l3descInx = l3descInx;
    SpecCollDesc[specCollInx].dataObjInfo = dataObjInfo;
    SpecCollDesc[specCollInx].parentInx = parentInx;

    return specCollInx;
}
Ejemplo n.º 26
0
int
rsPhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
{
    int status;

    if (getValByKey (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW) != NULL &&
      rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
	return SYS_NO_API_PRIV;
    }

    status = irsPhyPathReg (rsComm, phyPathRegInp);
    return (status);
}
Ejemplo n.º 27
0
int rsGetHostForGet(
    rsComm_t*     rsComm,
    dataObjInp_t* dataObjInp,
    char**        outHost ) {
    // =-=-=-=-=-=-=-
    // default behavior
    *outHost = strdup( THIS_ADDRESS );

    // =-=-=-=-=-=-=-
    // working on the "home zone", determine if we need to redirect to a different
    // server in this zone for this operation.  if there is a RESC_HIER_STR_KW then
    // we know that the redirection decision has already been made
    if ( isColl( rsComm, dataObjInp->objPath, NULL ) < 0 ) {
        std::string       hier;
        if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
            irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION, rsComm,
                               dataObjInp, hier );
            if ( !ret.ok() ) {
                std::stringstream msg;
                msg << __FUNCTION__;
                msg << " :: failed in irods::resolve_resource_hierarchy for [";
                msg << dataObjInp->objPath << "]";
                irods::log( PASSMSG( msg.str(), ret ) );
                return ret.code();
            }
            // =-=-=-=-=-=-=-
            // we resolved the redirect and have a host, set the hier str for subsequent
            // api calls, etc.
            addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

        } // if keyword

        // =-=-=-=-=-=-=-
        // extract the host location from the resource hierarchy
        std::string location;
        irods::error ret = irods::get_loc_for_hier_string( hier, location );
        if ( !ret.ok() ) {
            irods::log( PASSMSG( "rsGetHostForGet - failed in get_loc_for_hier_string", ret ) );
            return -1;
        }

        // =-=-=-=-=-=-=-
        // set the out variable
        *outHost = strdup( location.c_str() );

    } // if not a collection

    return 0;

}
Ejemplo n.º 28
0
int
_rsRegReplica (rsComm_t *rsComm, regReplica_t *regReplicaInp)
{
#ifdef RODS_CAT
    int status;
    dataObjInfo_t *srcDataObjInfo;
    dataObjInfo_t *destDataObjInfo;
    int savedClientAuthFlag;

    srcDataObjInfo = regReplicaInp->srcDataObjInfo;
    destDataObjInfo = regReplicaInp->destDataObjInfo;

#if 0
    status = checkDupReplica (rsComm, srcDataObjInfo->dataId, 
      destDataObjInfo->rescName, destDataObjInfo->filePath);
    if (status >= 0) {
	destDataObjInfo->replNum = status;
	return status;
    }
#endif
    if (getValByKey (&regReplicaInp->condInput, SU_CLIENT_USER_KW) != NULL) {
	savedClientAuthFlag = rsComm->clientUser.authInfo.authFlag;
	rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
        status = chlRegReplica (rsComm, srcDataObjInfo, destDataObjInfo,
          &regReplicaInp->condInput);
	/* restore it */
	rsComm->clientUser.authInfo.authFlag = savedClientAuthFlag;
    } else {
        status = chlRegReplica (rsComm, srcDataObjInfo, destDataObjInfo,
          &regReplicaInp->condInput);
	if (status >= 0) status = destDataObjInfo->replNum;
    }
    if (status == CAT_SUCCESS_BUT_WITH_NO_INFO || 
      status == CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME) {
	int status2;
	/* register a repl with a copy with the same resource and phyPaht.
         * could be caused by 2 staging at the same time */
        status2 = checkDupReplica (rsComm, srcDataObjInfo->dataId,
          destDataObjInfo->rescName, destDataObjInfo->filePath);
        if (status2 >= 0) {
            destDataObjInfo->replNum = status2;
	    destDataObjInfo->dataId = srcDataObjInfo->dataId;
            return status2;
        }
    }
    return (status);
#else
    return (SYS_NO_RCAT_SERVER_ERR);
#endif
}
Ejemplo n.º 29
0
int
rsSpecificQuery( rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
                 genQueryOut_t **genQueryOut ) {
    rodsServerHost_t *rodsServerHost;
    int status;
    char *zoneHint = "";

    /*  zoneHint = getZoneHintForGenQuery (genQueryInp); (need something like this?) */
    zoneHint = getValByKey( &specificQueryInp->condInput, ZONE_KW );

    status = getAndConnRcatHost( rsComm, SLAVE_RCAT, ( const char* )zoneHint,
                                 &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
        std::string svc_role;
        irods::error ret = get_catalog_service_role(svc_role);
        if(!ret.ok()) {
            irods::log(PASS(ret));
            return ret.code();
        }

        if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
            status = _rsSpecificQuery( rsComm, specificQueryInp, genQueryOut );
        } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
            rodsLog( LOG_NOTICE,
                     "rsSpecificQuery error. RCAT is not configured on this host" );
            return SYS_NO_RCAT_SERVER_ERR;
        } else {
            rodsLog(
                LOG_ERROR,
                "role not supported [%s]",
                svc_role.c_str() );
            status = SYS_SERVICE_ROLE_NOT_SUPPORTED;
        }

    }
    else {
        status = rcSpecificQuery( rodsServerHost->conn,
                                  specificQueryInp, genQueryOut );
    }
    if ( status < 0  && status != CAT_NO_ROWS_FOUND ) {
        rodsLog( LOG_NOTICE,
                 "rsSpecificQuery: rcSpecificQuery failed, status = %d", status );
    }
    return status;
}
Ejemplo n.º 30
0
int
svrUnregColl( rsComm_t *rsComm, collInp_t *rmCollInp ) {
    int status;
#ifdef RODS_CAT
    collInfo_t collInfo;
#endif
    rodsServerHost_t *rodsServerHost = NULL;

    status = getAndConnRcatHost(
                 rsComm,
                 MASTER_RCAT,
                 ( const char* )rmCollInp->collName,
                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        memset( &collInfo, 0, sizeof( collInfo ) );
        rstrcpy( collInfo.collName, rmCollInp->collName, MAX_NAME_LEN );
        if ( getValByKey( &rmCollInp->condInput, ADMIN_RMTRASH_KW )
                != NULL ) {
            status = chlDelCollByAdmin( rsComm, &collInfo );
            if ( status >= 0 ) {
                chlCommit( rsComm );
            }
        }
        else {
            status = chlDelColl( rsComm, &collInfo );
        }

#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        collOprStat_t *collOprStat = NULL;;
        addKeyVal( &rmCollInp->condInput, UNREG_COLL_KW, "" );
        status = _rcRmColl( rodsServerHost->conn, rmCollInp, &collOprStat );
        if ( collOprStat != NULL ) {
            free( collOprStat );
        }
    }

    return status;
}