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) 
|
Go to the documentation of this file.
27 #include <boost/lexical_cast.hpp>
28 #include <boost/function.hpp>
29 #include <boost/any.hpp>
34 template<
typename DEST_TYPE >
42 result =
ASSERT_PASS( ret,
"Resource context invalid." );
52 const std::string& _name,
53 const std::string& _hier,
67 if ( ( result =
ASSERT_PASS( err,
"Failed in set_string" ) ).ok() ) {
72 err = parse.next( _name,
next );
73 if ( ( result =
ASSERT_PASS( err,
"Failed in next." ) ).ok() ) {
78 _hier.c_str(), _name.c_str(),
next.c_str() ) ).ok() ) {
81 _resc = (*cmap_ref)[
next ].second;
94 const std::string& _name,
100 std::vector< irods::physical_object > objs = _file_obj->replicas();
101 std::vector< irods::physical_object >::iterator itr = objs.begin();
105 for ( ; itr != objs.end(); ++itr ) {
109 parser.set_string( itr->resc_hier() );
113 if ( !
parser.resc_in_hier( _name ) ) {
127 std::string msg(
"no replica found in resc [" );
138 template<
typename DEST_TYPE >
146 irods::error err = random_check_params< DEST_TYPE >( _ctx );
147 if ( ( result =
ASSERT_PASS( err,
"Bad resource context." ) ).ok() ) {
153 if ( ( result =
ASSERT_PASS( err,
"Failed to get property." ) ).ok() ) {
157 boost::shared_ptr< DEST_TYPE > dst_obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.
fco() );
158 std::string hier = dst_obj->resc_hier( );
163 result =
ASSERT_PASS( err,
"Get next child failed." );
176 std::string& _next_child ) {
181 if ( _cmap.
size() > 0 ) {
185 size_t target_index = irods::getRandom<unsigned int>() % _cmap.
size();
191 std::string next_child;
193 for ( ; itr != _cmap.
end(); ++itr ) {
194 if ( counter == target_index ) {
195 next_child = itr->first;
208 _next_child = next_child;
224 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
225 if ( ( result =
ASSERT_PASS( err,
"Invalid resource context." ) ).ok() ) {
230 result =
ASSERT_PASS( err,
"Failed calling create on child resource." );
245 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
246 if ( ( result =
ASSERT_PASS( err,
"Failed in file open." ) ).ok() ) {
251 result =
ASSERT_PASS( err,
"Failed calling open on the child." );
268 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
269 if ( ( result =
ASSERT_PASS( err,
"Failed finding resource." ) ).ok() ) {
274 result =
ASSERT_PASS( err,
"Failed calling operation on child resource." );
292 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
293 if ( ( result =
ASSERT_PASS( err,
"Failed choosing child resource." ) ).ok() ) {
298 result =
ASSERT_PASS( err,
"Failed calling operation on child resource." );
313 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
314 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
319 result =
ASSERT_PASS( err,
"Failed calling operation in child." );
334 irods::error err = random_get_resc_for_call< irods::data_object >( _ctx, resc );
335 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
340 result =
ASSERT_PASS( err,
"Failed during call to child operation." );
350 struct stat* _statbuf ) {
356 irods::error err = random_get_resc_for_call< irods::data_object >( _ctx, resc );
357 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random child resource." ) ).ok() ) {
362 result =
ASSERT_PASS( err,
"Failed in call to child operation." );
379 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
380 if ( ( result =
ASSERT_PASS( err,
"Failed to select random child." ) ).ok() ) {
385 result =
ASSERT_PASS( err,
"Failed calling child operation." );
400 irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc );
401 if ( ( result =
ASSERT_PASS( err,
"Failed to select random child resource." ) ).ok() ) {
406 result =
ASSERT_PASS( err,
"Failed calling child operation." );
421 irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc );
422 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
427 result =
ASSERT_PASS( err,
"Failed calling child operation." );
442 irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc );
443 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
448 result =
ASSERT_PASS( err,
"Failed calling child operation." );
463 irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc );
464 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
469 result =
ASSERT_PASS( err,
"Failed calling child operation." );
485 irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc );
486 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
491 result =
ASSERT_PASS( err,
"Failed calling child operation." );
501 const char* _new_file_name ) {
507 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
508 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
513 result =
ASSERT_PASS( err,
"Failed calling child operation." );
528 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
529 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
534 result =
ASSERT_PASS( err,
"Failed calling child operation." );
549 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
550 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
555 result =
ASSERT_PASS( err,
"Failed calling child operation." );
567 const char* _cache_file_name ) {
573 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
574 if ( ( result =
ASSERT_PASS( err,
"Failed to select random resource." ) ).ok() ) {
579 result =
ASSERT_PASS( err,
"Failed calling child operation." );
591 const char* _cache_file_name ) {
597 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
598 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
603 result =
ASSERT_PASS( err,
"Failed calling child operation." );
618 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
619 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
624 result =
ASSERT_PASS( err,
"Failed calling child operation." );
639 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
640 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
645 result =
ASSERT_PASS( err,
"Failed calling child operation." );
660 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
661 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
666 result =
ASSERT_PASS( err,
"Failed calling child operation." );
676 const std::string* _opr ) {
682 irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc );
683 if ( ( result =
ASSERT_PASS( err,
"Failed selecting random resource." ) ).ok() ) {
688 result =
ASSERT_PASS( err,
"Failed calling child operation." );
698 const std::string* _opr,
699 const std::string* _curr_host,
712 bool child_found =
false;
716 std::vector<irods::resource_ptr> candidate_resources;
721 for ( ; itr != cmap_ref->
end(); ++itr ) {
722 candidate_resources.push_back( itr->second.second );
727 while ( result.
ok() && ( !child_found && !candidate_resources.empty() ) ) {
731 size_t rand_index = irods::getRandom<unsigned int>() % candidate_resources.size();
743 _ctx.
fco(), _opr, _curr_host, &hierarchy_copy,
746 if ( ret.
ok() && *_out_vote != 0 ) {
748 *_out_parser = hierarchy_copy;
753 candidate_resources.erase( candidate_resources.begin() + rand_index );
771 const std::string* _opr,
772 const std::string* _curr_host,
779 irods::error err = random_check_params< irods::file_object >( _ctx );
780 if ( ( result =
ASSERT_PASS( err,
"Invalid resource context." ) ).ok() ) {
782 "Invalid parameters." ) ).ok() ) {
787 std::string hier = file_obj->resc_hier( );
815 _ctx.
fco(), _opr, _curr_host, _out_parser,
817 result =
ASSERT_PASS( err,
"Failed calling child operation." );
832 result =
ASSERT_PASS( err,
"Failed getting next valid child." );
861 for ( ; itr != cmap_ref->
end(); ++itr ) {
863 if ( !( result =
ASSERT_PASS( ret,
"Failed calling child operation." ) ).ok() ) {
868 if ( !result.ok() ) {
869 return PASS( result );
884 const std::string& _inst_name,
885 const std::string& _context ) :
893 return ERROR( -1,
"nop" );
899 return ERROR( -1,
"nop" );
913 const std::string& _context ) {
923 using namespace irods;
943 function<error(plugin_context&,void*,int)>(
958 function<error(plugin_context&, struct stat*)>(
973 function<error(plugin_context&,struct rodsDirent**)>(
978 function<error(plugin_context&, const char*)>(
988 function<error(plugin_context&, long long, int)>(
1003 function<error(plugin_context&, const char*)>(
1008 function<error(plugin_context&, const char*)>(
1028 function<error(plugin_context&, const std::string*)>(
1038 function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
irods::error random_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
irods::error random_file_rmdir(irods::plugin_context &_ctx)
const std::string RESOURCE_NAME("resource_property_name")
const std::string RESOURCE_OP_STAT("resource_stat")
irods::error random_file_close(irods::plugin_context &_ctx)
irods::error random_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
irods::error random_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
const std::string RESOURCE_CHECK_PATH_PERM("resource_property_check_path_perm")
const std::string RESOURCE_OP_MODIFIED("resource_modified")
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
std::function< irods::error(rcComm_t *) > pdmo_type
#define PASS(prev_error_)
boost::shared_ptr< resource > resource_ptr
const std::string RESOURCE_OP_RESOLVE_RESC_HIER("resource_resolve_hierarchy")
const std::string RESOURCE_OP_READDIR("resource_readdir")
irods::error random_file_modified(irods::plugin_context &_ctx)
irods::error get_next_child_for_open_or_write(const std::string &_name, irods::file_object_ptr &_file_obj, irods::plugin_property_map &_props, irods::resource_ptr &_resc)
const std::string RESOURCE_OP_READ("resource_read")
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods_hash_map::iterator iterator
const std::string RESOURCE_OP_LSEEK("resource_lseek")
irods::error random_file_unlink(irods::plugin_context &_ctx)
irods::error random_file_rebalance(irods::plugin_context &_ctx)
irods::error random_file_mkdir(irods::plugin_context &_ctx)
error get(const std::string &_key, ValueType &_val)
resource(const std::string &_inst, const std::string &_ctx)
error set_property(const std::string &_key, const T &_val)
@ SYS_INVALID_INPUT_PARAM
irods::error random_get_next_child_resource(irods::resource_child_map &_cmap, std::string &_next_child)
#define ASSERT_ERROR(expr_, code_, format_,...)
irods::error random_file_closedir(irods::plugin_context &_ctx)
virtual rsComm_t * comm()
const std::string RESOURCE_OP_TRUNCATE("resource_truncate")
const std::string RESOURCE_OP_RENAME("resource_rename")
const std::string OPEN_OPERATION("OPEN")
virtual irods::plugin_property_map & prop_map()
irods::error random_file_resolve_hierarchy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
error add_child(const std::string &_resc)
const std::string RESOURCE_OP_CREATE("resource_create")
irods::error get_next_child_in_hier(const std::string &_name, const std::string &_hier, irods::plugin_property_map &_props, irods::resource_ptr &_resc)
const std::string RESOURCE_OP_NOTIFY("resource_notify")
irods::error random_get_resc_for_call(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
irods::error random_file_opendir(irods::plugin_context &_ctx)
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
irods::error random_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
const std::string RESOURCE_OP_WRITE("resource_write")
irods::error random_file_notify(irods::plugin_context &_ctx, const std::string *_opr)
irods::error random_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
irods::error need_post_disconnect_maintenance_operation(bool &_flg)
#define ASSERT_PASS(prev_error_, format_,...)
bool has_entry(KeyType _k) const
const std::string RESOURCE_OP_CLOSE("resource_close")
const std::string RESC_CHILD_MAP_PROP("resource_child_map_property")
const std::string RESOURCE_OP_UNLINK("resource_unlink")
const std::string RESOURCE_OP_RMDIR("resource_rmdir")
#define ERROR(code_, message_)
const std::string RESOURCE_OP_UNREGISTERED("resource_unregistered")
irods::error random_file_getfs_freespace(irods::plugin_context &_ctx)
random_resource(const std::string &_inst_name, const std::string &_context)
const std::string RESOURCE_OP_REGISTERED("resource_registered")
irods::error random_file_unregistered(irods::plugin_context &_ctx)
irods::error random_check_params(irods::plugin_context &_ctx)
irods::error random_file_open(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
irods::error random_file_create(irods::plugin_context &_ctx)
boost::shared_ptr< file_object > file_object_ptr
const std::string WRITE_OPERATION("WRITE")
error add_operation(const std::string &_op, std::function< error(plugin_context &)> _f)
virtual first_class_object_ptr fco()
const std::string RESOURCE_OP_SYNCTOARCH("resource_synctoarch")
irods::error random_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
irods::error random_file_truncate(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
irods::error random_file_registered(irods::plugin_context &_ctx)
irods::error random_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
irods::error random_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
const std::string RESOURCE_OP_OPEN("resource_open")
const std::string CREATE_OPERATION("CREATE")
irods::error get_next_valid_child_resource(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
const std::string UNLINK_OPERATION("UNLINK")
irods::error post_disconnect_maintenance_operation(irods::pdmo_type &)