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.
29 #include <boost/lexical_cast.hpp>
30 #include <boost/function.hpp>
31 #include <boost/any.hpp>
33 #define MAX_ELAPSE_TIME 1800
45 template<
typename DEST_TYPE >
53 result =
ASSERT_PASS( ret,
"Resource context invalid." );
63 const std::string& _name,
64 const std::string& _hier,
78 if ( ( result =
ASSERT_PASS( err,
"Failed in set_string" ) ).ok() ) {
83 err = parse.next( _name,
next );
85 if ( ( result =
ASSERT_PASS( err,
"Failed in next." ) ).ok() ) {
90 next.c_str() ) ).ok() ) {
93 _resc = (*cmap_ref)[
next ].second;
105 template<
typename DEST_TYPE >
113 irods::error err = load_balanced_check_params< DEST_TYPE >( _ctx );
114 if ( ( result =
ASSERT_PASS( err,
"Bad resource context." ) ).ok() ) {
120 if ( ( result =
ASSERT_PASS( err,
"Failed to get property." ) ).ok() ) {
124 boost::shared_ptr< DEST_TYPE > dst_obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.
fco() );
125 std::string hier = dst_obj->resc_hier( );
130 result =
ASSERT_PASS( err,
"Get next child failed." );
143 srand( time(
NULL ) );
157 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
158 if ( ( result =
ASSERT_PASS( err,
"Invalid resource context." ) ).ok() ) {
163 result =
ASSERT_PASS( err,
"Failed calling create on child resource." );
178 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
179 if ( ( result =
ASSERT_PASS( err,
"Failed in file open." ) ).ok() ) {
184 result =
ASSERT_PASS( err,
"Failed calling open on the child." );
201 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
202 if ( ( result =
ASSERT_PASS( err,
"Failed finding resource." ) ).ok() ) {
207 result =
ASSERT_PASS( err,
"Failed calling operation on child resource." );
225 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
226 if ( ( result =
ASSERT_PASS( err,
"Failed choosing child resource." ) ).ok() ) {
231 result =
ASSERT_PASS( err,
"Failed calling operation on child resource." );
246 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
247 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
252 result =
ASSERT_PASS( err,
"Failed calling operation in child." );
267 irods::error err = load_balanced_get_resc_for_call< irods::data_object >( _ctx, resc );
268 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
273 result =
ASSERT_PASS( err,
"Failed during call to child operation." );
283 struct stat* _statbuf ) {
289 irods::error err = load_balanced_get_resc_for_call< irods::data_object >( _ctx, resc );
290 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced child resource." ) ).ok() ) {
295 result =
ASSERT_PASS( err,
"Failed in call to child operation." );
312 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
313 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced child." ) ).ok() ) {
318 result =
ASSERT_PASS( err,
"Failed calling child operation." );
333 irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc );
334 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced child resource." ) ).ok() ) {
339 result =
ASSERT_PASS( err,
"Failed calling child operation." );
354 irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc );
355 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
360 result =
ASSERT_PASS( err,
"Failed calling child operation." );
375 irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc );
376 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
381 result =
ASSERT_PASS( err,
"Failed calling child operation." );
396 irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc );
397 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
402 result =
ASSERT_PASS( err,
"Failed calling child operation." );
418 irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc );
419 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
424 result =
ASSERT_PASS( err,
"Failed calling child operation." );
434 const char* _new_file_name ) {
440 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
441 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
446 result =
ASSERT_PASS( err,
"Failed calling child operation." );
461 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
462 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
467 result =
ASSERT_PASS( err,
"Failed calling child operation." );
482 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
483 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
488 result =
ASSERT_PASS( err,
"Failed calling child operation." );
499 const char* _cache_file_name ) {
505 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
506 if ( ( result =
ASSERT_PASS( err,
"Failed to select load_balanced resource." ) ).ok() ) {
510 result =
ASSERT_PASS( err,
"Failed calling child operation." );
522 const char* _cache_file_name ) {
528 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
529 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
534 result =
ASSERT_PASS( err,
"Failed calling child operation." );
549 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
550 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
555 result =
ASSERT_PASS( err,
"Failed calling child operation." );
570 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
571 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
576 result =
ASSERT_PASS( err,
"Failed calling child operation." );
591 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
592 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
597 result =
ASSERT_PASS( err,
"Failed calling child operation." );
607 const std::string* _opr ) {
613 irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc );
614 if ( ( result =
ASSERT_PASS( err,
"Failed selecting load_balanced resource." ) ).ok() ) {
619 result =
ASSERT_PASS( err,
"Failed calling child operation." );
630 std::vector< std::string >& _resc_names,
631 std::vector< int >& _resc_loads,
632 std::vector< int >& _resc_times ) {
635 int i = 0, j = 0, nresc = 0,
status = 0;
643 memset( &genQueryInp, 0,
sizeof( genQueryInp ) );
653 nresc = genQueryOut->
rowCnt;
657 _resc_names.resize( nresc );
658 _resc_loads.resize( nresc );
659 _resc_times.resize( nresc );
661 for ( i = 0; i < genQueryOut->
attriCnt; i++ ) {
662 for ( j = 0; j < nresc; j++ ) {
667 _resc_names[j] = tResult;
670 _resc_loads[j] = atoi( tResult );
673 _resc_times[j] = atoi( tResult );
698 const std::string* _opr,
699 const std::string* _curr_host,
704 std::vector< std::string > names;
705 std::vector< int > loads;
706 std::vector< int > times;
732 bool resc_found =
false;
736 for ( ; itr != cmap_ref->
end(); ++itr ) {
743 std::string resc_name;
751 for (
size_t i = 0; i < names.size(); ++i ) {
752 if ( resc_name == names[ i ] ) {
753 if ( loads[ i ] >= 0 &&
754 min_load > loads[ i ] &&
758 selected_resource = resc;
772 "failed to find child resc in load list" );
796 "load_balanced node - hier : [%s], vote %f",
805 ( *_out_parser ) =
parser;
806 ( *_out_vote ) = vote;
816 const std::string* _opr,
817 const std::string* _curr_host,
825 std::map< float, irods::hierarchy_parser > result_map;
832 if(cmap_ref->
empty()) {
839 for ( ; itr != cmap_ref->
end(); ++itr ) {
867 rodsLog(
LOG_DEBUG10,
"load_balanced node - hier : [%s], vote %f", hier.c_str(), vote );
872 result_map[ vote ] =
parser;
877 if( result_map.empty() ) {
885 float high_vote = result_map.rbegin()->first;
886 if(0.0 == high_vote) {
889 else if ( high_vote > 0.0 ) {
890 ( *_out_parser ) = result_map.rbegin()->second;
891 ( *_out_vote ) = high_vote;
896 return ERROR( -1,
"no valid data object found to open" );
907 const std::string* _opr,
908 const std::string* _curr_host,
915 irods::error err = load_balanced_check_params< irods::file_object >( _ctx );
916 if ( ( result =
ASSERT_PASS( err,
"Invalid resource context." ) ).ok() ) {
918 "Invalid parameters." ) ).ok() ) {
922 std::string hier = file_obj->resc_hier( );
939 std::string err_msg =
"failed in resolve hierarchy for [" + ( *_opr ) +
"]";
949 std::string err_msg =
"failed in resolve hierarchy for [" + ( *_opr ) +
"]";
981 for ( ; itr != cmap_ref->
end(); ++itr ) {
983 if ( !( result =
ASSERT_PASS( ret,
"Failed calling child operation." ) ).ok() ) {
988 if ( !result.ok() ) {
989 return PASS( result );
1004 const std::string& _inst_name,
1005 const std::string& _context ) :
1016 "libload_balanced: invalid context [%s]",
1032 "load_balanced_resource :: using localhost policy, none specificed" );
1041 return ERROR( -1,
"nop" );
1047 return ERROR( -1,
"nop" );
1061 const std::string& _context ) {
1070 using namespace irods;
1071 using namespace std;
1090 function<error(plugin_context&,void*,int)>(
1105 function<error(plugin_context&, struct stat*)>(
1120 function<error(plugin_context&,struct rodsDirent**)>(
1125 function<error(plugin_context&, const char*)>(
1135 function<error(plugin_context&, long long, int)>(
1150 function<error(plugin_context&, const char*)>(
1155 function<error(plugin_context&, const char*)>(
1175 function<error(plugin_context&, const std::string*)>(
1185 function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
void rodsLog(int level, const char *formatStr,...)
#define COL_SLD_LOAD_FACTOR
const std::string RESOURCE_NAME("resource_property_name")
const std::string RESOURCE_OP_STAT("resource_stat")
irods::error load_balanced_start_operation(irods::plugin_property_map &, irods::resource_child_map &)
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_)
irods::error load_balanced_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
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 load_balanced_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
const std::string RESOURCE_OP_READ("resource_read")
#define COL_SLD_RESC_NAME
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods_hash_map::iterator iterator
const std::string RESOURCE_OP_LSEEK("resource_lseek")
irods::error load_balanced_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
const std::string DEFER_POLICY_KEY("defer_policy")
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
sqlResult_t sqlResult[50]
irods::error load_balanced_file_notify(irods::plugin_context &_ctx, const std::string *_opr)
#define ASSERT_ERROR(expr_, code_, format_,...)
virtual rsComm_t * comm()
const std::string RESOURCE_OP_TRUNCATE("resource_truncate")
irods::error load_balanced_file_modified(irods::plugin_context &_ctx)
irods::error post_disconnect_maintenance_operation(irods::pdmo_type &)
const std::string RESOURCE_OP_RENAME("resource_rename")
irods::error load_balanced_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
const std::string OPEN_OPERATION("OPEN")
virtual irods::plugin_property_map & prop_map()
plugin_property_map properties_
irods::error load_balanced_redirect_for_create_operation(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
#define COL_SLD_CREATE_TIME
error add_child(const std::string &_resc)
const std::string RESOURCE_OP_CREATE("resource_create")
irods::error load_balanced_file_close(irods::plugin_context &_ctx)
irods::error load_balanced_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
irods::error load_balanced_redirect_for_open_operation(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
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 DEFER_POLICY_LOCALHOST("localhost_defer_policy")
const std::string RESOURCE_OP_NOTIFY("resource_notify")
irods::error load_balanced_file_registered(irods::plugin_context &_ctx)
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
const std::string RESOURCE_OP_WRITE("resource_write")
irods::error load_balanced_file_opendir(irods::plugin_context &_ctx)
irods::error get_load_lists(irods::plugin_context &_ctx, std::vector< std::string > &_resc_names, std::vector< int > &_resc_loads, std::vector< int > &_resc_times)
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
#define ASSERT_PASS(prev_error_, format_,...)
irods::error load_balanced_file_resolve_hierarchy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
bool has_entry(KeyType _k) const
const std::string RESOURCE_OP_CLOSE("resource_close")
irods::error load_balanced_check_params(irods::plugin_context &_ctx)
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")
irods::error load_balanced_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
irods::error load_balanced_file_unlink(irods::plugin_context &_ctx)
#define ERROR(code_, message_)
const std::string RESOURCE_OP_UNREGISTERED("resource_unregistered")
irods::error load_balanced_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
irods::error load_balanced_file_rmdir(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_REGISTERED("resource_registered")
error parse_kvp_string(const std::string &_str, kvp_map_t &_kvp, const std::string &_association=KVP_DEF_ASSOCIATION, const std::string &_delimeter=KVP_DEF_DELIMITER)
irods::error load_balanced_file_open(irods::plugin_context &_ctx)
irods::error load_balanced_file_rebalance(irods::plugin_context &_ctx)
irods::error load_balanced_file_closedir(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
irods::error need_post_disconnect_maintenance_operation(bool &_flg)
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 load_balanced_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
load_balanced_resource(const std::string &_inst_name, const std::string &_context)
irods::error load_balanced_get_resc_for_call(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
irods::error load_balanced_file_mkdir(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
irods::error load_balanced_file_create(irods::plugin_context &_ctx)
error set(const std::string &_key, const ValueType &_val)
int freeGenQueryOut(genQueryOut_t **genQueryOut)
std::map< std::string, std::string > kvp_map_t
irods::error load_balanced_file_unregistered(irods::plugin_context &_ctx)
const std::string RESOURCE_OP_OPEN("resource_open")
void clearGenQueryInp(void *voidInp)
const std::string CREATE_OPERATION("CREATE")
int rsGenQuery(rsComm_t *rsComm, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut)
const std::string UNLINK_OPERATION("UNLINK")
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
irods::error load_balanced_file_getfs_freespace(irods::plugin_context &_ctx)
irods::error load_balanced_file_truncate(irods::plugin_context &_ctx)