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)  

rsDataObjLock.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjLock.h for a description of this API call.*/
5 
6 #include "rcMisc.h"
7 #include "dataObjLock.h"
8 #include "rodsLog.h"
9 #include "objMetaOpr.hpp"
10 #include "dataObjOpr.hpp"
11 #include "physPath.hpp"
12 #include "specColl.hpp"
13 #include "rsGlobalExtern.hpp"
14 #include "rcGlobalExtern.h"
15 #include "getRemoteZoneResc.h"
16 #include "miscServerFunct.hpp"
18 #include "rsDataObjLock.hpp"
19 
20 int
21 rsDataObjLock( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {
22 
23  specCollCache_t *specCollCache = NULL;
24  resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
25  &dataObjInp->condInput );
26 
28  int remoteFlag = getAndConnRcatHost(
29  rsComm,
31  ( const char* )dataObjInp->objPath,
32  &rodsServerHost );
33  if ( remoteFlag < 0 ) {
34  return remoteFlag;
35  }
36  else if ( remoteFlag == REMOTE_HOST ) {
37  if ( rodsServerHost != NULL ) { // JMC - cppcheck null ref
38  return rcDataObjLock( rodsServerHost->conn, dataObjInp );
39  }
40  else {
42  }
43  }
44  std::string svc_role;
45  irods::error ret = get_catalog_service_role(svc_role);
46  if(!ret.ok()) {
47  irods::log(PASS(ret));
48  return ret.code();
49  }
50 
51  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
52  return _rsDataObjLock( dataObjInp );
53  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
55  } else {
56  rodsLog(
57  LOG_ERROR,
58  "role not supported [%s]",
59  svc_role.c_str() );
61  }
62 
63 }
64 
65 int
66 _rsDataObjLock( dataObjInp_t *dataObjInp ) {
67 
68  int cmd, type;
69  int status = getLockCmdAndType( &dataObjInp->condInput, &cmd, &type );
70  if ( status < 0 ) {
71  return status;
72  }
73 
74  status = fsDataObjLock( dataObjInp->objPath, cmd, type );
75  return status;
76 }
77 
78 int
79 getLockCmdAndType( keyValPair_t *condInput, int *cmd, int *type ) {
80  char *lockType, *lockCmd;
81  int status;
82 
83  if ( condInput == NULL || cmd == NULL || type == NULL ) {
84  return USER__NULL_INPUT_ERR;
85  }
86 
87  lockType = getValByKey( condInput, LOCK_TYPE_KW );
88  if ( lockType == NULL ) {
89  return SYS_LOCK_TYPE_INP_ERR;
90  }
91 
92  if ( strcmp( lockType, READ_LOCK_TYPE ) == 0 ) {
93  *type = F_RDLCK;
94  }
95  else if ( strcmp( lockType, WRITE_LOCK_TYPE ) == 0 ) {
96  *type = F_WRLCK;
97  }
98  else {
101  "getLockCmdAndType: illegal lock type %s", lockType );
102  return status;
103  }
104 
105  lockCmd = getValByKey( condInput, LOCK_CMD_KW );
106  if ( lockCmd == NULL ) {
107  /* default to F_SETLKW */
108  *cmd = F_SETLKW;
109  return 0;
110  }
111 
112  if ( strcmp( lockCmd, SET_LOCK_CMD ) == 0 ) {
113  *cmd = F_SETLK;
114  }
115  else if ( strcmp( lockCmd, SET_LOCK_WAIT_CMD ) == 0 ) {
116  *cmd = F_SETLKW;
117  }
118  else if ( strcmp( lockCmd, GET_LOCK_CMD ) == 0 ) {
119  *cmd = F_GETLK;
120  }
121  else {
124  "getLockCmdAndType: illegal lock cmd %s", lockCmd );
125  return status;
126  }
127  return 0;
128 }
129 
130 // =-=-=-=-=-=-=-
131 // JMC - backport 4604
132 int
133 rsDataObjUnlock( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {
134 
135  specCollCache_t *specCollCache = NULL;
136  resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
137  &dataObjInp->condInput );
138 
140  int remoteFlag = getAndConnRcatHost(
141  rsComm,
142  MASTER_RCAT,
143  ( const char* )dataObjInp->objPath,
144  &rodsServerHost );
145  if ( remoteFlag < 0 ) {
146  return remoteFlag;
147  }
148  else if ( remoteFlag == REMOTE_HOST ) {
149  if ( rodsServerHost != NULL ) { // JMC - cppcheck null ref
150  return rcDataObjUnlock( rodsServerHost->conn, dataObjInp );
151  }
152  else {
153  return SYS_NO_RCAT_SERVER_ERR;
154  }
155  }
156  std::string svc_role;
157  irods::error ret = get_catalog_service_role(svc_role);
158  if(!ret.ok()) {
159  irods::log(PASS(ret));
160  return ret.code();
161  }
162 
163  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
164  return _rsDataObjUnlock( dataObjInp );
165  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
166  return SYS_NO_RCAT_SERVER_ERR;
167  } else {
168  rodsLog(
169  LOG_ERROR,
170  "role not supported [%s]",
171  svc_role.c_str() );
173  }
174 }
175 
176 int
178 
179  char * fd_string = getValByKey( &dataObjInp->condInput, LOCK_FD_KW );
180  if ( fd_string == NULL ) {
183  "getLockCmdAndType: LOCK_FD_KW not defined for unlock operation" );
184  return status;
185  }
186  return fsDataObjUnlock( F_SETLK, F_UNLCK, atoi( fd_string ) );
187 
188 }
189 // =-=-=-=-=-=-=-
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
LOCK_TYPE_KW
#define LOCK_TYPE_KW
Definition: rodsKeyWdDef.h:115
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
SYS_LOCK_CMD_INP_ERR
@ SYS_LOCK_CMD_INP_ERR
Definition: rodsErrorTable.h:190
irods::CFG_SERVICE_ROLE_CONSUMER
const std::string CFG_SERVICE_ROLE_CONSUMER("consumer")
irods_configuration_keywords.hpp
getRemoteZoneResc.h
SYS_SERVICE_ROLE_NOT_SUPPORTED
@ SYS_SERVICE_ROLE_NOT_SUPPORTED
Definition: rodsErrorTable.h:217
specColl.hpp
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
SET_LOCK_CMD
#define SET_LOCK_CMD
Definition: dataObjLock.h:14
SET_LOCK_WAIT_CMD
#define SET_LOCK_WAIT_CMD
Definition: dataObjLock.h:15
rcDataObjUnlock
int rcDataObjUnlock(rcComm_t *conn, dataObjInp_t *dataObjInp)
Definition: rcDataObjLock.cpp:80
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
rcMisc.h
LOCK_FD_KW
#define LOCK_FD_KW
Definition: rodsKeyWdDef.h:117
rcGlobalExtern.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
resolveLinkedPath
int resolveLinkedPath(rsComm_t *rsComm, char *objPath, specCollCache_t **specCollCache, keyValPair_t *condInput)
Definition: specColl.cpp:711
rsDataObjLock
int rsDataObjLock(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: rsDataObjLock.cpp:21
generate_iadmin_commands_for_41_to_42_upgrade.cmd
list cmd
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:19
rsGlobalExtern.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
GET_LOCK_CMD
#define GET_LOCK_CMD
Definition: dataObjLock.h:16
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
DataObjInp
Definition: dataObjInpOut.h:65
rsDataObjUnlock
int rsDataObjUnlock(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: rsDataObjLock.cpp:133
_rsDataObjUnlock
int _rsDataObjUnlock(dataObjInp_t *dataObjInp)
Definition: rsDataObjLock.cpp:177
LOCK_CMD_KW
#define LOCK_CMD_KW
Definition: rodsKeyWdDef.h:116
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
_rsDataObjLock
int _rsDataObjLock(dataObjInp_t *dataObjInp)
Definition: rsDataObjLock.cpp:66
rcDataObjLock
int rcDataObjLock(rcComm_t *conn, dataObjInp_t *dataObjInp)
Definition: rcDataObjLock.cpp:71
fsDataObjLock
int fsDataObjLock(char *objPath, int cmd, int type)
Definition: physPath.cpp:1268
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
WRITE_LOCK_TYPE
#define WRITE_LOCK_TYPE
Definition: dataObjLock.h:10
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
getLockCmdAndType
int getLockCmdAndType(keyValPair_t *condInput, int *cmd, int *type)
Definition: rsDataObjLock.cpp:79
READ_LOCK_TYPE
#define READ_LOCK_TYPE
Definition: dataObjLock.h:9
SYS_LOCK_TYPE_INP_ERR
@ SYS_LOCK_TYPE_INP_ERR
Definition: rodsErrorTable.h:189
dataObjOpr.hpp
dataObjLock.h
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
KeyValPair
Definition: objInfo.h:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rsDataObjLock.hpp
type
int type
Definition: filesystem.cpp:103
SpecCollCache
Definition: objInfo.h:102
objMetaOpr.hpp
fsDataObjUnlock
int fsDataObjUnlock(int cmd, int type, int fd)
Definition: physPath.cpp:1302
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247