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)  

rsSubStructFilePut.cpp
Go to the documentation of this file.
1 
3 #include "subStructFilePut.h"
4 #include "miscServerFunct.hpp"
5 #include "dataObjOpr.hpp"
6 #include "rsSubStructFilePut.hpp"
7 
9 #include "irods_stacktrace.hpp"
10 #include "irods_log.hpp"
11 
12 int
14  bytesBuf_t *subFilePutOutBBuf ) {
16  int remoteFlag;
17  int status;
18  remoteFlag = resolveHost( &subFile->addr, &rodsServerHost );
19 
20  if ( remoteFlag == LOCAL_HOST ) {
21  status = _rsSubStructFilePut( rsComm, subFile, subFilePutOutBBuf );
22  }
23  else if ( remoteFlag == REMOTE_HOST ) {
24  status = remoteSubStructFilePut( rsComm, subFile, subFilePutOutBBuf,
26  }
27  else {
28  if ( remoteFlag < 0 ) {
29  return remoteFlag;
30  }
31  else {
33  "rsSubStructFilePut: resolveHost returned unrecognized value %d",
34  remoteFlag );
36  }
37  }
38 
39  return status;
40 }
41 
42 int
44  bytesBuf_t *subFilePutOutBBuf, rodsServerHost_t *rodsServerHost ) {
45  int status;
46 
47  if ( rodsServerHost == NULL ) {
49  "remoteSubStructFilePut: Invalid rodsServerHost" );
51  }
52 
53  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
54  return status;
55  }
56 
58  subFilePutOutBBuf );
59 
60  if ( status < 0 ) {
62  "remoteSubStructFilePut: rcSubStructFilePut failed for %s, status = %d",
63  subFile->subFilePath, status );
64  }
65 
66  return status;
67 }
68 
69 int
71  subFile_t* _sub_file,
72  bytesBuf_t* _out_buf ) {
73  int status = -1;
74  int fd = -1;
75 
76  // =-=-=-=-=-=-=-
77  // create a structured object on which to operate
80  *_sub_file ) );
81  struct_obj->comm( _comm );
82  struct_obj->resc_hier( _sub_file->specColl->rescHier );
83 
84  // =-=-=-=-=-=-=-
85  // force the opening of a file?
86  if ( _sub_file->flags & FORCE_FLAG ) {
87  irods::error err = fileOpen( _comm, struct_obj );
88  if ( !err.ok() ) {
89  std::stringstream msg;
90  msg << "failed on call to fileCreate for [";
91  msg << struct_obj->sub_file_path();
92  irods::log( PASSMSG( msg.str(), err ) );
93  fd = -1;
94 
95  }
96  else {
97  fd = err.code();
98  }
99 
100  }
101  else {
102  irods::error err = fileCreate( _comm, struct_obj );
103  if ( !err.ok() ) {
104  std::stringstream msg;
105  msg << "failed on call to fileCreate for [";
106  msg << struct_obj->sub_file_path();
107  irods::log( PASSMSG( msg.str(), err ) );
108  fd = -1;
109 
110  }
111  else {
112  fd = err.code();
113  }
114 
115  }
116 
117  // =-=-=-=-=-=-=-
118  // more error trapping, etc.
119  if ( fd < 0 ) {
120  if ( getErrno( fd ) == EEXIST ) {
122  "_rsSubStructFilePut: filePut for %s, status = %d",
123  _sub_file->subFilePath, fd );
124  }
125  else {
127  "_rsSubStructFilePut: subStructFileOpen error for %s, stat=%d",
128  _sub_file->subFilePath, fd );
129  }
130  return fd;
131  }
132 
133  //status = subStructFileWrite (_sub_file->specColl->type, _comm,
134  // fd, _out_buf->buf, _out_buf->len);
135  // =-=-=-=-=-=-=-
136  // write the buffer to our structured file
137  irods::error write_err = fileWrite( _comm, struct_obj, _out_buf->buf, _out_buf->len );
138  if ( !write_err.ok() ) {
139  std::stringstream msg;
140  msg << "failed on call to fileWrite for [";
141  msg << struct_obj->sub_file_path();
142  irods::log( PASSMSG( msg.str(), write_err ) );
143  status = write_err.code();
144 
145  }
146  else {
147  status = write_err.code();
148 
149  }
150 
151  // =-=-=-=-=-=-=-
152  // more error trapping, etc.
153  if ( status != _out_buf->len ) {
154  if ( status >= 0 ) {
156  "_rsSubStructFilePut:Write error for %s,towrite %d,read %d",
157  _sub_file->subFilePath, _out_buf->len, status );
159  }
160  else {
162  "_rsSubStructFilePut: Write error for %s, status = %d",
163  _sub_file->subFilePath, status );
164  }
165  }
166 
167  // =-=-=-=-=-=-=-
168  // close up our file after writing
169  irods::error close_err = fileClose( _comm, struct_obj );
170  if ( !close_err.ok() ) {
171  std::stringstream msg;
172  msg << "failed on call to fileWrite for [";
173  msg << struct_obj->sub_file_path();
174  irods::log( PASSMSG( msg.str(), close_err ) );
175  status = close_err.code();
176 
177  }
178 
179  return status;
180 
181 } // _rsSubStructFilePut
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
subStructFilePut.h
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
_rsSubStructFilePut
int _rsSubStructFilePut(rsComm_t *_comm, subFile_t *_sub_file, bytesBuf_t *_out_buf)
Definition: rsSubStructFilePut.cpp:70
BytesBuf::len
int len
Definition: rodsDef.h:198
remoteSubStructFilePut
int remoteSubStructFilePut(rsComm_t *rsComm, subFile_t *subFile, bytesBuf_t *subFilePutOutBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsSubStructFilePut.cpp:43
irods::error::code
long long code() const
Definition: irods_error.cpp:194
SYS_COPY_LEN_ERR
@ SYS_COPY_LEN_ERR
Definition: rodsErrorTable.h:95
fileWrite
irods::error fileWrite(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:113
irods::structured_object
Definition: irods_structured_object.hpp:15
getErrno
int getErrno(int errCode)
Definition: rcMisc.cpp:3261
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
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
fileCreate
irods::error fileCreate(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:17
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
fileOpen
irods::error fileOpen(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:49
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
LOG_DEBUG10
#define LOG_DEBUG10
Definition: rodsLog.h:19
rcSubStructFilePut
int rcSubStructFilePut(rcComm_t *conn, subFile_t *subFile, bytesBuf_t *subFilePutOutBBuf)
Definition: rcSubStructFilePut.cpp:24
irods_structured_object.hpp
dataObjOpr.hpp
rsSubStructFilePut
int rsSubStructFilePut(rsComm_t *rsComm, subFile_t *subFile, bytesBuf_t *subFilePutOutBBuf)
Definition: rsSubStructFilePut.cpp:13
FORCE_FLAG
#define FORCE_FLAG
Definition: fileOpen.h:12
rsSubStructFilePut.hpp
Subfile::flags
int flags
Definition: objInfo.h:320
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_log.hpp
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375