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)  

irods_create_write_replicator.cpp
Go to the documentation of this file.
2 
3 #include "dataObjRepl.h"
4 #include "irods_repl_retry.hpp"
5 #include "irods_stacktrace.hpp"
6 
7 namespace irods {
8 
10  const std::string& _root_resource,
11  const std::string& _current_resource,
12  const std::string& _child ) {
13  root_resource_ = _root_resource;
14  current_resource_ = _current_resource;
15  child_ = _child;
16  }
17 
19  // TODO - stub
20  }
21 
23  plugin_context& _ctx,
24  const child_list_t& _siblings,
25  const object_oper& _object_oper ) {
26 
27  error result = SUCCESS();
28  error last_error = SUCCESS();
29  if ( ( result = ASSERT_ERROR( _object_oper.operation() == irods::CREATE_OPERATION || _object_oper.operation() == irods::WRITE_OPERATION,
30  INVALID_OPERATION, "Performing create/write replication but objects operation is: \"%s\".",
31  _object_oper.operation().c_str() ) ).ok() ) {
32  // Generate a resource hierarchy string up to and including this resource
33  hierarchy_parser child_parser;
34  child_parser.set_string( child_ );
35  std::string sub_hier;
36  child_parser.str( sub_hier, current_resource_ );
37 
38  file_object object = _object_oper.object();
39  child_list_t::const_iterator it;
40  for ( it = _siblings.begin(); it != _siblings.end(); ++it ) {
41  hierarchy_parser sibling = *it;
42  std::string hierarchy_string;
43  error ret = sibling.str( hierarchy_string );
44  if ( ( result = ASSERT_PASS( ret, "Failed to get the hierarchy string from the sibling hierarchy parser." ) ).ok() ) {
45  dataObjInp_t dataObjInp;
46  bzero( &dataObjInp, sizeof( dataObjInp ) );
47  rstrcpy( dataObjInp.objPath, object.logical_path().c_str(), MAX_NAME_LEN );
48  dataObjInp.createMode = object.mode();
49 
50  copyKeyVal( ( keyValPair_t* )&object.cond_input(), &dataObjInp.condInput );
51  addKeyVal( &dataObjInp.condInput, RESC_HIER_STR_KW, child_.c_str() );
52  addKeyVal( &dataObjInp.condInput, DEST_RESC_HIER_STR_KW, hierarchy_string.c_str() );
53  addKeyVal( &dataObjInp.condInput, RESC_NAME_KW, root_resource_.c_str() );
54  addKeyVal( &dataObjInp.condInput, DEST_RESC_NAME_KW, root_resource_.c_str() );
55  addKeyVal( &dataObjInp.condInput, IN_PDMO_KW, sub_hier.c_str() );
56 
57  try {
58  const auto status = data_obj_repl_with_retry( _ctx, dataObjInp );
59  char* sys_error = NULL;
60  auto rods_error = rodsErrorName( status, &sys_error );
61  result = ASSERT_ERROR( status >= 0, status, "Failed to replicate the data object: \"%s\" from resource: \"%s\" "
62  "to sibling: \"%s\" - %s %s.", object.logical_path().c_str(), child_.c_str(),
63  hierarchy_string.c_str(), rods_error, sys_error );
64  free( sys_error );
65 
66  // cache last error to return, log it and add it to the
67  // client side error stack
68  if ( !result.ok() ) {
69  last_error = result;
70  irods::log( result );
72  &_ctx.comm()->rError,
73  result.code(),
74  result.result().c_str() );
75  result = SUCCESS();
76  }
77  }
78  catch ( const irods::exception& e ) {
80  }
81 
82  } // if hier str
83 
84  } // for it
85 
86  } // if ok
87 
88  if ( !last_error.ok() ) {
89  return last_error;
90  }
91 
92  return SUCCESS();
93  }
94 
95 }; // namespace irods
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
NULL
#define NULL
Definition: rodsDef.h:70
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
irods::object_oper::object
const file_object & object(void) const
Definition: irods_object_oper.hpp:19
irods_stacktrace.hpp
irods::create_write_replicator::~create_write_replicator
virtual ~create_write_replicator(void)
Definition: irods_create_write_replicator.cpp:18
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
irods::plugin_context
Definition: irods_plugin_context.hpp:18
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
ASSERT_ERROR
#define ASSERT_ERROR(expr_, code_, format_,...)
Definition: irods_error.hpp:123
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
INVALID_OPERATION
@ INVALID_OPERATION
Definition: rodsErrorTable.h:760
irods::plugin_context::comm
virtual rsComm_t * comm()
Definition: irods_plugin_context.hpp:95
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
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
Definition: apiHandler.hpp:35
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
irods::object_oper::operation
const std::string & operation(void) const
Definition: irods_object_oper.hpp:22
irods::data_obj_repl_with_retry
int data_obj_repl_with_retry(irods::plugin_context &_ctx, dataObjInp_t &dataObjInp)
Definition: irods_repl_retry.cpp:12
ASSERT_PASS
#define ASSERT_PASS(prev_error_, format_,...)
Definition: irods_error.hpp:124
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
DEST_RESC_HIER_STR_KW
#define DEST_RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:226
irods::error
Definition: irods_error.hpp:23
DataObjInp::createMode
int createMode
Definition: dataObjInpOut.h:67
dataObjRepl.h
IN_PDMO_KW
#define IN_PDMO_KW
Definition: rodsKeyWdDef.h:227
irods::hierarchy_parser::str
error str(std::string &_ret_string, const std::string &_term_resc="") const
Definition: irods_hierarchy_parser.cpp:46
child_list_t
std::vector< irods::hierarchy_parser > child_list_t
Definition: irods_repl_types.hpp:16
irods::file_object
Definition: irods_file_object.hpp:19
irods::object_oper
Definition: irods_object_oper.hpp:12
irods::WRITE_OPERATION
const std::string WRITE_OPERATION("WRITE")
irods::create_write_replicator::create_write_replicator
create_write_replicator(const std::string &_root_resource, const std::string &_current_resource, const std::string &_child)
Definition: irods_create_write_replicator.cpp:9
irods::exception
Definition: irods_exception.hpp:15
irods::create_write_replicator::root_resource_
std::string root_resource_
Definition: irods_create_write_replicator.hpp:24
irods::create_write_replicator::child_
std::string child_
Definition: irods_create_write_replicator.hpp:26
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
KeyValPair
Definition: objInfo.h:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_repl_retry.hpp
irods::create_write_replicator::current_resource_
std::string current_resource_
Definition: irods_create_write_replicator.hpp:25
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
irods_create_write_replicator.hpp
irods::create_write_replicator::replicate
error replicate(plugin_context &_ctx, const child_list_t &_siblings, const object_oper &_object_oper)
Definition: irods_create_write_replicator.cpp:22
copyKeyVal
int copyKeyVal(const keyValPair_t *srcCondInput, keyValPair_t *destCondInput)
Definition: rcMisc.cpp:751