65 std::stringstream msg;
66 msg <<
"no resource found for name ["
85 std::stringstream msg;
86 msg <<
"no resource found for name ["
96 const std::string _plugin_name,
97 const std::string _inst_name,
98 const std::string _context ) {
100 error ret = load_plugin< resource >(
106 if ( ret.
ok() && resc ) {
107 _plugin.reset( resc );
113 "loading impostor resource for [%s] of type [%s] with context [%s] and load_plugin message [%s]",
115 _plugin_name.c_str(),
120 "impostor_resource",
"" ) );
133 std::string _physical_path,
135 std::string& _out_path ) {
148 if ( _physical_path.empty() ) {
167 if ( svr_host != _svr_host ) {
174 ret = itr->second->get_property<std::string>(
RESOURCE_PATH, path );
182 if ( !path.empty() && ( _physical_path.find( path ) != std::string::npos ) ) {
189 std::stringstream msg;
190 msg <<
"resource_manager::resolve_from_physical_path - ";
191 msg <<
"failed to get vault parameter from resource";
201 if (
true == found ) {
205 std::stringstream msg;
206 msg <<
"failed to find resource for path [";
207 msg << _physical_path;
229 memset( &genQueryInp, 0,
sizeof( genQueryInp ) );
257 while ( continueInx > 0 ) {
284 if ( !proc_ret.
ok() ) {
285 irods::error log_err =
PASSMSG(
"init_from_catalog - process_init_results failed", proc_ret );
291 if ( genQueryOut !=
NULL ) {
308 if ( !proc_ret.
ok() ) {
309 return PASSMSG(
"process_init_results failed.", proc_ret );
315 if ( !proc_ret.
ok() ) {
316 return PASSMSG(
"init_child_map failed.", proc_ret );
322 if ( !op_ret.
ok() ) {
323 return PASSMSG(
"gather_operations failed.", op_ret );
329 if ( !start_err.
ok() ) {
330 return PASSMSG(
"start_resource_plugins failed.", start_err );
348 itr->second->stop_operation();
359 std::vector< std::string >& _list ) {
368 error ret = itr->second->get_parent( parent_ptr );
370 std::string resc_name;
371 ret = resc->get_property< std::string >(
RESOURCE_NAME, resc_name );
376 _list.push_back( resc_name );
388 std::string& _name ) {
391 error ret = _resc->get_property<std::string>(
398 std::string parent_id_str;
399 ret = _resc->get_property<std::string>(
406 if(parent_id_str.empty()) {
407 std::stringstream msg;
410 "empty parent string");
414 ret = lexical_cast<rodsLong_t>(
429 return parent_resc->get_property<std::string>(
435 const std::string& _resc_name,
436 std::string& _hierarchy ) {
438 _hierarchy = _resc_name;
439 std::string parent_name = _resc_name;
442 while( !parent_name.empty() ) {
461 if(!parent_name.empty()) {
462 _hierarchy = parent_name +
473 const std::string& _resc_name,
483 if(resc->num_children() > 0 ) {
485 std::vector<std::string> children;
486 resc->children(children);
489 idx < children.size();
511 _bundle.push_back( resc_id );
526 std::vector<std::string> children;
527 resc->children(children);
528 std::vector<leaf_bundle_t> ret;
529 ret.resize(children.size());
530 for (
size_t i=0; i<children.size(); ++i) {
551 sqlResult_t *rescId = 0, *rescName = 0, *zoneName = 0, *rescType = 0, *rescClass = 0;
552 sqlResult_t *rescLoc = 0, *rescVaultPath = 0, *freeSpace = 0, *rescInfo = 0;
553 sqlResult_t *rescComments = 0, *rescCreate = 0, *rescModify = 0, *rescStatus = 0;
554 sqlResult_t *rescChildren = 0, *rescContext = 0, *rescParent = 0, *rescParentContext = 0;
628 for (
int i = 0; i < _result->
rowCnt; ++i ) {
631 std::string tmpRescId = &rescId->
value[ rescId->
len * i ];
632 std::string tmpRescLoc = &rescLoc->
value[ rescLoc->
len * i ];
633 std::string tmpRescName = &rescName->value[ rescName->len * i ];
634 std::string tmpZoneName = &zoneName->value[ zoneName->len * i ];
635 std::string tmpRescType = &rescType->value[ rescType->len * i ];
636 std::string tmpRescInfo = &rescInfo->value[ rescInfo->len * i ];
637 std::string tmpFreeSpace = &freeSpace->value[ freeSpace->len * i ];
638 std::string tmpRescClass = &rescClass->value[ rescClass->len * i ];
639 std::string tmpRescCreate = &rescCreate->value[ rescCreate->len * i ];
640 std::string tmpRescModify = &rescModify->value[ rescModify->len * i ];
641 std::string tmpRescStatus = &rescStatus->value[ rescStatus->len * i ];
642 std::string tmpRescComments = &rescComments->
value[ rescComments->
len * i ];
643 std::string tmpRescVaultPath = &rescVaultPath->value[ rescVaultPath->len * i ];
644 std::string tmpRescChildren = &rescChildren->
value[ rescChildren->
len * i ];
645 std::string tmpRescContext = &rescContext->value[ rescContext->len * i ];
646 std::string tmpRescParent = &rescParent->value[ rescParent->len * i ];
647 std::string tmpRescParentCtx = &rescParentContext->value[ rescParent->len * i ];
666 if (
resolveHost( &addr, &tmpRodsServerHost ) < 0 ) {
678 rodsLong_t resource_id = strtoll( tmpRescId.c_str(), 0, 0 );
683 resc->set_property<std::string>(
RESOURCE_ZONE, tmpZoneName );
684 resc->set_property<std::string>(
RESOURCE_NAME, tmpRescName );
686 resc->set_property<std::string>(
RESOURCE_TYPE, tmpRescType );
688 resc->set_property<std::string>(
RESOURCE_PATH, tmpRescVaultPath );
689 resc->set_property<std::string>(
RESOURCE_INFO, tmpRescInfo );
698 if ( tmpRescStatus == std::string(
RESC_DOWN ) ) {
727 return PASSMSG(
"Failed to load Resource Plugin", ret );
740 const std::string& child_name = itr.first;
743 std::string parent_id_str;
744 error ret = child_resc->get_property<std::string>(
747 if(!ret.
ok() || parent_id_str.empty()) {
752 ret = lexical_cast<rodsLong_t>(
763 "invalid parent resource id %ld",
770 std::string parent_child_context;
771 ret = child_resc->get_property<std::string>(
773 parent_child_context );
777 parent_resc->add_child(
779 parent_child_context,
782 child_resc->set_parent(parent_resc);
786 "%s - add [%s][%s] to [%ld]",
789 parent_child_context.c_str(),
803 std::string loc, path,
name;
806 if ( path_err.
ok() && loc_err.ok() &&
"localhost" == loc ) {
808 itr->first.c_str(), path.c_str() );
821 std::vector< std::string > proc_vec;
834 if ( get_err.
ok() ) {
835 std::vector< std::string >::iterator itr;
836 itr = std::find< std::vector< std::string >::iterator, std::string >( proc_vec.begin(), proc_vec.end(),
name );
837 if ( proc_vec.end() != itr ) {
842 std::stringstream msg;
843 msg <<
"resource_manager::gather_operations - failed to get property ";
844 msg <<
"[name] for resource";
845 return PASSMSG( msg.str(), get_err );
850 std::vector< pdmo_type > resc_ops;
855 error pdmo_err = resc->post_disconnect_maintenance_operation( pdmo_op );
856 if ( pdmo_err.
ok() ) {
857 resc_ops.push_back( pdmo_op );
862 proc_vec.push_back(
name );
866 std::string child_str;
868 if ( child_err.
ok() && !child_str.empty() ) {
874 if ( !resc_ops.empty() ) {
888 std::vector< std::string >& _proc_vec,
889 std::vector< pdmo_type >& _resc_ops ) {
893 parser.set_string( _children );
897 return PASSMSG(
"gather_operations_recursive failed.", ret );
902 children_parser::children_map_t::const_iterator itr;
903 for ( itr = children_list.begin(); itr != children_list.end(); ++itr ) {
904 std::string child = itr->first;
910 if ( get_err.
ok() ) {
914 error pdmo_ret = resc->post_disconnect_maintenance_operation( pdmo_op );
915 if ( pdmo_ret.
ok() ) {
916 _resc_ops.push_back( pdmo_op );
921 _proc_vec.push_back( child );
925 std::stringstream msg;
926 msg <<
"failed to get resource for key [";
936 for ( itr = children_list.begin(); itr != children_list.end(); ++itr ) {
937 std::string child = itr->first;
943 if ( get_err.
ok() ) {
944 std::string child_str;
946 if ( child_err.
ok() && !child_str.empty() ) {
952 std::stringstream msg;
953 msg <<
"failed to get resource for key [";
976 error ret = itr->second->start_operation( );
991 bool need_pdmo =
false;
1002 itr->second->need_post_disconnect_maintenance_operation( flg );
1021 std::vector< std::vector< pdmo_type > >
::iterator vec_itr;
1027 std::vector< pdmo_type >::iterator op_itr;
1028 for ( op_itr = vec_itr->begin();
1029 op_itr != vec_itr->end();
1034 error ret = ( ( *op_itr ) )( _comm );
1036 log(
PASSMSG(
"resource_manager::call_maintenance_operations - op failed", ret ) );
1037 result = ret.
code();
1040 catch (
const boost::bad_function_call& ) {
1041 rodsLog(
LOG_ERROR,
"maintenance operation threw boost::bad_function_call" );
1057 std::vector<std::string> hier_list;
1060 if ( resc->num_children() > 0 ) {
1072 std::string curr_hier;
1077 hier_list.push_back( curr_hier );
1083 const std::string& _hier,
1088 "empty hierarchy string" );
1092 p.set_string( _hier );
1095 p.last_resc( leaf );
1121 std::string& _hier ) {
1123 std::stringstream msg;
1124 msg <<
"invalid resource id: " << _id;
1133 error ret = resc->get_property<std::string>(
1140 resc->get_parent(resc);
1141 while( resc.get() ) {
1143 error ret = resc->get_property<std::string>(
1150 hier.insert( 0,
";" );
1151 hier.insert( 0,
name);
1153 resc->get_parent(resc);
1164 std::string& _name ) {
1171 std::stringstream msg;
1172 msg <<
"invalid resource id: " << _id;
1181 error ret = resc->get_property<std::string>(
1193 const std::string& _id_str,
1194 std::string& _name ) {
1196 if(
"0" == _id_str || _id_str.empty()) {
1201 error ret = lexical_cast<rodsLong_t>(
1209 std::stringstream msg;
1210 msg <<
"invalid resource id: " << _id_str;
1218 ret = resc->get_property<std::string>(
1230 const std::string& _resc_name,
1240 _ret = resc->num_children() > 0;