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)  

rsCollRepl.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjRepl.h for a description of this API call.*/
5 
6 #include "collRepl.h"
7 #include "dataObjOpr.hpp"
8 #include "rodsLog.h"
9 #include "objMetaOpr.hpp"
10 #include "rsCollRepl.hpp"
11 #include "openCollection.h"
12 #include "readCollection.h"
13 #include "closeCollection.h"
14 #include "dataObjRepl.h"
15 #include "rsApiHandler.hpp"
16 #include "getRemoteZoneResc.h"
17 #include "rsOpenCollection.hpp"
18 #include "rsCloseCollection.hpp"
19 #include "rsReadCollection.hpp"
20 #include "rsDataObjRepl.hpp"
21 
22 /* rsCollRepl - The Api handler of the rcCollRepl call - Replicate
23  * a data object.
24  * Input -
25  * rsComm_t *rsComm
26  * dataObjInp_t *collReplInp - The replication input
27  * collOprStat_t **collOprStat - transfer stat output. If it is an
28  * internal server call, collOprStat must be NULL
29  */
30 
31 int
32 rsCollRepl( rsComm_t *rsComm, collInp_t *collReplInp,
33  collOprStat_t **collOprStat ) {
34  int status;
35  dataObjInp_t dataObjInp;
36  int handleInx;
37  transferStat_t myTransStat;
38  int totalFileCnt = 0;
39  int fileCntPerStatOut;
40  int savedStatus = 0;
41  int remoteFlag;
43 
44  /* try to connect to dest resc */
45  bzero( &dataObjInp, sizeof( dataObjInp ) );
46  rstrcpy( dataObjInp.objPath, collReplInp->collName, MAX_NAME_LEN );
47  remoteFlag = getAndConnRemoteZone( rsComm, &dataObjInp, &rodsServerHost,
48  REMOTE_CREATE );
49 
50  if ( remoteFlag < 0 ) {
51  return remoteFlag;
52  }
53  else if ( remoteFlag == REMOTE_HOST ) {
54  int retval;
55  retval = _rcCollRepl( rodsServerHost->conn, collReplInp, collOprStat );
56  if ( retval < 0 ) {
57  return retval;
58  }
60  *collOprStat, retval );
61  return status;
62  }
63 
64  fileCntPerStatOut = FILE_CNT_PER_STAT_OUT;
65  if ( collOprStat != NULL ) {
66  *collOprStat = NULL;
67  }
68  collReplInp->flags = RECUR_QUERY_FG;
69  handleInx = rsOpenCollection( rsComm, collReplInp );
70  if ( handleInx < 0 ) {
72  "rsCollRepl: rsOpenCollection of %s error. status = %d",
73  collReplInp->collName, handleInx );
74  return handleInx;
75  }
76 
77  if ( collOprStat != NULL ) {
78  *collOprStat = ( collOprStat_t* )malloc( sizeof( collOprStat_t ) );
79  memset( *collOprStat, 0, sizeof( collOprStat_t ) );
80  }
81 
82  if ( CollHandle[handleInx].rodsObjStat->specColl != NULL ) {
84  "rsCollRepl: unable to replicate mounted collection %s",
85  collReplInp->collName );
86  rsCloseCollection( rsComm, &handleInx );
87  return 0;
88  }
89 
90  collEnt_t *collEnt = NULL;
91  while ( ( status = rsReadCollection( rsComm, &handleInx, &collEnt ) ) >= 0 ) {
92  if ( collEnt->objType == DATA_OBJ_T ) {
93  if ( totalFileCnt == 0 ) totalFileCnt =
94  CollHandle[handleInx].dataObjSqlResult.totalRowCount;
95 
96  bzero( &dataObjInp, sizeof( dataObjInp ) );
97  snprintf( dataObjInp.objPath, MAX_NAME_LEN, "%s/%s",
98  collEnt->collName, collEnt->dataName );
99  dataObjInp.condInput = collReplInp->condInput;
100 
101  memset( &myTransStat, 0, sizeof( myTransStat ) );
102  status = _rsDataObjRepl( rsComm, &dataObjInp,
103  &myTransStat, NULL );
104 
105  if ( status == SYS_COPY_ALREADY_IN_RESC ) {
106  savedStatus = status;
107  status = 0;
108  }
109 
110  if ( status < 0 ) {
112  "rsCollRepl: rsDataObjRepl failed for %s. status = %d",
113  dataObjInp.objPath, status );
114  savedStatus = status;
115  break;
116  }
117  else {
118  if ( collOprStat != NULL ) {
119  ( *collOprStat )->bytesWritten += myTransStat.bytesWritten;
120  ( *collOprStat )->filesCnt ++;
121  }
122  }
123  if ( collOprStat != NULL &&
124  ( *collOprStat )->filesCnt >= fileCntPerStatOut ) {
125  rstrcpy( ( *collOprStat )->lastObjPath, dataObjInp.objPath,
126  MAX_NAME_LEN );
127  ( *collOprStat )->totalFileCnt = totalFileCnt;
128  status = svrSendCollOprStat( rsComm, *collOprStat );
129  if ( status < 0 ) {
131  "rsCollRepl: svrSendCollOprStat failed for %s. status = %d",
132  dataObjInp.objPath, status );
133  *collOprStat = NULL;
134  savedStatus = status;
135  break;
136  }
137  *collOprStat = ( collOprStat_t* )malloc( sizeof( collOprStat_t ) );
138  memset( *collOprStat, 0, sizeof( collOprStat_t ) );
139  }
140  }
141  free( collEnt ); /* just free collEnt but not content */
142  collEnt = NULL;
143  }
144  rsCloseCollection( rsComm, &handleInx );
145  freeCollEnt( collEnt );
146 
147  return savedStatus;
148 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rsReadCollection
int rsReadCollection(rsComm_t *rsComm, int *handleInxInp, collEnt_t **collEnt)
Definition: rsReadCollection.cpp:15
transferStat_t
Definition: objInfo.h:291
rsOpenCollection
int rsOpenCollection(rsComm_t *rsComm, collInp_t *openCollInp)
Definition: rsOpenCollection.cpp:16
getRemoteZoneResc.h
CollInp
Definition: dataObjInpOut.h:157
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
CollEnt::collName
char * collName
Definition: miscUtil.h:119
CollHandle
std::vector< collHandle_t > CollHandle
Definition: irods_server_globals.cpp:31
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
rsOpenCollection.hpp
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
_rcCollRepl
int _rcCollRepl(rcComm_t *conn, collInp_t *collReplInp, collOprStat_t **collOprStat)
Definition: rcCollRepl.cpp:9
CollInp::flags
int flags
Definition: dataObjInpOut.h:159
_rsDataObjRepl
int _rsDataObjRepl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, transferStat_t *transStat, dataObjInfo_t *outDataObjInfo)
Definition: rsDataObjRepl.cpp:229
rsReadCollection.hpp
readCollection.h
transferStat_t::bytesWritten
rodsLong_t bytesWritten
Definition: objInfo.h:294
rsCloseCollection
int rsCloseCollection(rsComm_t *rsComm, int *handleInxInp)
Definition: rsCloseCollection.cpp:14
closeCollection.h
rsCollRepl.hpp
freeCollEnt
int freeCollEnt(collEnt_t *collEnt)
Definition: miscUtil.cpp:1759
collOprStat_t
Definition: objInfo.h:298
CollEnt
Definition: miscUtil.h:113
FILE_CNT_PER_STAT_OUT
#define FILE_CNT_PER_STAT_OUT
Definition: objInfo.h:297
REMOTE_CREATE
#define REMOTE_CREATE
Definition: getRemoteZoneResc.h:4
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
CollInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:161
svrSendCollOprStat
int svrSendCollOprStat(rsComm_t *rsComm, collOprStat_t *collOprStat)
Definition: rsApiHandler.cpp:660
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
rsCollRepl
int rsCollRepl(rsComm_t *rsComm, collInp_t *collReplInp, collOprStat_t **collOprStat)
Definition: rsCollRepl.cpp:32
RECUR_QUERY_FG
#define RECUR_QUERY_FG
Definition: miscUtil.h:92
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
dataObjRepl.h
CollEnt::dataName
char * dataName
Definition: miscUtil.h:120
rodsServerHost
Definition: rodsConnect.h:62
openCollection.h
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
getAndConnRemoteZone
int getAndConnRemoteZone(rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsServerHost_t **rodsServerHost, char *remotZoneOpr)
Definition: rodsConnect.cpp:784
CollEnt::objType
objType_t objType
Definition: miscUtil.h:114
CollInp::collName
char collName[(1024+64)]
Definition: dataObjInpOut.h:158
rodsObjStat
Definition: objStat.h:8
rodsObjStat::specColl
specColl_t * specColl
Definition: objStat.h:18
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
dataObjOpr.hpp
rsApiHandler.hpp
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
SYS_COPY_ALREADY_IN_RESC
@ SYS_COPY_ALREADY_IN_RESC
Definition: rodsErrorTable.h:113
collRepl.h
rsCloseCollection.hpp
rsDataObjRepl.hpp
svrSendZoneCollOprStat
int svrSendZoneCollOprStat(rsComm_t *rsComm, rcComm_t *conn, collOprStat_t *collOprStat, int retval)
Definition: rsApiHandler.cpp:705
objMetaOpr.hpp