Example #1
0
int
rsDataObjGet (rsComm_t *rsComm, dataObjInp_t *dataObjInp, 
portalOprOut_t **portalOprOut, bytesBuf_t *dataObjOutBBuf)
{
  int status;
    int remoteFlag;
    rodsServerHost_t *rodsServerHost;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath (rsComm, dataObjInp->objPath, &specCollCache,
      &dataObjInp->condInput);
    remoteFlag = getAndConnRemoteZone (rsComm, dataObjInp, &rodsServerHost,
      REMOTE_OPEN);

    if (remoteFlag < 0) {
	return (remoteFlag);
    } else if (remoteFlag == LOCAL_HOST) {
        status = _rsDataObjGet (rsComm, dataObjInp, portalOprOut, 
          dataObjOutBBuf, BRANCH_MSG);
    } else {
       int l1descInx;
	status = _rcDataObjGet (rodsServerHost->conn, dataObjInp, portalOprOut,
	  dataObjOutBBuf);

        if (status < 0) {
            return (status);
        }
        if (status == 0 || 
	  (dataObjOutBBuf != NULL && dataObjOutBBuf->len > 0)) {
            /* data included in buf */
            return status;
        } else {
            /* have to allocate a local l1descInx to keep track of things
             * since the file is in remote zone. It sets remoteL1descInx,
             * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that  
             * rsComplete knows what to do */
	    l1descInx = allocAndSetL1descForZoneOpr (
	      (*portalOprOut)->l1descInx, dataObjInp, rodsServerHost, NULL);
            if (l1descInx < 0) return l1descInx;
            (*portalOprOut)->l1descInx = l1descInx;
            return status;
        }
    }

    return (status);
}
Example #2
0
int
rcDataObjGet( rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath ) {
    int status;
    portalOprOut_t *portalOprOut = NULL;
    bytesBuf_t dataObjOutBBuf;
#ifndef windows_platform
    struct stat statbuf;
#else
    struct irodsntstat statbuf;
#endif

    if ( strcmp( locFilePath, STDOUT_FILE_NAME ) == 0 ) {
        /* no parallel I/O if pipe to stdout */
        dataObjInp->numThreads = NO_THREADING;
    }
#ifndef windows_platform
    else if ( stat( locFilePath, &statbuf ) >= 0 )
#else
    else if ( iRODSNt_stat( locFilePath, &statbuf ) >= 0 )
#endif
    {
        /* local file exists */
        if ( getValByKey( &dataObjInp->condInput, FORCE_FLAG_KW ) == NULL ) {
            return ( OVERWRITE_WITHOUT_FORCE_FLAG );
        }
    }

    status = _rcDataObjGet( conn, dataObjInp, &portalOprOut, &dataObjOutBBuf );

    if ( status < 0 ) {
        if ( portalOprOut != NULL ) {
            free( portalOprOut );
        }
        return ( status );
    }

    if ( status == 0 || dataObjOutBBuf.len > 0 ) {
        /* data included */
        /**** Removed by Raja as this can cause problems when the data sizes are different - say when post processing is done....Dec 2 2010
              if (dataObjInp->dataSize > 0 &&
              dataObjInp->dataSize != dataObjOutBBuf.len) {
              rodsLog (LOG_NOTICE,
              "putFile: totalWritten %lld dataSize %lld mismatch",
              dataObjOutBBuf.len, dataObjInp->dataSize);
              return (SYS_COPY_LEN_ERR);
              }
        ****/
        status = getIncludeFile( conn, &dataObjOutBBuf, locFilePath );
        free( dataObjOutBBuf.buf );
    }
    else if ( getUdpPortFromPortList( &portalOprOut->portList ) != 0 ) {
        int veryVerbose;
        /* rbudp transfer */
        /* some sanity check */
        if ( portalOprOut->numThreads != 1 ) {
            rcOprComplete( conn, SYS_INVALID_PORTAL_OPR );
            free( portalOprOut );
            return ( SYS_INVALID_PORTAL_OPR );
        }
        conn->transStat.numThreads = portalOprOut->numThreads;
        if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) {
            printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n",
                    portalOprOut->numThreads, portalOprOut->portList.hostAddr,
                    portalOprOut->portList.portNum, portalOprOut->portList.cookie );
            veryVerbose = 2;
        }
        else {
            veryVerbose = 0;
        }

        // =-=-=-=-=-=-=-
        // if a secret has been negotiated then we must be using
        // encryption.  given that RBUDP is not supported in an
        // encrypted capacity this is considered an error
        if ( irods::CS_NEG_USE_SSL == conn->negotiation_results ) {
            rodsLog(
                LOG_ERROR,
                "getFileToPortal: Encryption is not supported with RBUDP" );
            return SYS_INVALID_PORTAL_OPR;

        }

        status = getFileToPortalRbudp(
                     portalOprOut,
                     locFilePath, 0,
                     dataObjInp->dataSize,
                     veryVerbose, 0 );

        /* just send a complete msg */
        if ( status < 0 ) {
            rcOprComplete( conn, status );

        }
        else {
            status = rcOprComplete( conn, portalOprOut->l1descInx );
        }
    }
    else {

        if ( portalOprOut->numThreads <= 0 ) {
            status = getFile( conn, portalOprOut->l1descInx,
                              locFilePath, dataObjInp->objPath, dataObjInp->dataSize );
        }
        else {
            if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) {
                printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n",
                        portalOprOut->numThreads, portalOprOut->portList.hostAddr,
                        portalOprOut->portList.portNum, portalOprOut->portList.cookie );
            }
            /* some sanity check */
            if ( portalOprOut->numThreads >= 20 * DEF_NUM_TRAN_THR ) {
                rcOprComplete( conn, SYS_INVALID_PORTAL_OPR );
                free( portalOprOut );
                return ( SYS_INVALID_PORTAL_OPR );
            }

            conn->transStat.numThreads = portalOprOut->numThreads;
            status = getFileFromPortal( conn, portalOprOut, locFilePath,
                                        dataObjInp->objPath, dataObjInp->dataSize );
        }
        /* just send a complete msg */
        if ( status < 0 ) {
            rcOprComplete( conn, status );
        }
        else {
            status = rcOprComplete( conn, portalOprOut->l1descInx );
        }
    }

    if ( status >= 0 && conn->fileRestart.info.numSeg > 0 ) { /* file restart */
        clearLfRestartFile( &conn->fileRestart );
    }

    if ( getValByKey( &dataObjInp->condInput, VERIFY_CHKSUM_KW ) != NULL ) {
        if ( portalOprOut == NULL || strlen( portalOprOut->chksum ) == 0 ) {
            rodsLog( LOG_ERROR,
                     "rcDataObjGet: VERIFY_CHKSUM_KW set but no chksum from server" );
        }
        else {

            status = verifyChksumLocFile( locFilePath, portalOprOut->chksum, NULL );
            if ( status == USER_CHKSUM_MISMATCH ) {
                rodsLogError( LOG_ERROR, status,
                              "rcDataObjGet: chksum mismatch error for %s, status = %d",
                              locFilePath, status );
                if ( portalOprOut != NULL ) {
                    free( portalOprOut );
                }
                return ( status );
            }
            else if ( status < 0 ) {
                rodsLogError( LOG_ERROR, status,
                              "rcDataObjGet: chksumLocFile error for %s, status = %d",
                              locFilePath, status );
                if ( portalOprOut != NULL ) {
                    free( portalOprOut );
                }
                return ( status );
            }

        }
    }
    if ( portalOprOut != NULL ) {
        free( portalOprOut );
    }

    return ( status );
}
Example #3
0
int
rsDataObjGet( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
              portalOprOut_t **portalOprOut, bytesBuf_t *dataObjOutBBuf ) {
    int status;
    int remoteFlag;
    rodsServerHost_t *rodsServerHost;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
                       &dataObjInp->condInput );
    remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost,
                                       REMOTE_OPEN );

    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == LOCAL_HOST ) {
        // =-=-=-=-=-=-=-
        // 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 ( 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 << "rsDataObjGet :: failed in irods::resolve_resource_redirect 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

        status = _rsDataObjGet( rsComm, dataObjInp, portalOprOut, dataObjOutBBuf, BRANCH_MSG );

    }
    else {
        int l1descInx;
        status = _rcDataObjGet( rodsServerHost->conn, dataObjInp, portalOprOut,
                                dataObjOutBBuf );

        if ( status < 0 ) {
            return status;
        }
        if ( status == 0 ||
                ( dataObjOutBBuf != NULL && dataObjOutBBuf->len > 0 ) ) {
            /* data included in buf */
            return status;
        }
        else {
            /* have to allocate a local l1descInx to keep track of things
             * since the file is in remote zone. It sets remoteL1descInx,
             * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that
             * rsComplete knows what to do */
            l1descInx = allocAndSetL1descForZoneOpr(
                            ( *portalOprOut )->l1descInx, dataObjInp, rodsServerHost, NULL );
            if ( l1descInx < 0 ) {
                return l1descInx;
            }
            ( *portalOprOut )->l1descInx = l1descInx;
            return status;
        }
    }

    return status;
}