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)  

rsSetRoundRobinContext.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // irods includes
3 #include "rcMisc.h"
4 #include "rodsConnect.h"
5 #include "apiHandler.hpp"
10 #include "apiNumber.h"
11 
13 
14 // =-=-=-=-=-=-=-
15 // actual implementation of the API plugin
17  rsComm_t* _comm,
19  rodsLog( LOG_DEBUG, "rsSetRoundRobinContex" );
20  // =-=-=-=-=-=-=-
21  // error check - incoming parameters
22  if ( !_comm ||
23  !_inp ) {
24  rodsLog(
25  LOG_ERROR,
26  "rsSetRoundRobinContex - invalid input param" );
28  }
29 
30  // =-=-=-=-=-=-=-
31  // error check - must have a valid context
32  // string otherwise chlModResc
33  // fails. treat this as a
34  // success
35  if ( strlen( _inp->context_ ) <= 0 ) {
36  return 0;
37 
38  }
39 
40  // =-=-=-=-=-=-=-
41  // error check - resource name is valid
42  // by getting a handle to it
45  _inp->resc_name_,
46  resc );
47  if ( !ret.ok() ) {
48  irods::log( PASS( ret ) );
50  }
51 
52  // =-=-=-=-=-=-=-
53  // error check - resource is in fact a
54  // round robin resource?
55  std::string resc_type;
56  ret = resc->get_property< std::string >(
58  resc_type );
59  if ( resc_type != "roundrobin" ) {
60  rodsLog(
61  LOG_ERROR,
62  "rsSetRoundRobinContex - resource is not of type roundrobin [%s]",
63  resc_type.c_str() );
65  }
66 
67  // =-=-=-=-=-=-=-
68  // error check - next resource is in fact a
69  // child of the resource
70  if ( !resc->has_child( _inp->context_ ) ) {
71  rodsLog(
72  LOG_ERROR,
73  "rsSetRoundRobinContex - invalid next child [%s]",
74  _inp->context_ );
76  }
77 
78  // =-=-=-=-=-=-=-
79  // get the server host struct for the icat,
80  // determine if we are it. if not redirect.
81  rodsServerHost_t* server_host = 0;
83  _comm,
85  ( const char* )NULL,
86  &server_host );
87  if ( status < 0 ) {
88  rodsLog(
89  LOG_DEBUG,
90  "rsSetRoundRobinContex - getAndConnRcatHost failed." );
91  return status;
92  }
93 
94  // =-=-=-=-=-=-=-
95  // we are localhost to the iCAT server
96  if ( server_host->localFlag == LOCAL_HOST ) {
97  // =-=-=-=-=-=-=-
98  // lie to the icat api just a little bit...
99  int client_user_auth = _comm->clientUser.authInfo.authFlag;
100  int proxy_user_auth = _comm->proxyUser.authInfo.authFlag;
103  status = chlModResc(
104  _comm,
105  _inp->resc_name_,
106  "context",
107  _inp->context_ );
108  _comm->clientUser.authInfo.authFlag = client_user_auth;
109  _comm->proxyUser.authInfo.authFlag = proxy_user_auth;
110  }
111  else {
112  // =-=-=-=-=-=-=-
113  // redirect to the appropriate server
115  server_host->conn,
117  _inp,
118  NULL,
119  ( void** ) NULL,
120  NULL );
121  if ( status < 0 ) {
123  server_host->conn->rError,
124  &_comm->rError );
125  }
126 
127  } // else
128 
129  // =-=-=-=-=-=-=-
130  // bad, bad things have happened.
131  if ( status < 0 ) {
132  rodsLog(
133  LOG_NOTICE,
134  "rsSetRoundRobinContex: error %d",
135  status );
136  }
137 
138  return status;
139 
140 } // rsSetRoundRobinContext
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
setRoundRobinContextInp_t::resc_name_
char resc_name_[64]
Definition: set_round_robin_context.h:8
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
setRoundRobinContextInp_t::context_
char context_[(1024+64)]
Definition: set_round_robin_context.h:9
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
rcComm_t::rError
rError_t * rError
Definition: rcConnect.h:106
apiHandler.hpp
rcMisc.h
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
chlModResc
int chlModResc(rsComm_t *rsComm, const char *rescName, const char *option, const char *optionValue)
Definition: icatHighLevelRoutines.cpp:2223
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
rodsConnect.h
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
irods::RESOURCE_TYPE
const std::string RESOURCE_TYPE("resource_property_type")
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
LOCAL_PRIV_USER_AUTH
#define LOCAL_PRIV_USER_AUTH
Definition: rodsUser.h:36
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
setRoundRobinContextInp_t
Definition: set_round_robin_context.h:7
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
irods::error
Definition: irods_error.hpp:23
rsSetRoundRobinContext
int rsSetRoundRobinContext(rsComm_t *_comm, setRoundRobinContextInp_t *_inp)
Definition: rsSetRoundRobinContext.cpp:16
apiNumber.h
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
procApiRequest
int procApiRequest(rcComm_t *conn, int apiNumber, void *inputStruct, bytesBuf_t *inputBsBBuf, void **outStruct, bytesBuf_t *outBsBBuf)
Definition: procApiRequest.cpp:55
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
rodsServerHost
Definition: rodsConnect.h:62
SET_RR_CTX_AN
#define SET_RR_CTX_AN
Definition: apiNumber.h:162
irods_resource_manager.hpp
irods::resource_manager
Definition: irods_resource_manager.hpp:30
icatHighLevelRoutines.hpp
replErrorStack
int replErrorStack(rError_t *srcRError, rError_t *destRError)
Definition: rcMisc.cpp:152
set_round_robin_context.h
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rsSetRoundRobinContext.hpp