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)  

rsFileWrite.cpp
Go to the documentation of this file.
1 
3 /* rsFileWrite.c - server routine that handles the fileWrite
4  * API
5  */
6 
7 /* script generated code */
8 #include "fileWrite.h"
9 #include "miscServerFunct.hpp"
10 #include "rsGlobalExtern.hpp"
11 #include "rsFileWrite.hpp"
12 #include <sstream>
13 
14 // =-=-=-=-=-=-=-
15 #include "irods_log.hpp"
16 #include "irods_file_object.hpp"
17 #include "irods_stacktrace.hpp"
18 
19 int
20 rsFileWrite( rsComm_t *rsComm, fileWriteInp_t *fileWriteInp,
21  bytesBuf_t *fileWriteInpBBuf ) {
23  int remoteFlag;
24  int retVal;
25 
26  remoteFlag = getServerHostByFileInx( fileWriteInp->fileInx,
27  &rodsServerHost );
28 
29  if ( remoteFlag == LOCAL_HOST ) {
30  retVal = _rsFileWrite( rsComm, fileWriteInp, fileWriteInpBBuf );
31  }
32  else if ( remoteFlag == REMOTE_HOST ) {
33  retVal = remoteFileWrite( rsComm, fileWriteInp, fileWriteInpBBuf,
35  }
36  else {
37  if ( remoteFlag < 0 ) {
38  return remoteFlag;
39  }
40  else {
42  "rsFileWrite: resolveHost returned unrecognized value %d",
43  remoteFlag );
45  }
46  }
47 
48  if ( retVal >= 0 ) {
49  FileDesc[fileWriteInp->fileInx].writtenFlag = 1;
50  }
51 
52  return retVal;
53 }
54 
55 int
56 remoteFileWrite( rsComm_t *rsComm, fileWriteInp_t *fileWriteInp,
57  bytesBuf_t *fileWriteInpBBuf, rodsServerHost_t *rodsServerHost ) {
58  int retVal;
59 
60  if ( rodsServerHost == NULL ) {
62  "remoteFileWrite: Invalid rodsServerHost" );
64  }
65 
66  if ( ( retVal = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
67  return retVal;
68  }
69 
70  fileWriteInp->fileInx = convL3descInx( fileWriteInp->fileInx );
71  retVal = rcFileWrite( rodsServerHost->conn, fileWriteInp,
72  fileWriteInpBBuf );
73 
74  if ( retVal < 0 ) {
76  "remoteFileWrite: rcFileWrite failed for %s",
77  FileDesc[fileWriteInp->fileInx].fileName );
78  }
79 
80  return retVal;
81 }
82 
83 // =-=-=-=-=-=-=-
84 // _rsFileWrite - this the local version of rsFileWrite.
86  rsComm_t* _comm,
87  fileWriteInp_t* _write_inp,
88  bytesBuf_t* _write_bbuf ) {
89  // =-=-=-=-=-=-=-
90  // XXXX need to check resource permission and vault permission
91  // when RCAT is available
92 
93  // =-=-=-=-=-=-=-
94  // make a call to the resource write
95  irods::file_object_ptr file_obj(
97  _comm,
98  FileDesc[_write_inp->fileInx].objPath,
99  FileDesc[_write_inp->fileInx].fileName,
100  FileDesc[_write_inp->fileInx].rescHier,
101  FileDesc[_write_inp->fileInx].fd,
102  0, 0 ) );
103 
104  irods::error write_err = fileWrite( _comm,
105  file_obj,
106  _write_bbuf->buf,
107  _write_inp->len );
108  // =-=-=-=-=-=-=-
109  // log error if necessary
110  if ( !write_err.ok() ) {
111  std::stringstream msg;
112  msg << "fileWrite for [";
113  msg << file_obj->physical_path();
114  msg << "]";
115  irods::error err = PASSMSG( msg.str(), write_err );
116  irods::log( err );
117  }
118 
119  return write_err.code();
120 
121 } // _rsFileWrite
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
rsFileWrite.hpp
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rcFileWrite
int rcFileWrite(rcComm_t *conn, fileWriteInp_t *fileWriteInp, bytesBuf_t *fileWriteInpBBuf)
Definition: rcFileWrite.cpp:24
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
getServerHostByFileInx
int getServerHostByFileInx(int fileInx, rodsServerHost_t **rodsServerHost)
Definition: fileOpr.cpp:99
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
fileWriteInp_t
Definition: fileWrite.h:7
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileWriteInp_t::len
int len
Definition: fileWrite.h:9
rsFileWrite
int rsFileWrite(rsComm_t *rsComm, fileWriteInp_t *fileWriteInp, bytesBuf_t *fileWriteInpBBuf)
Definition: rsFileWrite.cpp:20
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
_rsFileWrite
int _rsFileWrite(rsComm_t *_comm, fileWriteInp_t *_write_inp, bytesBuf_t *_write_bbuf)
Definition: rsFileWrite.cpp:85
fileWrite.h
rsGlobalExtern.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
remoteFileWrite
int remoteFileWrite(rsComm_t *rsComm, fileWriteInp_t *fileWriteInp, bytesBuf_t *fileWriteInpBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsFileWrite.cpp:56
fileWriteInp_t::fileInx
int fileInx
Definition: fileWrite.h:8
fileDesc_t::objPath
char * objPath
Definition: fileOpr.hpp:29
fileWrite
irods::error fileWrite(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:113
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
convL3descInx
int convL3descInx(int l3descInx)
Definition: objDesc.cpp:571
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
fileDesc_t::writtenFlag
int writtenFlag
Definition: fileOpr.hpp:33
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
fileDesc_t::fd
int fd
Definition: fileOpr.hpp:32
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
fileDesc_t::fileName
char * fileName
Definition: fileOpr.hpp:27
irods_log.hpp