irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rcDataObjGet.cpp
Go to the documentation of this file.
1 
6 
8 /* This is script-generated code. */
9 /* See dataObjGet.h for a description of this API call.*/
10 
11 // =-=-=-=-=-=-=-
12 // irods includes
13 #include "dataObjGet.h"
14 #include "procApiRequest.h"
15 #include "apiNumber.h"
16 #include "rcPortalOpr.h"
17 #include "apiHeaderAll.h"
18 #include "sockComm.h"
19 
20 // =-=-=-=-=-=-=-
23 #include "irods_stacktrace.hpp"
24 #include "checksum.hpp"
25 
90 int
91 rcDataObjGet( rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath ) {
92 #ifndef windows_platform
93  struct stat statbuf;
94 #else
95  struct irodsntstat statbuf;
96 #endif
97 
98  if ( strcmp( locFilePath, STDOUT_FILE_NAME ) == 0 ) {
99  /* no parallel I/O if pipe to stdout */
100  dataObjInp->numThreads = NO_THREADING;
101  }
102 #ifndef windows_platform
103  else if ( stat( locFilePath, &statbuf ) >= 0 )
104 #else
105  else if ( iRODSNt_stat( locFilePath, &statbuf ) >= 0 )
106 #endif
107  {
108  /* local file exists */
109  if ( getValByKey( &dataObjInp->condInput, FORCE_FLAG_KW ) == NULL ) {
111  }
112  }
113 
115  bytesBuf_t dataObjOutBBuf;
116  int status = _rcDataObjGet( conn, dataObjInp, &portalOprOut, &dataObjOutBBuf );
117 
118  if ( status < 0 ) {
119  free( portalOprOut );
120  return status;
121  }
122 
123  if ( status == 0 || dataObjOutBBuf.len > 0 ) {
124  /* data included */
125  status = getIncludeFile( conn, &dataObjOutBBuf, locFilePath );
126  free( dataObjOutBBuf.buf );
127  }
128  else if ( !portalOprOut ) {
129  rodsLog( LOG_ERROR, "_rcDataObjGet returned a %d status code, but left portalOprOut null.", status );
130  return SYS_INVALID_PORTAL_OPR;
131  }
132  else if ( getUdpPortFromPortList( &portalOprOut->portList ) != 0 ) {
133  int veryVerbose;
134  /* rbudp transfer */
135  /* some sanity check */
136  if ( portalOprOut->numThreads != 1 ) {
138  free( portalOprOut );
139  return SYS_INVALID_PORTAL_OPR;
140  }
142  if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) {
143  printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n",
146  veryVerbose = 2;
147  }
148  else {
149  veryVerbose = 0;
150  }
151 
152  // =-=-=-=-=-=-=-
153  // if a secret has been negotiated then we must be using
154  // encryption. given that RBUDP is not supported in an
155  // encrypted capacity this is considered an error
157  rodsLog(
158  LOG_ERROR,
159  "getFileToPortal: Encryption is not supported with RBUDP" );
160  return SYS_INVALID_PORTAL_OPR;
161 
162  }
163 
165  portalOprOut,
166  locFilePath, 0,
167  veryVerbose, 0 );
168 
169  /* just send a complete msg */
170  if ( status < 0 ) {
171  rcOprComplete( conn, status );
172 
173  }
174  else {
176  }
177  }
178  else {
179 
180  if ( portalOprOut->numThreads <= 0 ) {
182  locFilePath, dataObjInp->objPath, dataObjInp->dataSize );
183  }
184  else {
185  if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) {
186  printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n",
189  }
190 
191  /* some sanity check */
192  rodsEnv env;
193  getRodsEnv( &env );
194  if ( portalOprOut->numThreads >= 20 * env.irodsDefaultNumberTransferThreads ) {
196  free( portalOprOut );
197  return SYS_INVALID_PORTAL_OPR;
198  }
199 
201  status = getFileFromPortal( conn, portalOprOut, locFilePath,
202  dataObjInp->objPath, dataObjInp->dataSize );
203  }
204  /* just send a complete msg */
205  if ( status < 0 ) {
206  rcOprComplete( conn, status );
207  }
208  else {
210  }
211  }
212 
213  if ( status >= 0 && conn->fileRestart.info.numSeg > 0 ) { /* file restart */
215  }
216 
217  if ( getValByKey( &dataObjInp->condInput, VERIFY_CHKSUM_KW ) != NULL ) {
218  if ( portalOprOut == NULL || strlen( portalOprOut->chksum ) == 0 ) {
220  "rcDataObjGet: VERIFY_CHKSUM_KW set but no checksum from server" );
221  }
222  else {
223 
224  status = verifyChksumLocFile( locFilePath, portalOprOut->chksum, NULL );
225  if ( status == USER_CHKSUM_MISMATCH ) {
227  "rcDataObjGet: checksum mismatch error for %s, status = %d",
228  locFilePath, status );
229  if ( portalOprOut != NULL ) {
230  free( portalOprOut );
231  }
232  return status;
233  }
234  else if ( status < 0 ) {
236  "rcDataObjGet: chksumLocFile error for %s, status = %d",
237  locFilePath, status );
238  if ( portalOprOut != NULL ) {
239  free( portalOprOut );
240  }
241  return status;
242  }
243 
244  }
245  }
246  free( portalOprOut );
247 
248  return status;
249 }
250 
251 int
252 _rcDataObjGet( rcComm_t *conn, dataObjInp_t *dataObjInp,
253  portalOprOut_t **portalOprOut, bytesBuf_t *dataObjOutBBuf ) {
254  int status;
255 
256  *portalOprOut = NULL;
257 
258  memset( &conn->transStat, 0, sizeof( transStat_t ) );
259 
260  memset( dataObjOutBBuf, 0, sizeof( bytesBuf_t ) );
261 
262  dataObjInp->oprType = GET_OPR;
263 
264  status = procApiRequest( conn, DATA_OBJ_GET_AN, dataObjInp, NULL,
265  ( void ** ) portalOprOut, dataObjOutBBuf );
266 
267  if ( *portalOprOut != NULL && ( *portalOprOut )->l1descInx < 0 ) {
268  status = ( *portalOprOut )->l1descInx;
269  }
270 
271  return status;
272 }
273 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
fileRestart_t::info
fileRestartInfo_t info
Definition: rcConnect.h:85
DATA_OBJ_GET_AN
#define DATA_OBJ_GET_AN
Definition: apiNumber.h:46
getRodsEnv
int getRodsEnv(rodsEnv *myRodsEnv)
Definition: getRodsEnv.cpp:112
irods_server_properties.hpp
portalOprOut
Definition: dataObjInpOut.h:114
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
irods_stacktrace.hpp
DataObjInp::dataSize
rodsLong_t dataSize
Definition: dataObjInpOut.h:70
fileRestartInfo_t::numSeg
int numSeg
Definition: rcConnect.h:75
env
Definition: restructs.hpp:226
checksum.hpp
getUdpPortFromPortList
int getUdpPortFromPortList(portList_t *thisPortList)
Definition: sockComm.cpp:1475
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
NO_THREADING
#define NO_THREADING
Definition: rodsDef.h:100
_rcDataObjGet
int _rcDataObjGet(rcComm_t *conn, dataObjInp_t *dataObjInp, portalOprOut_t **portalOprOut, bytesBuf_t *dataObjOutBBuf)
Definition: rcDataObjGet.cpp:252
GET_OPR
#define GET_OPR
Definition: dataObjInpOut.h:168
getIncludeFile
int getIncludeFile(rcComm_t *conn, bytesBuf_t *dataObjOutBBuf, char *locFilePath)
Definition: rcPortalOpr.cpp:639
BytesBuf::len
int len
Definition: rodsDef.h:198
portList_t::portNum
int portNum
Definition: dataObjInpOut.h:30
verifyChksumLocFile
int verifyChksumLocFile(char *fileName, const char *myChksum, char *chksumStr)
Definition: checksum.cpp:178
transferStat_t::numThreads
int numThreads
Definition: objInfo.h:292
procApiRequest.h
VERY_VERBOSE_KW
#define VERY_VERBOSE_KW
Definition: rodsKeyWdDef.h:77
rcDataObjGet
int rcDataObjGet(rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath)
Definition: rcDataObjGet.cpp:91
irods::CS_NEG_USE_SSL
const std::string CS_NEG_USE_SSL("CS_NEG_USE_SSL")
DataObjInp
Definition: dataObjInpOut.h:65
getFile
int getFile(rcComm_t *conn, int l1descInx, char *locFilePath, char *objPath, rodsLong_t dataSize)
Definition: rcPortalOpr.cpp:688
getFileToPortalRbudp
int getFileToPortalRbudp(portalOprOut_t *portalOprOut, char *locFilePath, int locFd, int veryVerbose, int packetSize)
Definition: rcPortalOpr.cpp:1281
portalOprOut::portList
portList_t portList
Definition: dataObjInpOut.h:119
rcOprComplete
int rcOprComplete(rcComm_t *conn, int retval)
Definition: rcOprComplete.cpp:32
transStat_t
Definition: objInfo.h:286
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rcPortalOpr.h
rcComm_t::fileRestart
fileRestart_t fileRestart
Definition: rcConnect.h:135
BytesBuf
Definition: rodsDef.h:197
portalOprOut::l1descInx
int l1descInx
Definition: dataObjInpOut.h:116
apiNumber.h
procApiRequest
int procApiRequest(rcComm_t *conn, int apiNumber, void *inputStruct, bytesBuf_t *inputBsBBuf, void **outStruct, bytesBuf_t *outBsBBuf)
Definition: procApiRequest.cpp:55
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
portalOprOut::chksum
char chksum[64]
Definition: dataObjInpOut.h:118
apiHeaderAll.h
DataObjInp::oprType
int oprType
Definition: dataObjInpOut.h:72
OVERWRITE_WITHOUT_FORCE_FLAG
@ OVERWRITE_WITHOUT_FORCE_FLAG
Definition: rodsErrorTable.h:243
VERIFY_CHKSUM_KW
#define VERIFY_CHKSUM_KW
Definition: rodsKeyWdDef.h:16
SYS_INVALID_PORTAL_OPR
@ SYS_INVALID_PORTAL_OPR
Definition: rodsErrorTable.h:101
portalOprOut::numThreads
int numThreads
Definition: dataObjInpOut.h:117
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
rcComm_t::transStat
transferStat_t transStat
Definition: rcConnect.h:108
sockComm.h
getFileFromPortal
int getFileFromPortal(rcComm_t *conn, portalOprOut_t *portalOprOut, char *locFilePath, char *objPath, rodsLong_t dataSize)
Definition: rcPortalOpr.cpp:833
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
portList_t::cookie
int cookie
Definition: dataObjInpOut.h:31
rodsEnv
Definition: getRodsEnv.h:8
DataObjInp::numThreads
int numThreads
Definition: dataObjInpOut.h:71
dataObjGet.h
portList_t::hostAddr
char hostAddr[256]
Definition: dataObjInpOut.h:34
STDOUT_FILE_NAME
#define STDOUT_FILE_NAME
Definition: rodsPath.h:16
USER_CHKSUM_MISMATCH
@ USER_CHKSUM_MISMATCH
Definition: rodsErrorTable.h:245
irods_client_server_negotiation.hpp
rcComm_t::negotiation_results
char negotiation_results[(1024+64)]
Definition: rcConnect.h:125
clearLfRestartFile
int clearLfRestartFile(fileRestart_t *fileRestart)
Definition: rcPortalOpr.cpp:1535