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)  

rsGetRemoteZoneResc.cpp
Go to the documentation of this file.
1 
3 /* rsGetRemoteZoneResc.c
4  */
5 
6 #include "getRemoteZoneResc.h"
7 #include "rodsLog.h"
8 #include "objMetaOpr.hpp"
9 #include "dataObjOpr.hpp"
10 #include "physPath.hpp"
11 #include "regDataObj.h"
12 #include "rcGlobalExtern.h"
13 #include "rsGetRemoteZoneResc.hpp"
14 #include "dataObjCreate.h"
15 #include "dataObjOpen.h"
16 
19 
20 int
22  rodsHostAddr_t **rescAddr ) {
23 
24  irods::error err = SUCCESS();
25 
26  // =-=-=-=-=-=-=-
27  // acquire the operation requested
28  char* remoteOprType = getValByKey(
29  &dataObjInp->condInput,
31  if ( !remoteOprType ) {
33  "rsGetRemoteZoneResc: REMOTE_ZONE_OPR_KW not defined for %s",
34  dataObjInp->objPath );
35  return USER_BAD_KEYWORD_ERR;
36  }
37 
38  // =-=-=-=-=-=-=-
39  // try to open the object in question, otherwise it is a create
40  int status = 0;
41  bool do_sort = false; // only on open
42  std::string oper = irods::CREATE_OPERATION;
43  dataObjInfo_t *dataObjInfoHead = NULL;
44  if ( strcmp( remoteOprType, REMOTE_OPEN ) == 0 ) {
46  rsComm,
47  dataObjInp,
48  &dataObjInfoHead );
49  if ( status >= 0 ) {
50  do_sort = true;
51  oper = irods::OPEN_OPERATION;
52  }
53  }
54 
55  // =-=-=-=-=-=-=-
56  // determine the hier string for the dest data obj inp
57  std::string hier;
59  oper,
60  rsComm,
61  dataObjInp,
62  hier );
63  if ( !err.ok() ) {
64  std::stringstream msg;
65  msg << "failed for [";
66  msg << dataObjInp->objPath << "]";
67  irods::log( PASSMSG( msg.str(), err ) );
68  return err.code();
69  }
70 
71  // =-=-=-=-=-=-=-
72  // we resolved the hier str for subsequent api calls, etc.
73  addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );
74 
75  // =-=-=-=-=-=-=-
76  // we resolved the hier str for subsequent api calls, etc.
77  std::string location;
78  err = irods::get_loc_for_hier_string( hier, location );
79  if ( !err.ok() ) {
80  irods::log( PASS( err ) );
81  return err.code();
82  }
83 
84  // =-=-=-=-=-=-=-
85  // if this was an open then run the sort and override the location
86  if ( do_sort ) {
87  int writeFlag;
88  writeFlag = getWriteFlag( dataObjInp->openFlags );
90  &dataObjInfoHead,
91  &dataObjInp->condInput,
92  writeFlag );
93  if ( status < 0 ) {
94  rodsLog(
95  LOG_ERROR,
96  "rsGetRemoteZoneResc - sortObjInfoForOpen failed for [%s]",
97  dataObjInp->objPath );
98  return status;
99  }
100 
101  // =-=-=-=-=-=-=-
102  // extract resource location from hierarchy
103  err = irods::get_resource_property<std::string>( dataObjInfoHead->rescId, irods::RESOURCE_LOCATION, location );
104  if ( !err.ok() ) {
105  irods::log( PASSMSG( "rsGetRemoteZoneResc - failed in get_resc_hier_property", err ) );
106  return err.code();
107  }
108  }
109 
110  // =-=-=-=-=-=-=-
111  // set the out variable
112  *rescAddr = ( rodsHostAddr_t* )malloc( sizeof( rodsHostAddr_t ) );
113  bzero( *rescAddr, sizeof( rodsHostAddr_t ) );
114  rstrcpy( ( *rescAddr )->hostAddr, location.c_str(), NAME_LEN );
115  rstrcpy( ( *rescAddr )->zoneName, ZoneInfoHead->zoneName, NAME_LEN );
116 
117  return 0;
118 
119 }
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
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
NULL
#define NULL
Definition: rodsDef.h:70
regDataObj.h
irods::RESOURCE_LOCATION
const std::string RESOURCE_LOCATION("resource_property_location")
rsComm_t
Definition: rcConnect.h:145
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
getRemoteZoneResc.h
DataObjInp::openFlags
int openFlags
Definition: dataObjInpOut.h:68
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
rsGetRemoteZoneResc.hpp
irods::resolve_resource_hierarchy
error resolve_resource_hierarchy(const std::string &, rsComm_t *, dataObjInp_t *, std::string &, dataObjInfo_t **_data_obj_info=0)
Definition: irods_resource_redirect.cpp:505
REMOTE_OPEN
#define REMOTE_OPEN
Definition: getRemoteZoneResc.h:5
DataObjInfo::rescId
rodsLong_t rescId
Definition: objInfo.h:164
zoneInfo::zoneName
char zoneName[64]
Definition: rodsConnect.h:75
irods_resource_backport.hpp
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
rcGlobalExtern.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
dataObjCreate.h
ZoneInfoHead
zoneInfo_t * ZoneInfoHead
Definition: irods_server_globals.cpp:23
irods_resource_redirect.hpp
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::OPEN_OPERATION
const std::string OPEN_OPERATION("OPEN")
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
USER_BAD_KEYWORD_ERR
@ USER_BAD_KEYWORD_ERR
Definition: rodsErrorTable.h:246
getDataObjInfoIncSpecColl
int getDataObjInfoIncSpecColl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfo)
Definition: dataObjOpr.cpp:1767
REMOTE_ZONE_OPR_KW
#define REMOTE_ZONE_OPR_KW
Definition: rodsKeyWdDef.h:81
DataObjInp
Definition: dataObjInpOut.h:65
getWriteFlag
int getWriteFlag(int openFlag)
Definition: physPath.cpp:386
sortObjInfoForOpen
int sortObjInfoForOpen(dataObjInfo_t **dataObjInfoHead, keyValPair_t *condInput, int writeFlag)
Definition: dataObjOpr.cpp:548
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::error
Definition: irods_error.hpp:23
rsGetRemoteZoneResc
int rsGetRemoteZoneResc(rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsHostAddr_t **rescAddr)
Definition: rsGetRemoteZoneResc.cpp:21
dataObjOpen.h
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
dataObjOpr.hpp
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
irods::get_loc_for_hier_string
error get_loc_for_hier_string(const std::string &_hier, std::string &_loc)
Definition: irods_resource_backport.cpp:633
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DataObjInfo
Definition: objInfo.h:129
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
objMetaOpr.hpp
rodsHostAddr_t
Definition: rodsDef.h:296