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)  

rsStructFileSync.cpp
Go to the documentation of this file.
1 
3 #include "structFileSync.h"
4 #include "miscServerFunct.hpp"
5 #include "dataObjOpr.hpp"
6 #include "rsStructFileSync.hpp"
7 
8 // =-=-=-=-=-=-=-
11 #include "irods_stacktrace.hpp"
12 
13 int
14 rsStructFileSync( rsComm_t *rsComm, structFileOprInp_t *structFileOprInp ) {
16  int remoteFlag;
17  int status;
18 
19  char* resc_hier = getValByKey( &structFileOprInp->condInput, RESC_HIER_STR_KW );
20  if ( resc_hier != NULL ) {
21  irods::error ret = irods::get_host_for_hier_string( resc_hier, remoteFlag, rodsServerHost );
22  if ( !ret.ok() ) {
23  irods::log( PASSMSG( "failed in call to irods::get_host_for_hier_string", ret ) );
24  return -1;
25  }
26  }
27  else {
28  return -1;
29  }
30 
31  //remoteFlag = resolveHost (&structFileOprInp->addr, &rodsServerHost);
32 
33  if ( remoteFlag == LOCAL_HOST ) {
34  status = _rsStructFileSync( rsComm, structFileOprInp );
35  }
36  else if ( remoteFlag == REMOTE_HOST ) {
37  status = remoteStructFileSync( rsComm, structFileOprInp, rodsServerHost );
38  }
39  else {
40  if ( remoteFlag < 0 ) {
41  return remoteFlag;
42  }
43  else {
45  "rsStructFileSync: resolveHost returned unrecognized value %d",
46  remoteFlag );
48  }
49  }
50 
51  return status;
52 }
53 
54 int
55 remoteStructFileSync( rsComm_t *rsComm, structFileOprInp_t *structFileOprInp,
57  int status;
58 
59  if ( rodsServerHost == NULL ) {
61  "remoteStructFileSync: Invalid rodsServerHost" );
63  }
64 
65  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
66  return status;
67  }
68 
69  status = rcStructFileSync( rodsServerHost->conn, structFileOprInp );
70 
71  if ( status < 0 ) {
73  "remoteStructFileSync: rcStructFileSync failed for %s, status = %d",
74  structFileOprInp->specColl->collection, status );
75  }
76 
77  return status;
78 }
79 
80 // =-=-=-=-=-=-=-
81 // implementation for local rs call for sync
83  structFileOprInp_t* _struct_inp ) {
84  // =-=-=-=-=-=-=-
85  // create a structured fco and resolve a resource plugin
86  // to handle the extract process
89  ) );
90  struct_obj->spec_coll( _struct_inp->specColl );
91  struct_obj->addr( _struct_inp->addr );
92  struct_obj->flags( _struct_inp->flags );
93  struct_obj->comm( _comm );
94  struct_obj->opr_type( _struct_inp->oprType );
95  struct_obj->resc_hier( _struct_inp->specColl->rescHier );
96  struct_obj->spec_coll_type( _struct_inp->specColl->type );
97 
98  // =-=-=-=-=-=-=-
99  // cache data type for selection of tasty compression options
100  char* data_type = getValByKey( &_struct_inp->condInput, DATA_TYPE_KW );
101  if ( data_type ) {
102  struct_obj->data_type( data_type );
103  }
104 
105  // =-=-=-=-=-=-=-
106  // retrieve the resource name given the object
107  irods::plugin_ptr ptr;
108  irods::error ret_err = struct_obj->resolve( irods::RESOURCE_INTERFACE, ptr );
109  if ( !ret_err.ok() ) {
110  irods::error err = PASSMSG( "failed to resolve resource", ret_err );
111  irods::log( err );
112  return ret_err.code();
113  }
114 
115  irods::resource_ptr resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
116 
117  // =-=-=-=-=-=-=-
118  // make the call to the "extract" interface
119  ret_err = resc->call( _comm, "sync", struct_obj );
120 
121  // =-=-=-=-=-=-=-
122  // pass along an error from the interface or return SUCCESS
123  if ( !ret_err.ok() ) {
124  irods::error err = PASSMSG( "failed to call 'sync'", ret_err );
125  irods::log( err );
126  return ret_err.code();
127  }
128  else {
129  return ret_err.code();
130  }
131 
132 } // _rsStructFileSync
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
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
structFileSync.h
rsStructFileSync
int rsStructFileSync(rsComm_t *rsComm, structFileOprInp_t *structFileOprInp)
Definition: rsStructFileSync.cpp:14
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_stacktrace.hpp
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
_rsStructFileSync
int _rsStructFileSync(rsComm_t *_comm, structFileOprInp_t *_struct_inp)
Definition: rsStructFileSync.cpp:82
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
irods_resource_backport.hpp
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
DATA_TYPE_KW
#define DATA_TYPE_KW
Definition: rodsKeyWdDef.h:23
remoteStructFileSync
int remoteStructFileSync(rsComm_t *rsComm, structFileOprInp_t *structFileOprInp, rodsServerHost_t *rodsServerHost)
Definition: rsStructFileSync.cpp:55
irods::error::code
long long code() const
Definition: irods_error.cpp:194
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
irods::RESOURCE_INTERFACE
const std::string RESOURCE_INTERFACE("irods_resource_interface")
StructFileOprInp::oprType
int oprType
Definition: structFileSync.h:10
rsStructFileSync.hpp
irods::structured_object
Definition: irods_structured_object.hpp:15
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
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
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
StructFileOprInp::flags
int flags
Definition: structFileSync.h:11
SpecColl::collection
char collection[(1024+64)]
Definition: objInfo.h:79
rcStructFileSync
int rcStructFileSync(rcComm_t *conn, structFileOprInp_t *structFileOprInp)
Definition: rcStructFileSync.cpp:23
StructFileOprInp
Definition: structFileSync.h:8
rodsServerHost
Definition: rodsConnect.h:62
StructFileOprInp::condInput
keyValPair_t condInput
Definition: structFileSync.h:13
StructFileOprInp::addr
rodsHostAddr_t addr
Definition: structFileSync.h:9
irods_structured_object.hpp
dataObjOpr.hpp
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
StructFileOprInp::specColl
specColl_t * specColl
Definition: structFileSync.h:12