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)  

rsDataCopy.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataCopy.h for a description of this API call.*/
5 
6 #include "rcMisc.h"
7 #include "dataCopy.h"
8 #include "rcPortalOpr.h"
9 #include "miscServerFunct.hpp"
10 #include "rsGlobalExtern.hpp"
11 #include "rcGlobalExtern.h"
12 #include "rsDataCopy.hpp"
13 #include "rodsConnect.h"
15 #include "irods_re_structs.hpp"
16 
17 /* rsDataCopy - Do the copy data transfer.
18  * Input -
19  * dataCopyInp_t dataCopyInp:
20  * dataOprInp: - mostly setup by initDataOprInp()
21  * int oprType - SAME_HOST_COPY_OPR, COPY_TO_REM_OPR, COPY_TO_LOCAL_OPR
22  * int numThreads
23  * int srcL3descInx - the source L3descInx
24  * int destL3descInx - the target L3descInx
25  * int srcRescTypeInx;
26  * int destRescTypeInx;
27  * rodsLong_t offset
28  * rodsLong_t dataSize
29  * keyValPair_t condInput - valid input -
30  * EXEC_LOCALLY_KW - all operations except remote-remote copy
31  * have the keyword set.
32  *
33  * portalOprOut_t portalOprOut - the resource server portal info.
34  */
35 int
36 rsDataCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
37  int status;
38  int l3descInx;
40  dataOprInp_t *dataOprInp;
41 
42  dataOprInp = &dataCopyInp->dataOprInp;
43 
44 
45  if ( getValByKey( &dataOprInp->condInput, EXEC_LOCALLY_KW ) != NULL ||
46  dataCopyInp->portalOprOut.numThreads == 0 ) {
47  /* XXXXX do it locally if numThreads == 0 */
48  status = _rsDataCopy( rsComm, dataCopyInp );
49  }
50  else {
51  if ( dataOprInp->destL3descInx > 0 ) {
52  l3descInx = dataOprInp->destL3descInx;
53  }
54  else {
55  l3descInx = dataOprInp->srcL3descInx;
56  }
59  addKeyVal( &dataOprInp->condInput, EXEC_LOCALLY_KW, "" );
60  status = remoteDataCopy( rsComm, dataCopyInp, rodsServerHost );
61  clearKeyVal( &dataOprInp->condInput );
62  }
63  else {
64  status = _rsDataCopy( rsComm, dataCopyInp );
65  }
66  }
67  return status;
68 }
69 
70 int
71 remoteDataCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp,
73  int status;
74 
75  if ( rodsServerHost == NULL ) {
77  "remoteDataCopy: Invalid rodsServerHost" );
79  }
80 
81  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
82  return status;
83  }
84 
85  dataCopyInp->dataOprInp.srcL3descInx =
86  convL3descInx( dataCopyInp->dataOprInp.srcL3descInx );
87  dataCopyInp->dataOprInp.destL3descInx =
88  convL3descInx( dataCopyInp->dataOprInp.destL3descInx );
89 
90  status = rcDataCopy( rodsServerHost->conn, dataCopyInp );
91 
92  if ( status < 0 ) {
94  "remoteDataCopy: rcDataCopy failed" );
95  }
96 
97  return status;
98 }
99 
100 static
101 int
103  if (rsComm == NULL) {
104  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: NULL rsComm");
106  }
107 
108  if (dataOprInp == NULL) {
109  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: NULL dataOprInp");
111  }
112 
113  const int l3_index = dataOprInp->destL3descInx;
114  if (l3_index < 3 || l3_index >= NUM_FILE_DESC) {
115  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: bad l3 descriptor index %d", l3_index);
117  }
118 
119  const char* resource_hierarchy = FileDesc[l3_index].rescHier;
120  if (resource_hierarchy == NULL) {
121  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: NULL resource_hierarchy");
123  }
124 
125  irods::hierarchy_parser hierarchy_parser;
126  irods::error err = hierarchy_parser.set_string(resource_hierarchy);
127  if (!err.ok()) {
128  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: set_string error [%s]", err.result().c_str());
129  return err.status();
130  }
131 
132  std::string leaf_resource;
133  err = hierarchy_parser.last_resc(leaf_resource);
134  if (!err.ok()) {
135  rodsLog(LOG_ERROR, "apply_acPostProcForDataCopyReceived: last_resc error [%s]", err.result().c_str());
136  return err.status();
137  }
138 
139  const char *args[] = {leaf_resource.c_str()};
140  ruleExecInfo_t rei;
141  memset(&rei, 0, sizeof(rei));
142  rei.rsComm = rsComm;
143  int ret = applyRuleArg("acPostProcForDataCopyReceived", args, sizeof(args)/sizeof(args[0]), &rei, NO_SAVE_REI);
144  return ret;
145 }
146 
147 int
148 _rsDataCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
149  dataOprInp_t *dataOprInp;
150  int retVal;
151 
152  if ( dataCopyInp == NULL ) {
154  "_rsDataCopy: NULL dataCopyInp input" );
156  }
157 
158  dataOprInp = &dataCopyInp->dataOprInp;
159  if ( dataOprInp->oprType == SAME_HOST_COPY_OPR ) {
160  /* src is on the same host */
161  retVal = sameHostCopy( rsComm, dataCopyInp );
162  if (retVal >= 0) {
163  apply_acPostProcForDataCopyReceived(rsComm, dataOprInp);
164  }
165  }
166  else if ( dataOprInp->oprType == COPY_TO_LOCAL_OPR ||
167  dataOprInp->oprType == COPY_TO_REM_OPR ) {
168  retVal = remLocCopy( rsComm, dataCopyInp );
169  if (retVal >= 0 && dataOprInp->oprType == COPY_TO_LOCAL_OPR) {
170  apply_acPostProcForDataCopyReceived(rsComm, dataOprInp);
171  }
172  }
173  else {
175  "_rsDataCopy: Invalid oprType %d", dataOprInp->oprType );
176  return SYS_INVALID_OPR_TYPE;
177  }
178 
179  return retVal;
180 }
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
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
DataOprInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:134
rsDataCopy
int rsDataCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: rsDataCopy.cpp:36
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
rsDataCopy.hpp
remLocCopy
int remLocCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:1321
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
DataOprInp::srcL3descInx
int srcL3descInx
Definition: dataObjInpOut.h:125
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
rcMisc.h
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
rcDataCopy
int rcDataCopy(rcComm_t *conn, dataCopyInp_t *dataCopyInp)
Definition: rcDataCopy.cpp:35
DataCopyInp
Definition: dataCopy.h:7
rcGlobalExtern.h
SAME_HOST_COPY_OPR
#define SAME_HOST_COPY_OPR
Definition: dataObjInpOut.h:169
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
remoteDataCopy
int remoteDataCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp, rodsServerHost_t *rodsServerHost)
Definition: rsDataCopy.cpp:71
rodsConnect.h
SYS_INVALID_OPR_TYPE
@ SYS_INVALID_OPR_TYPE
Definition: rodsErrorTable.h:102
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
sameHostCopy
int sameHostCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:1496
rsGlobalExtern.hpp
EXEC_LOCALLY_KW
#define EXEC_LOCALLY_KW
Definition: rodsKeyWdDef.h:12
irods::hierarchy_parser::last_resc
error last_resc(std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:109
apply_acPostProcForDataCopyReceived
static int apply_acPostProcForDataCopyReceived(rsComm_t *rsComm, dataOprInp_t *dataOprInp)
Definition: rsDataCopy.cpp:102
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
fileDesc_t::rodsServerHost
rodsServerHost_t * rodsServerHost
Definition: fileOpr.hpp:26
COPY_TO_REM_OPR
#define COPY_TO_REM_OPR
Definition: dataObjInpOut.h:171
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
COPY_TO_LOCAL_OPR
#define COPY_TO_LOCAL_OPR
Definition: dataObjInpOut.h:170
convL3descInx
int convL3descInx(int l3descInx)
Definition: objDesc.cpp:571
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rcPortalOpr.h
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
DataCopyInp::portalOprOut
portalOprOut_t portalOprOut
Definition: dataCopy.h:9
irods_hierarchy_parser.hpp
rodsServerHost
Definition: rodsConnect.h:62
dataCopy.h
_rsDataCopy
int _rsDataCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: rsDataCopy.cpp:148
RuleExecInfo
Definition: irods_re_structs.hpp:18
irods_re_structs.hpp
portalOprOut::numThreads
int numThreads
Definition: dataObjInpOut.h:117
DataOprInp
Definition: dataObjInpOut.h:122
DataOprInp::destL3descInx
int destL3descInx
Definition: dataObjInpOut.h:126
NUM_FILE_DESC
#define NUM_FILE_DESC
Definition: fileOpr.hpp:16
irods::error::status
bool status() const
Definition: irods_error.cpp:187
DataCopyInp::dataOprInp
dataOprInp_t dataOprInp
Definition: dataCopy.h:8
DataOprInp::oprType
int oprType
Definition: dataObjInpOut.h:123
SYS_FILE_DESC_OUT_OF_RANGE
@ SYS_FILE_DESC_OUT_OF_RANGE
Definition: rodsErrorTable.h:87
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::error::result
std::string result() const
Definition: irods_error.cpp:201