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)  

rsSubStructFileGet.cpp
Go to the documentation of this file.
1 
3 #include "subStructFileGet.h"
4 #include "miscServerFunct.hpp"
5 #include "dataObjOpr.hpp"
6 #include "rsSubStructFileGet.hpp"
7 
8 // =-=-=-=-=-=-=-
10 #include "irods_error.hpp"
11 #include "irods_stacktrace.hpp"
12 
13 int
15  bytesBuf_t *subFileGetOutBBuf ) {
17  int remoteFlag;
18  int status;
19 
20  remoteFlag = resolveHost( &subFile->addr, &rodsServerHost );
21 
22  if ( remoteFlag == LOCAL_HOST ) {
23  status = _rsSubStructFileGet( rsComm, subFile, subFileGetOutBBuf );
24  }
25  else if ( remoteFlag == REMOTE_HOST ) {
26  status = remoteSubStructFileGet( rsComm, subFile, subFileGetOutBBuf,
28  }
29  else {
30  if ( remoteFlag < 0 ) {
31  return remoteFlag;
32  }
33  else {
35  "rsSubStructFileGet: resolveHost returned unrecognized value %d",
36  remoteFlag );
38  }
39  }
40 
41  return status;
42 }
43 
44 int
46  bytesBuf_t *subFileGetOutBBuf, rodsServerHost_t *rodsServerHost ) {
47  int status;
48 
49  if ( rodsServerHost == NULL ) {
51  "remoteSubStructFileGet: Invalid rodsServerHost" );
53  }
54 
55  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
56  return status;
57  }
58 
60  subFileGetOutBBuf );
61 
62  if ( status < 0 ) {
64  "remoteSubStructFileGet: rcSubStructFileGet failed for %s, status = %d",
65  subFile->subFilePath, status );
66  }
67 
68  return status;
69 }
70 
72  subFile_t* _sub_file,
73  bytesBuf_t* _out_buf ) {
74  // =-=-=-=-=-=-=-
75  // convert subfile to a first class object
78  *_sub_file ) );
79  struct_obj->comm( _comm );
80  struct_obj->resc_hier( _sub_file->specColl->rescHier );
81 
82  if ( _sub_file->offset <= 0 ) {
83  irods::log( ERROR( SYS_INVALID_INPUT_PARAM, "invalid length" ) );
84  return -1;
85  }
86 
87  // =-=-=-=-=-=-=-
88  // open the structured object
89  irods::error open_err = fileOpen( _comm, struct_obj );
90  if ( !open_err.ok() ) {
91  std::stringstream msg;
92  msg << "fileOpen error for [";
93  msg << struct_obj->sub_file_path();
94  msg << "], status = ";
95  msg << open_err.code();
96  irods::log( PASSMSG( msg.str(), open_err ) );
97  return open_err.code();
98  }
99 
100  // =-=-=-=-=-=-=-
101  // allocte outgoing buffer if necessary
102  if ( _out_buf->buf == NULL ) {
103  _out_buf->buf = new unsigned char[ _sub_file->offset ];
104  }
105 
106  // =-=-=-=-=-=-=-
107  // read structured file
108  irods::error read_err = fileRead( _comm, struct_obj, _out_buf->buf, _sub_file->offset );
109  int status = read_err.code();
110 
111  if ( !read_err.ok() ) {
112  if ( status >= 0 ) {
113  std::stringstream msg;
114  msg << "failed in fileRead for [";
115  msg << struct_obj->sub_file_path();
116  msg << ", toread ";
117  msg << _sub_file->offset;
118  msg << ", read ";
119  msg << read_err.code();
120  irods::log( PASSMSG( msg.str(), read_err ) );
121 
123  }
124  else {
125  std::stringstream msg;
126  msg << "failed in fileRead for [";
127  msg << struct_obj->sub_file_path();
128  msg << ", status = ";
129  msg << read_err.code();
130  irods::log( PASSMSG( msg.str(), read_err ) );
131 
132  status = read_err.code();
133  }
134 
135  }
136  else {
137  _out_buf->len = read_err.code();
138  }
139 
140  // =-=-=-=-=-=-=-
141  // ok, done with that. close the file.
142  irods::error close_err = fileClose( _comm, struct_obj );
143  if ( !close_err.ok() ) {
144  std::stringstream msg;
145  msg << "failed in fileClose for [";
146  msg << struct_obj->sub_file_path();
147  msg << ", status = ";
148  msg << close_err.code();
149  irods::log( PASSMSG( msg.str(), read_err ) );
150  }
151 
152  return status;
153 
154 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
Subfile::offset
rodsLong_t offset
Definition: objInfo.h:321
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
Subfile
Definition: objInfo.h:316
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_stacktrace.hpp
Subfile::subFilePath
char subFilePath[(1024+64)]
Definition: objInfo.h:318
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
Subfile::specColl
specColl_t * specColl
Definition: objInfo.h:322
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
BytesBuf::len
int len
Definition: rodsDef.h:198
rsSubStructFileGet.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
SYS_COPY_LEN_ERR
@ SYS_COPY_LEN_ERR
Definition: rodsErrorTable.h:95
rsSubStructFileGet
int rsSubStructFileGet(rsComm_t *rsComm, subFile_t *subFile, bytesBuf_t *subFileGetOutBBuf)
Definition: rsSubStructFileGet.cpp:14
remoteSubStructFileGet
int remoteSubStructFileGet(rsComm_t *rsComm, subFile_t *subFile, bytesBuf_t *subFileGetOutBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsSubStructFileGet.cpp:45
irods::structured_object
Definition: irods_structured_object.hpp:15
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
subStructFileGet.h
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
SpecColl::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:84
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::structured_object_ptr
boost::shared_ptr< structured_object > structured_object_ptr
Definition: irods_structured_object.hpp:107
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
fileOpen
irods::error fileOpen(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:49
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileClose
irods::error fileClose(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:147
rodsServerHost
Definition: rodsConnect.h:62
irods_error.hpp
rcSubStructFileGet
int rcSubStructFileGet(rcComm_t *conn, subFile_t *subFile, bytesBuf_t *subFileGetOutBBuf)
Definition: rcSubStructFileGet.cpp:24
irods_structured_object.hpp
dataObjOpr.hpp
_rsSubStructFileGet
int _rsSubStructFileGet(rsComm_t *_comm, subFile_t *_sub_file, bytesBuf_t *_out_buf)
Definition: rsSubStructFileGet.cpp:71
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
fileRead
irods::error fileRead(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:81
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375