int _rsNcGetVarsByTypeForObj( rsComm_t *rsComm, ncGetVarInp_t *ncGetVarInp, ncGetVarOut_t **ncGetVarOut ) { int remoteFlag; rodsServerHost_t *rodsServerHost = NULL; int l1descInx; ncGetVarInp_t myNcGetVarInp; int status = 0; l1descInx = ncGetVarInp->ncid; l1desc_t& my_desc = irods::get_l1desc( l1descInx ); if ( my_desc.remoteZoneHost != NULL ) { myNcGetVarInp = *ncGetVarInp; myNcGetVarInp.ncid = my_desc.remoteL1descInx; /* cross zone operation */ status = rcNcGetVarsByType( my_desc.remoteZoneHost->conn, &myNcGetVarInp, ncGetVarOut ); } else { remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = _rsNcGetVarsByType( my_desc.l3descInx, ncGetVarInp, ncGetVarOut ); if ( status < 0 ) { return status; } } else { /* execute it remotely */ myNcGetVarInp = *ncGetVarInp; myNcGetVarInp.ncid = my_desc.l3descInx; addKeyVal( &myNcGetVarInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcGetVarsByType( rodsServerHost->conn, &myNcGetVarInp, ncGetVarOut ); clearKeyVal( &myNcGetVarInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcGetVarsByType: rcNcGetVarsByType %d for %s error, status = %d", my_desc.l3descInx, my_desc.dataObjInfo->objPath, status ); return ( status ); } } } return status; }
int _rsNcInqIdDataObj( rsComm_t *rsComm, ncInqIdInp_t *ncInqIdInp, int **outId ) { int remoteFlag; rodsServerHost_t *rodsServerHost = NULL; int l1descInx; ncInqIdInp_t myNcInqIdInp; int status = 0; l1descInx = ncInqIdInp->ncid; l1desc_t& my_desc = irods::get_l1desc( l1descInx ); remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = _rsNcInqId( ncInqIdInp->paramType, my_desc.l3descInx, ncInqIdInp->name, outId ); if ( status < 0 ) { return status; } } else { /* execute it remotely */ bzero( &myNcInqIdInp, sizeof( myNcInqIdInp ) ); myNcInqIdInp.paramType = ncInqIdInp->paramType; myNcInqIdInp.ncid = my_desc.l3descInx; rstrcpy( myNcInqIdInp.name, ncInqIdInp->name, MAX_NAME_LEN ); addKeyVal( &myNcInqIdInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcInqId( rodsServerHost->conn, &myNcInqIdInp, outId ); clearKeyVal( &myNcInqIdInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcInqIdDataObj: rcNcInqId %d for %s error, status = %d", my_desc.l3descInx, my_desc.dataObjInfo->objPath, status ); return ( status ); } } return status; }
int rsNcGetVarsByType (rsComm_t *rsComm, ncGetVarInp_t *ncGetVarInp, ncGetVarOut_t **ncGetVarOut) { int remoteFlag; rodsServerHost_t *rodsServerHost = NULL; int l1descInx; ncGetVarInp_t myNcGetVarInp; 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].remoteZoneHost != NULL) { myNcGetVarInp = *ncGetVarInp; myNcGetVarInp.ncid = L1desc[l1descInx].remoteL1descInx; /* cross zone operation */ status = rcNcGetVarsByType (L1desc[l1descInx].remoteZoneHost->conn, &myNcGetVarInp, ncGetVarOut); } else { remoteFlag = resoAndConnHostByDataObjInfo (rsComm, L1desc[l1descInx].dataObjInfo, &rodsServerHost); if (remoteFlag < 0) { return (remoteFlag); } else if (remoteFlag == LOCAL_HOST) { status = _rsNcGetVarsByType (L1desc[l1descInx].l3descInx, ncGetVarInp, ncGetVarOut); if (status < 0) { return status; } } else { /* execute it remotely */ myNcGetVarInp = *ncGetVarInp; myNcGetVarInp.ncid = L1desc[l1descInx].l3descInx; addKeyVal (&myNcGetVarInp.condInput, NATIVE_NETCDF_CALL_KW, ""); status = rcNcGetVarsByType (rodsServerHost->conn, &myNcGetVarInp, ncGetVarOut); clearKeyVal (&myNcGetVarInp.condInput); if (status < 0) { rodsLog (LOG_ERROR, "rsNcGetVarsByType: rcNcGetVarsByType %d for %s error, status = %d", L1desc[l1descInx].l3descInx, L1desc[l1descInx].dataObjInfo->objPath, status); return (status); } } } return status; }
int rsNcCreate( rsComm_t *rsComm, ncOpenInp_t *ncCreateInp, int **ncid ) { int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; int status; dataObjInp_t dataObjInp; int l1descInx, myncid; if ( getValByKey( &ncCreateInp->condInput, NATIVE_NETCDF_CALL_KW ) != NULL ) { /* just do nc_open with objPath as file nc file path */ /* must to be called internally */ if ( rsComm->proxyUser.authInfo.authFlag < REMOTE_PRIV_USER_AUTH ) { return( CAT_INSUFFICIENT_PRIVILEGE_LEVEL ); } status = nc_create( ncCreateInp->objPath, ncCreateInp->mode, &myncid ); if ( status == NC_NOERR ) { *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = myncid; return 0; } else { rodsLog( LOG_ERROR, "rsNccreate: nc_create %s error, status = %d, %s", ncCreateInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } bzero( &dataObjInp, sizeof( dataObjInp ) ); rstrcpy( dataObjInp.objPath, ncCreateInp->objPath, MAX_NAME_LEN ); replKeyVal( &ncCreateInp->condInput, &dataObjInp.condInput ); resolveLinkedPath( rsComm, dataObjInp.objPath, &specCollCache, &dataObjInp.condInput ); remoteFlag = getAndConnRemoteZone( rsComm, &dataObjInp, &rodsServerHost, REMOTE_OPEN ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { addKeyVal( &dataObjInp.condInput, NO_OPEN_FLAG_KW, "" ); l1descInx = _rsDataObjCreate( rsComm, &dataObjInp ); clearKeyVal( &dataObjInp.condInput ); if ( l1descInx < 0 ) { return l1descInx; } l1desc_t& my_desc = irods::get_l1desc( l1descInx ); remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = nc_create( my_desc.dataObjInfo->filePath, ncCreateInp->mode, &myncid ); if ( status != NC_NOERR ) { rodsLog( LOG_ERROR, "rsNcCreate: nc_open %s error, status = %d, %s", ncCreateInp->objPath, status, nc_strerror( status ) ); freeL1desc( l1descInx ); return ( NETCDF_CREATE_ERR + status ); } } else { /* execute it remotely with dataObjInfo->filePath */ ncOpenInp_t myNcCreateInp; bzero( &myNcCreateInp, sizeof( myNcCreateInp ) ); rstrcpy( myNcCreateInp.objPath, my_desc.dataObjInfo->filePath, MAX_NAME_LEN ); addKeyVal( &myNcCreateInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcCreate( rodsServerHost->conn, &myNcCreateInp, &myncid ); clearKeyVal( &myNcCreateInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcCreate: _rcNcCreate %s error, status = %d", myNcCreateInp.objPath, status ); freeL1desc( l1descInx ); return ( status ); } } my_desc.l3descInx = myncid; /* need to reg here since NO_OPEN_FLAG_KW does not do it */ if ( my_desc.dataObjInfo->specColl == NULL ) { status = svrRegDataObj( rsComm, my_desc.dataObjInfo ); if ( status < 0 ) { ncCloseInp_t myNcCloseInp; bzero( &myNcCloseInp, sizeof( myNcCloseInp ) ); myNcCloseInp.ncid = l1descInx; irods::server_api_call ( NC_CLOSE_AN, rsComm, &myNcCloseInp ); l3Unlink( rsComm, my_desc.dataObjInfo ); rodsLog( LOG_ERROR, "rsNcCreate: svrRegDataObj for %s failed, status = %d", my_desc.dataObjInfo->objPath, status ); freeL1desc( l1descInx ); return ( NETCDF_CREATE_ERR + status ); } } } else { addKeyVal( &dataObjInp.condInput, CROSS_ZONE_CREATE_KW, "" ); status = rcNcCreate( rodsServerHost->conn, ncCreateInp, &myncid ); /* rm it to avoid confusion */ rmKeyVal( &dataObjInp.condInput, CROSS_ZONE_CREATE_KW ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcCreate: _rcNcCreate %s error, status = %d", ncCreateInp->objPath, status ); return ( status ); } l1descInx = allocAndSetL1descForZoneOpr( myncid, &dataObjInp, rodsServerHost, NULL ); } l1desc_t& my_desc = irods::get_l1desc( l1descInx ); my_desc.oprType = NC_CREATE; *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = l1descInx; return 0; }
int rsNcOpenGroup( rsComm_t *rsComm, ncOpenInp_t *ncOpenGroupInp, int **ncid ) { int remoteFlag; rodsServerHost_t *rodsServerHost; int status; dataObjInfo_t *dataObjInfo = NULL; int rl1descInx, l1descInx, myncid; int rootNcid; if ( getValByKey( &ncOpenGroupInp->condInput, NATIVE_NETCDF_CALL_KW ) != NULL ) { /* just all nc_open with objPath as file nc file path */ /* must to be called internally */ if ( rsComm->proxyUser.authInfo.authFlag < REMOTE_PRIV_USER_AUTH ) { return( CAT_INSUFFICIENT_PRIVILEGE_LEVEL ); } status = nc_inq_grp_full_ncid( ncOpenGroupInp->rootNcid, ncOpenGroupInp->objPath, &myncid ); if ( status == NC_NOERR ) { *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = myncid; return 0; } else { rodsLog( LOG_ERROR, "rsNcOpenGroup: nc_open %s error, status = %d, %s", ncOpenGroupInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } rl1descInx = ncOpenGroupInp->rootNcid; l1desc_t& my_desc = irods::get_l1desc( rl1descInx ); if ( rl1descInx < 2 || rl1descInx >= NUM_L1_DESC ) { rodsLog( LOG_ERROR, "rsNcClose: rl1descInx %d out of range", rl1descInx ); return ( SYS_FILE_DESC_OUT_OF_RANGE ); } if ( my_desc.inuseFlag != FD_INUSE ) { return BAD_INPUT_DESC_INDEX; } if ( my_desc.remoteZoneHost != NULL ) { ncOpenInp_t myNcOpenGroupInp; bzero( &myNcOpenGroupInp, sizeof( myNcOpenGroupInp ) ); rstrcpy( myNcOpenGroupInp.objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); myNcOpenGroupInp.rootNcid = my_desc.remoteL1descInx; status = rcNcOpenGroup( my_desc.remoteZoneHost->conn, &myNcOpenGroupInp, &myncid ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: _rcNcOpenGroup %s error, status = %d", ncOpenGroupInp->objPath, status ); return ( status ); } l1descInx = allocAndSetL1descForZoneOpr( myncid, my_desc.dataObjInp, my_desc.remoteZoneHost, NULL ); } else { /* local zone */ rootNcid = my_desc.l3descInx; remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = nc_inq_grp_full_ncid( rootNcid, ncOpenGroupInp->objPath, &myncid ); if ( status != NC_NOERR ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: nc_inq_grp_full_ncid %s err, stat = %d, %s", ncOpenGroupInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } else { /* execute it remotely */ ncOpenInp_t myNcOpenGroupInp; bzero( &myNcOpenGroupInp, sizeof( myNcOpenGroupInp ) ); rstrcpy( myNcOpenGroupInp.objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); myNcOpenGroupInp.rootNcid = rootNcid; addKeyVal( &myNcOpenGroupInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcOpenGroup( rodsServerHost->conn, &myNcOpenGroupInp, &myncid ); clearKeyVal( &myNcOpenGroupInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: rcNcOpenGroup %s error, status = %d", myNcOpenGroupInp.objPath, status ); return ( status ); } } l1descInx = allocL1desc(); l1desc_t& new_desc = irods::get_l1desc( l1descInx ); new_desc.dataObjInfo = dataObjInfo = ( dataObjInfo_t * ) calloc( 1, sizeof( dataObjInfo_t ) ); rstrcpy( dataObjInfo->objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); new_desc.l3descInx = myncid; } my_desc.oprType = NC_OPEN_GROUP; *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = l1descInx; return 0; }