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.
21 #include <boost/lexical_cast.hpp>
22 #include <boost/function.hpp>
23 #include <boost/any.hpp>
30 template<
typename DEST_TYPE >
37 return PASSMSG(
"resource context is invalid", ret );
49 const std::string& _name,
50 const std::string& _hier,
64 std::stringstream msg;
65 msg <<
"get_next_child_in_hier - failed in set_string for [";
67 return PASSMSG( msg.str(), err );
73 err = parse.next( _name,
next );
75 std::stringstream msg;
76 msg <<
"get_next_child_in_hier - failed in next for [";
77 msg << _name <<
"] for hier ["
79 return PASSMSG( msg.str(), err );
85 std::stringstream msg;
86 msg <<
"get_next_child_in_hier - child map missing entry [";
93 _resc = (*cmap_ref)[
next ].second;
103 const std::string& _name,
109 std::vector< irods::physical_object > objs = _file_obj->replicas();
110 std::vector< irods::physical_object >::iterator itr = objs.begin();
114 for ( ; itr != objs.end(); ++itr ) {
118 parser.set_string( itr->resc_hier() );
122 if ( !
parser.resc_in_hier( _name ) ) {
136 std::string msg(
"no hier found for resc [" );
147 template<
typename DEST_TYPE >
153 irods::error err = round_robin_check_params< DEST_TYPE >( _ctx );
155 return PASSMSG(
"round_robin_get_resc_for_call - bad resource context", err );
163 return PASSMSG(
"round_robin_get_resc_for_call - failed to get property 'name'.", err );
168 boost::shared_ptr< DEST_TYPE > obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.
fco() );
169 std::string hier = obj->resc_hier( );
175 return PASSMSG(
"round_robin_get_resc_for_call - get_next_child_in_hier failed.", err );
203 std::vector< std::string >& _child_vector ) {
212 size_t list_size = cmap_ref->
size();
213 _child_vector.resize( list_size );
220 for ( itr = cmap_ref->
begin();
221 itr != cmap_ref->
end();
224 std::string ctx = itr->second.first;
226 if ( !ctx.empty() ) {
230 size_t idx = boost::lexical_cast<size_t>( ctx );
231 if ( idx >= list_size ) {
232 irods::log(
ERROR( -1,
"build_sorted_child_vector - index out of bounds" ) );
239 if ( !_child_vector[ idx ].
empty() ) {
240 std::stringstream msg;
241 msg <<
"build_sorted_child_vector - child map list is not empty ";
242 msg <<
"for index " << idx <<
" colliding with [";
243 msg << _child_vector[ idx ] <<
"]";
253 irods::log(
ERROR( -1,
"build_sorted_child_vector - get property for resource name failed." ) );
259 _child_vector[ idx ] =
name;
262 catch (
const boost::bad_lexical_cast& ) {
263 irods::log(
ERROR( -1,
"build_sorted_child_vector - lexical cast to size_t failed" ) );
274 for ( itr = cmap_ref->
begin();
275 itr != cmap_ref->
end();
278 std::string ctx = itr->second.first;
284 if ( !ctx.empty() ) {
291 bool filled_flg =
false;
293 std::vector< std::string >::iterator vitr;
294 for ( vitr = _child_vector.begin();
295 vitr != _child_vector.end();
297 if ( vitr->empty() ) {
303 irods::log(
ERROR( -1,
"build_sorted_child_vector - get property for resource name failed." ) );
321 if (
false == filled_flg ) {
322 irods::log(
ERROR( -1,
"build_sorted_child_vector - failed to find an entry in the resc list" ) );
339 std::string next_child;
344 std::vector< std::string > child_vector;
346 if ( !get_err.
ok() ) {
347 std::stringstream msg;
348 msg <<
"update_next_child_resource - failed to get child vector";
349 return ERROR( -1, msg.str() );
355 if ( next_child.empty() ) {
358 for (
size_t i = 0; i < child_vector.size(); ++i ) {
359 if ( child_vector[ i ].
empty() ) {
360 std::stringstream msg;
361 msg <<
"update_next_child_resource - chlid vector at ";
362 msg <<
" posittion " << i;
367 next_child = child_vector[ i ];
378 for (
size_t i = 0; i < child_vector.size(); ++i ) {
379 if ( next_child == child_vector[ i ] ) {
380 size_t idx = ( ( i + 1 ) >= child_vector.size() ) ? 0 : i + 1;
381 next_child = child_vector[ idx ];
391 if ( next_child.empty() ) {
392 std::stringstream msg;
393 msg <<
"update_next_child_resource - next_child is empty.";
394 return ERROR( -1, msg.str() );
419 if ( cmap_ref->
empty() ) {
420 return ERROR( -1,
"round_robin_start_operation - no children specified" );
425 std::vector< std::string > child_vector;
428 return PASSMSG(
"round_robin_start_operation - failed.", err );
433 for (
size_t i = 0; i < child_vector.size(); ++i ) {
435 child_vector[i].c_str(), i );
442 return PASSMSG(
"round_robin_start_operation - failed.", err );
448 std::string next_child;
450 if ( err.
ok() && next_child.empty() && child_vector.size() > 0 ) {
465 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
467 std::stringstream msg;
470 return PASSMSG( msg.str(), err );
486 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
488 std::stringstream msg;
491 return PASSMSG( msg.str(), err );
509 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
511 std::stringstream msg;
514 return PASSMSG( msg.str(), err );
532 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
534 std::stringstream msg;
537 return PASSMSG( msg.str(), err );
553 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
555 std::stringstream msg;
558 return PASSMSG( msg.str(), err );
574 irods::error err = round_robin_get_resc_for_call< irods::data_object >( _ctx, resc );
576 std::stringstream msg;
579 return PASSMSG( msg.str(), err );
592 struct stat* _statbuf ) {
596 irods::error err = round_robin_get_resc_for_call< irods::data_object >( _ctx, resc );
598 std::stringstream msg;
601 return PASSMSG( msg.str(), err );
619 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
621 std::stringstream msg;
624 return PASSMSG( msg.str(), err );
640 irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
642 std::stringstream msg;
645 return PASSMSG( msg.str(), err );
661 irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
663 std::stringstream msg;
666 return PASSMSG( msg.str(), err );
682 irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
684 std::stringstream msg;
687 return PASSMSG( msg.str(), err );
703 irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
705 std::stringstream msg;
708 return PASSMSG( msg.str(), err );
725 irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
727 std::stringstream msg;
730 return PASSMSG( msg.str(), err );
743 const char* _new_file_name ) {
747 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
749 std::stringstream msg;
752 return PASSMSG( msg.str(), err );
768 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
786 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
788 std::stringstream msg;
791 return PASSMSG( msg.str(), err );
806 const char* _cache_file_name ) {
810 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
812 std::stringstream msg;
815 return PASSMSG( msg.str(), err );
830 const char* _cache_file_name ) {
834 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
836 std::stringstream msg;
839 return PASSMSG( msg.str(), err );
855 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
857 std::stringstream msg;
860 return PASSMSG( msg.str(), err );
876 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
878 std::stringstream msg;
881 return PASSMSG( msg.str(), err );
897 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
912 std::string operation;
921 return PASSMSG(
"update_next_child_resource failed", err );
930 std::string next_child;
936 sizeof( inp.resc_name_ ),
937 "%s",
name.c_str() );
940 sizeof( inp.context_ ),
941 "%s", next_child.c_str() );
946 std::stringstream msg;
947 msg <<
"failed to update round robin context for [";
948 msg <<
name <<
"] with context [" << next_child <<
"]";
964 const std::string* _opr,
965 const std::string* _curr_host,
972 bool child_found =
false;
982 while ( !child_found &&
983 child_ctr < cmap_ref->
size() ) {
990 std::string next_child;
995 return PASSMSG(
"get property for 'next_child' failed.", err );
1001 if ( !cmap_ref->
has_entry( next_child ) ) {
1002 std::stringstream msg;
1003 msg <<
"child map has no child by name [";
1004 msg << next_child <<
"]";
1005 return PASSMSG( msg.str(), err );
1015 int resc_status = 0;
1018 return PASSMSG(
"failed to get property", err );
1024 err = resc->call <
const std::string*,
1038 "forward of put redirect failed" );
1043 if( *_out_vote > 0 ) {
1054 return PASSMSG(
"update_next_child_resource failed", err );
1064 if ( child_found ) {
1080 const std::string* _opr,
1081 const std::string* _curr_host,
1083 float* _out_vote ) {
1086 irods::error err = round_robin_check_params< irods::file_object >( _ctx );
1089 "round_robin_resolve_hierarchy - bad resource context", err );
1094 "round_robin_resolve_hierarchy - null operation" );
1096 if ( !_curr_host ) {
1099 "round_robin_resolve_hierarchy - null host" );
1101 if ( !_out_parser ) {
1104 "round_robin_resolve_hierarchy - null outgoing hier parser" );
1109 "round_robin_resolve_hierarchy - null outgoing vote" );
1127 std::string hier = file_obj->
resc_hier( );
1134 return PASSMSG(
"failed to get property 'name'.", err );
1155 ( *_out_vote ) = 0.0;
1162 return resc->call <
const std::string*,
1184 ( *_out_vote ) = 0.0;
1190 _out_parser->
str( hier );
1193 "round robin - create :: resc hier [%s] vote [%f]",
1202 std::stringstream msg;
1203 msg <<
"round_robin_resolve_hierarchy - operation not supported [";
1204 msg << ( *_opr ) <<
"]";
1205 return ERROR( -1, msg.str() );
1222 for ( ; itr != cmap_ref->
end(); ++itr ) {
1233 if ( !result.ok() ) {
1234 return PASS( result );
1245 const std::string* _opr ) {
1249 irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
1251 std::stringstream msg;
1253 return PASSMSG( msg.str(), err );
1258 return resc->call<
const std::string* >(
1274 const std::string& _context ) :
1297 const std::string& _context ) {
1306 using namespace irods;
1307 using namespace std;
1326 function<error(plugin_context&,void*,int)>(
1341 function<error(plugin_context&, struct stat*)>(
1356 function<error(plugin_context&,struct rodsDirent**)>(
1361 function<error(plugin_context&, const char*)>(
1371 function<error(plugin_context&, long long, int)>(
1386 function<error(plugin_context&, const char*)>(
1391 function<error(plugin_context&, const char*)>(
1411 function<error(plugin_context&, const std::string*)>(
1421 function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
void rodsLog(int level, const char *formatStr,...)
const std::string OPERATION_PROP("round_robin_operation")
const std::string RESOURCE_NAME("resource_property_name")
const std::string RESOURCE_OP_STAT("resource_stat")
roundrobin_resource(const std::string &_inst_name, const std::string &_context)
irods::error round_robin_file_create(irods::plugin_context &_ctx)
irods::error round_robin_file_closedir(irods::plugin_context &_ctx)
const std::string RESOURCE_CHECK_PATH_PERM("resource_property_check_path_perm")
const std::string RESOURCE_OP_MODIFIED("resource_modified")
irods::error round_robin_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
#define PASS(prev_error_)
irods::error round_robin_file_notify(irods::plugin_context &_ctx, const std::string *_opr)
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 round_robin_check_params(irods::plugin_context &_ctx)
irods::error round_robin_file_mkdir(irods::plugin_context &_ctx)
irods::error round_robin_file_rmdir(irods::plugin_context &_ctx)
irods::error round_robin_file_close(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_READ("resource_read")
irods::error round_robin_file_modified(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods::error round_robin_file_getfs_freespace(irods::plugin_context &_ctx)
irods_hash_map::iterator iterator
irods::error round_robin_file_resolve_hierarchy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
const std::string RESOURCE_OP_LSEEK("resource_lseek")
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)
#define PASSMSG(message_, prev_error_)
irods::error round_robin_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
error get(const std::string &_key, ValueType &_val)
resource(const std::string &_inst, const std::string &_ctx)
const std::string RESOURCE_STATUS("resource_property_status")
error set_property(const std::string &_key, const T &_val)
@ SYS_INVALID_INPUT_PARAM
irods::error round_robin_file_unregistered(irods::plugin_context &_ctx)
irods::error round_robin_get_resc_for_call(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
irods::error round_robin_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
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")
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)
virtual irods::plugin_property_map & prop_map()
irods::error round_robin_file_rebalance(irods::plugin_context &_ctx)
plugin_property_map properties_
error add_child(const std::string &_resc)
const std::string RESOURCE_OP_CREATE("resource_create")
irods::error round_robin_file_open(irods::plugin_context &_ctx)
irods::error round_robin_file_registered(irods::plugin_context &_ctx)
irods::error get_next_child_in_hier(const std::string &_name, const std::string &_hier, irods::plugin_property_map &_props, irods::resource_ptr &_resc)
irods::error round_robin_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
const std::string RESOURCE_OP_NOTIFY("resource_notify")
virtual std::string resc_hier() const
irods::error round_robin_file_unlink(irods::plugin_context &_ctx)
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
const std::string RESOURCE_OP_WRITE("resource_write")
irods::error round_robin_start_operation(irods::plugin_property_map &_prop_map)
irods::error build_sorted_child_vector(irods::plugin_property_map &_props, std::vector< std::string > &_child_vector)
bool has_entry(KeyType _k) const
irods::error round_robin_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
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 round_robin_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
const std::string RESOURCE_OP_REGISTERED("resource_registered")
irods::error round_robin_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
error str(std::string &_ret_string, const std::string &_term_resc="") const
void set_start_operation(maintenance_operation_t _op)
const std::string NEXT_CHILD_PROP("round_robin_next_child")
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
irods::error round_robin_file_truncate(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
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 round_robin_file_opendir(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
error set(const std::string &_key, const ValueType &_val)
irods::error round_robin_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
const std::string CHILD_VECTOR_PROP("round_robin_child_vector")
irods::error update_next_child_resource(irods::plugin_property_map &_prop_map)
const std::string RESOURCE_OP_OPEN("resource_open")
const std::string CREATE_OPERATION("CREATE")
const std::string UNLINK_OPERATION("UNLINK")