/// =-=-=-=-=-=-=- /// @brief used to allow the resource to determine which host /// should provide the requested operation irods::error load_balanced_redirect( irods::resource_plugin_context& _ctx, const std::string* _opr, const std::string* _curr_host, irods::hierarchy_parser* _out_parser, float* _out_vote ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // check incoming parameters irods::error err = load_balanced_check_params< irods::file_object >( _ctx ); if ( ( result = ASSERT_PASS( err, "Invalid resource context." ) ).ok() ) { if ( ( result = ASSERT_ERROR( _opr && _curr_host && _out_parser && _out_vote, SYS_INVALID_INPUT_PARAM, "Invalid parameters." ) ).ok() ) { // =-=-=-=-=-=-=- // get the object's hier string irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); std::string hier = file_obj->resc_hier( ); // =-=-=-=-=-=-=- // get the object's hier string std::string name; err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name ); if ( ( result = ASSERT_PASS( err, "Failed to get property: \"%s\".", irods::RESOURCE_NAME.c_str() ) ).ok() ) { // =-=-=-=-=-=-=- // add ourselves into the hierarch before calling child resources _out_parser->add_child( name ); // =-=-=-=-=-=-=- // test the operation to determine which choices to make if ( irods::OPEN_OPERATION == ( *_opr ) || irods::WRITE_OPERATION == ( *_opr ) ) { std::string err_msg = "failed in resolve hierarchy for [" + ( *_opr ) + "]"; err = load_balanced_redirect_for_open_operation( _ctx, _opr, _curr_host, _out_parser, _out_vote ); result = ASSERT_PASS( err, err_msg ); } else if ( irods::CREATE_OPERATION == ( *_opr ) ) { // =-=-=-=-=-=-=- // get the next_child resource for create irods::resource_ptr resc; std::string err_msg = "failed in resolve hierarchy for [" + ( *_opr ) + "]"; err = load_balanced_redirect_for_create_operation( _ctx, _opr, _curr_host, _out_parser, _out_vote ); result = ASSERT_PASS( err, err_msg ); } else { // =-=-=-=-=-=-=- // must have been passed a bad operation result = ASSERT_ERROR( false, INVALID_OPERATION, "Operation not supported: \"%s\".", _opr->c_str() ); } } } } return result; } // load_balanced_redirect
/// =-=-=-=-=-=-=- /// @brief get the next resource shared pointer given this resources name /// as well as the object's hierarchy string irods::error get_next_child_in_hier( const std::string& _name, const std::string& _hier, irods::resource_child_map& _cmap, irods::resource_ptr& _resc ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // create a parser and parse the string irods::hierarchy_parser parse; irods::error err = parse.set_string( _hier ); if ( ( result = ASSERT_PASS( err, "Failed in set_string" ) ).ok() ) { // =-=-=-=-=-=-=- // get the next resource in the series std::string next; err = parse.next( _name, next ); if ( ( result = ASSERT_PASS( err, "Failed in next." ) ).ok() ) { // =-=-=-=-=-=-=- // get the next resource from the child map if ( ( result = ASSERT_ERROR( _cmap.has_entry( next ), CHILD_NOT_FOUND, "Child map missing entry: \"%s\"", next.c_str() ) ).ok() ) { // =-=-=-=-=-=-=- // assign resource _resc = _cmap[ next ].second; } } } return result; } // get_next_child_in_hier
irods::error random_get_resc_for_call( irods::resource_plugin_context& _ctx, irods::resource_ptr& _resc ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // check incoming parameters irods::error err = random_check_params< DEST_TYPE >( _ctx ); if ( ( result = ASSERT_PASS( err, "Bad resource context." ) ).ok() ) { // =-=-=-=-=-=-=- // get the object's name std::string name; err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name ); if ( ( result = ASSERT_PASS( err, "Failed to get property." ) ).ok() ) { // =-=-=-=-=-=-=- // get the object's hier string boost::shared_ptr< DEST_TYPE > dst_obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.fco() ); std::string hier = dst_obj->resc_hier( ); // =-=-=-=-=-=-=- // get the next child pointer given our name and the hier string err = get_next_child_in_hier( name, hier, _ctx.child_map(), _resc ); result = ASSERT_PASS( err, "Get next child failed." ); } } return result; } // random_get_resc_for_call
// =-=-=-=-=-=-=- // unixStageToCache - This routine is for testing the TEST_STAGE_FILE_TYPE. // Just copy the file from filename to cacheFilename. optionalInfo info // is not used. irods::error mock_archive_stagetocache_plugin( irods::resource_plugin_context& _ctx, const char* _cache_file_name ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // Check the operation parameters and update the physical path irods::error ret = unix_check_params_and_path< irods::file_object >( _ctx ); if ( ( result = ASSERT_PASS( ret, "Invalid plugin context." ) ).ok() ) { // =-=-=-=-=-=-=- // get ref to fco irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // get the vault path for the resource std::string path; ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_PATH, path ); if ( ( result = ASSERT_PASS( ret, "Failed to retrieve vault path for resource." ) ).ok() ) { // =-=-=-=-=-=-=- // append the hash to the path as the new 'cache file name' path += "/"; path += fco->physical_path().c_str(); int status = mockArchiveCopyPlugin( fco->mode(), fco->physical_path().c_str(), _cache_file_name ); result = ASSERT_ERROR( status >= 0, status, "Failed copying archive file: \"%s\" to cache file: \"%s\".", fco->physical_path().c_str(), _cache_file_name ); } } return result; } // mock_archive_stagetocache_plugin
// =-=-=-=-=-=-=- // used to allow the resource to determine which host // should provide the requested operation irods::error impostor_resource_redirect_plugin( irods::resource_plugin_context& _ctx, const std::string* _opr, const std::string* _curr_host, irods::hierarchy_parser* _out_parser, float* _out_vote ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // check the context validity irods::error ret = _ctx.valid< irods::file_object >(); if ( ( result = ASSERT_PASS( ret, "Invalid resource context." ) ).ok() ) { // =-=-=-=-=-=-=- // check incoming parameters if ( ( result = ASSERT_ERROR( _opr && _curr_host && _out_parser && _out_vote, SYS_INVALID_INPUT_PARAM, "Invalid input parameter." ) ).ok() ) { // =-=-=-=-=-=-=- // cast down the chain to our understood object type irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // get the name of this resource std::string resc_name; ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, resc_name ); if ( ( result = ASSERT_PASS( ret, "Failed in get property for name." ) ).ok() ) { // =-=-=-=-=-=-=- // add ourselves to the hierarchy parser by default _out_parser->add_child( resc_name ); // =-=-=-=-=-=-=- // test the operation to determine which choices to make if ( irods::OPEN_OPERATION == ( *_opr ) || irods::WRITE_OPERATION == ( *_opr ) ) { // =-=-=-=-=-=-=- // call redirect determination for 'get' operation ret = impostor_resource_redirect_open( _ctx.prop_map(), file_obj, resc_name, ( *_curr_host ), ( *_out_vote ) ); result = ASSERT_PASS_MSG( ret, "Failed redirecting for open." ); } else if ( irods::CREATE_OPERATION == ( *_opr ) ) { // =-=-=-=-=-=-=- // call redirect determination for 'create' operation ret = impostor_resource_redirect_create( _ctx.prop_map(), file_obj, resc_name, ( *_curr_host ), ( *_out_vote ) ); result = ASSERT_PASS_MSG( ret, "Failed redirecting for create." ); } else { // =-=-=-=-=-=-=- // must have been passed a bad operation result = ASSERT_ERROR( false, INVALID_OPERATION, "Operation not supported." ); } } } } return result; } // impostor_resource_redirect_plugin
// =-=-=-=-=-=-=- // redirect_create - code to determine redirection for create operation irods::error impostor_resource_redirect_create( irods::plugin_property_map& _prop_map, irods::file_object_ptr _file_obj, const std::string& _resc_name, const std::string& _curr_host, float& _out_vote ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // determine if the resource is down int resc_status = 0; irods::error get_ret = _prop_map.get< int >( irods::RESOURCE_STATUS, resc_status ); if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"status\" property." ) ).ok() ) { // =-=-=-=-=-=-=- // if the status is down, vote no. if ( INT_RESC_STATUS_DOWN == resc_status ) { _out_vote = 0.0; result.code( SYS_RESC_IS_DOWN ); // result = PASS( result ); } else { // =-=-=-=-=-=-=- // get the resource host for comparison to curr host std::string host_name; get_ret = _prop_map.get< std::string >( irods::RESOURCE_LOCATION, host_name ); if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"location\" property." ) ).ok() ) { // =-=-=-=-=-=-=- // vote higher if we are on the same host if ( _curr_host == host_name ) { _out_vote = 1.0; } else { _out_vote = 0.5; } } rodsLog( LOG_DEBUG, "create :: resc name [%s] curr host [%s] resc host [%s] vote [%f]", _resc_name.c_str(), _curr_host.c_str(), host_name.c_str(), _out_vote ); } } return result; } // impostor_resource_redirect_create
// =-=-=-=-=-=-=- // unixSyncToArch - This routine is for testing the TEST_STAGE_FILE_TYPE. // Just copy the file from cacheFilename to filename. optionalInfo info // is not used. irods::error mock_archive_synctoarch_plugin( irods::resource_plugin_context& _ctx, char* _cache_file_name ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // Check the operation parameters and update the physical path irods::error ret = unix_check_params_and_path< irods::file_object >( _ctx ); if ( ( result = ASSERT_PASS( ret, "Invalid plugin context." ) ).ok() ) { // =-=-=-=-=-=-=- // get ref to fco irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // get the vault path for the resource std::string path; ret = make_hashed_path( _ctx.prop_map(), fco->physical_path(), path ); if ( ( result = ASSERT_PASS( ret, "Failed to gen hashed path" ) ).ok() ) { // =-=-=-=-=-=-=- // append the hash to the path as the new 'cache file name' rodsLog( LOG_NOTICE, "mock archive :: cache file name [%s]", _cache_file_name ); rodsLog( LOG_NOTICE, "mock archive :: new hashed file name for [%s] is [%s]", fco->physical_path().c_str(), path.c_str() ); // =-=-=-=-=-=-=- // make the directories in the path to the new file std::string new_path = path; std::size_t last_slash = new_path.find_last_of( '/' ); new_path.erase( last_slash ); ret = mock_archive_mkdir_r( new_path.c_str(), 0750 ); if ( ( result = ASSERT_PASS( ret, "Mkdir error for \"%s\".", new_path.c_str() ) ).ok() ) { } // =-=-=-=-=-=-=- // make the copy to the 'archive' int status = mockArchiveCopyPlugin( fco->mode(), _cache_file_name, path.c_str() ); if ( ( result = ASSERT_ERROR( status >= 0, status, "Sync to arch failed." ) ).ok() ) { fco->physical_path( path ); } } } return result; } // mock_archive_synctoarch_plugin
// =-=-=-=-=-=-=- /// @brief update the physical path in the file object irods::error unix_check_path( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); try { irods::data_object_ptr data_obj = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // NOTE: Must do this for all storage resources std::string full_path; irods::error ret = mock_archive_generate_full_path( _ctx.prop_map(), data_obj->physical_path(), full_path ); if ( ( result = ASSERT_PASS( ret, "Failed generating full path for object." ) ).ok() ) { data_obj->physical_path( full_path ); } return result; } catch ( const std::bad_cast& ) { return ERROR( SYS_INVALID_INPUT_PARAM, "failed to cast fco to data_object" ); } } // unix_check_path
// =-=-=-=-=-=-=- /// @brief Generates a full path name from the partial physical path and the specified resource's vault path irods::error mock_archive_generate_full_path( irods::plugin_property_map& _prop_map, const std::string& _phy_path, std::string& _ret_string ) { irods::error result = SUCCESS(); irods::error ret; std::string vault_path; // TODO - getting vault path by property will not likely work for coordinating nodes ret = _prop_map.get<std::string>( irods::RESOURCE_PATH, vault_path ); if ( ( result = ASSERT_PASS( ret, "Resource has no vault path." ) ).ok() ) { if ( _phy_path.compare( 0, 1, "/" ) != 0 && _phy_path.compare( 0, vault_path.size(), vault_path ) != 0 ) { _ret_string = vault_path; _ret_string += "/"; _ret_string += _phy_path; } else { // The physical path already contains the vault path _ret_string = _phy_path; } } return result; } // mock_archive_generate_full_path
// =-=-=-=-=-=-=- // interface for POSIX Unlink irods::error mock_archive_unlink_plugin( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // Check the operation parameters and update the physical path irods::error ret = unix_check_params_and_path< irods::file_object >( _ctx ); if ( ( result = ASSERT_PASS( ret, "Invalid plugin context." ) ).ok() ) { // =-=-=-=-=-=-=- // get ref to fco irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // make the call to unlink int status = unlink( fco->physical_path().c_str() ); // =-=-=-=-=-=-=- // error handling int err_status = UNIX_FILE_UNLINK_ERR - errno; result = ASSERT_ERROR( status >= 0, err_status, "Unlink error for: \"%s\", errno = \"%s\", status = %d.", fco->physical_path().c_str(), strerror( errno ), err_status ); } return result; } // mock_archive_unlink_plugin
// =-=-=-=-=-=-=- // interface for POSIX readdir irods::error mock_archive_rename_plugin( irods::resource_plugin_context& _ctx, const char* _new_file_name ) { // =-=-=-=-=-=-=- // Check the operation parameters and update the physical path irods::error result = SUCCESS(); irods::error ret = unix_check_params_and_path< irods::data_object >( _ctx ); if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) { // =-=-=-=-=-=-=- // manufacture a new path from the new file name std::string new_full_path; ret = mock_archive_generate_full_path( _ctx.prop_map(), _new_file_name, new_full_path ); if ( ( result = ASSERT_PASS( ret, "Unable to generate full path for destination file: \"%s\".", _new_file_name ) ).ok() ) { // =-=-=-=-=-=-=- // cast down the hierarchy to the desired object irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() ); // =-=-=-=-=-=-=- // get hashed names for the old path std::string new_hash; ret = make_hashed_path( _ctx.prop_map(), _new_file_name, new_hash ); if ( ( result = ASSERT_PASS( ret, "Failed to gen hashed path" ) ).ok() ) { // =-=-=-=-=-=-=- // make the call to rename int status = rename( fco->physical_path().c_str(), new_hash.c_str() ); // =-=-=-=-=-=-=- // handle error cases int err_status = UNIX_FILE_RENAME_ERR - errno; if ( ( result = ASSERT_ERROR( status >= 0, err_status, "Rename error for \"%s\" to \"%s\", errno = \"%s\", status = %d.", fco->physical_path().c_str(), new_hash.c_str(), strerror( errno ), err_status ) ).ok() ) { fco->physical_path( new_hash ); result.code( status ); } } } } return result; } // mock_archive_rename_plugin
// =-=-=-=-=-=-=- // interface for POSIX Open irods::error random_file_open( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed in file open." ) ).ok() ) { // =-=-=-=-=-=-=- // call open operation on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_OPEN, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling open on the child." ); } return result; } // random_file_open
/// =-=-=-=-=-=-=- /// @brief interface for POSIX create irods::error random_file_create( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Invalid resource context." ) ).ok() ) { // =-=-=-=-=-=-=- // call create on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_CREATE, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling create on child resource." ); } return result; } // random_file_create
// =-=-=-=-=-=-=- /// @brief interface for POSIX closedir irods::error random_file_closedir( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::collection_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select random resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call closedir on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSEDIR, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // random_file_closedir
/// =-=-=-=-=-=-=- /// @brief interface to notify of a file unregistration irods::error load_balanced_file_unregistered( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed selecting load_balanced resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call rename on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_UNREGISTERED, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // load_balanced_file_unregistered
/// =-=-=-=-=-=-=- /// @brief This routine copys data from the archive resource to the cache resource /// in a compound resource composition irods::error load_balanced_file_stage_to_cache( irods::resource_plugin_context& _ctx, const char* _cache_file_name ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select load_balanced resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call stage on the child err = resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_STAGETOCACHE, _ctx.fco(), _cache_file_name ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // load_balanced_file_stage_to_cache
/// =-=-=-=-=-=-=- /// @brief interface for POSIX Close irods::error load_balanced_file_close( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select load_balanced resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call close on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSE, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling operation in child." ); } return result; } // load_balanced_file_close
/// =-=-=-=-=-=-=- /// @brief interface for POSIX Unlink irods::error random_file_unlink( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::data_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select random resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call unlink on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_UNLINK, _ctx.fco() ); result = ASSERT_PASS( err, "Failed during call to child operation." ); } return result; } // random_file_unlink
/// =-=-=-=-=-=-=- /// @brief interface to notify of a file modification irods::error random_file_modified( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed selecting random resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call rename on the child err = resc->call( _ctx.comm(), irods::RESOURCE_OP_MODIFIED, _ctx.fco() ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // random_file_modified
/// =-=-=-=-=-=-=- /// @brief interface for POSIX Stat irods::error random_file_stat( irods::resource_plugin_context& _ctx, struct stat* _statbuf ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::data_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed selecting random child resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call stat on the child err = resc->call< struct stat* >( _ctx.comm(), irods::RESOURCE_OP_STAT, _ctx.fco(), _statbuf ); result = ASSERT_PASS( err, "Failed in call to child operation." ); } return result; } // random_file_stat
/// =-=-=-=-=-=-=- /// @brief interface for POSIX readdir irods::error load_balanced_file_readdir( irods::resource_plugin_context& _ctx, struct rodsDirent** _dirent_ptr ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = load_balanced_get_resc_for_call< irods::collection_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select load_balanced resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call readdir on the child err = resc->call< struct rodsDirent** >( _ctx.comm(), irods::RESOURCE_OP_READDIR, _ctx.fco(), _dirent_ptr ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // load_balanced_file_readdir
/// =-=-=-=-=-=-=- /// @brief This routine is for testing the TEST_STAGE_FILE_TYPE. /// Just copy the file from cacheFilename to filename. optionalInfo info /// is not used. irods::error random_file_sync_to_arch( irods::resource_plugin_context& _ctx, const char* _cache_file_name ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed selecting random resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call synctoarch on the child err = resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_SYNCTOARCH, _ctx.fco(), _cache_file_name ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // random_file_sync_to_arch
/// =-=-=-=-=-=-=- /// @brief interface for POSIX rename irods::error random_file_rename( irods::resource_plugin_context& _ctx, const char* _new_file_name ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select random resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call rename on the child err = resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_RENAME, _ctx.fco(), _new_file_name ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // random_file_rename
/// =-=-=-=-=-=-=- /// @brief interface for POSIX Write irods::error random_file_write( irods::resource_plugin_context& _ctx, void* _buf, int _len ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed choosing child resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call write on the child err = resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_WRITE, _ctx.fco(), _buf, _len ); result = ASSERT_PASS( err, "Failed calling operation on child resource." ); } return result; } // random_file_write
/// =-=-=-=-=-=-=- /// @brief interface for POSIX lseek irods::error random_file_lseek( irods::resource_plugin_context& _ctx, long long _offset, int _whence ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = random_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed to select random child." ) ).ok() ) { // =-=-=-=-=-=-=- // call lseek on the child err = resc->call< long long, int >( _ctx.comm(), irods::RESOURCE_OP_LSEEK, _ctx.fco(), _offset, _whence ); result = ASSERT_PASS( err, "Failed calling child operation." ); } return result; } // random_file_lseek
/// =-=-=-=-=-=-=- /// @brief interface for POSIX Read irods::error load_balanced_file_read( irods::resource_plugin_context& _ctx, void* _buf, int _len ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // get the child resc to call irods::resource_ptr resc; irods::error err = load_balanced_get_resc_for_call< irods::file_object >( _ctx, resc ); if ( ( result = ASSERT_PASS( err, "Failed finding resource." ) ).ok() ) { // =-=-=-=-=-=-=- // call read on the child err = resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_READ, _ctx.fco(), _buf, _len ); result = ASSERT_PASS( err, "Failed calling operation on child resource." ); } return result; } // load_balanced_file_read
inline irods::error random_check_params( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); // =-=-=-=-=-=-=- // ask the context if it is valid irods::error ret = _ctx.valid< DEST_TYPE >(); result = ASSERT_PASS( ret, "Resource context invalid." ); return result; } // random_check_params
error gsi_auth_object::resolve( const std::string& _interface, plugin_ptr& _ptr ) { error result = SUCCESS(); if ( ( result = ASSERT_ERROR( _interface == AUTH_INTERFACE, SYS_INVALID_INPUT_PARAM, "gsi_auth_object does not support a \"%s\" plugin interface.", _interface.c_str() ) ).ok() ) { auth_ptr ath; error ret = auth_mgr.resolve( AUTH_GSI_SCHEME, ath ); if ( !( result = ASSERT_PASS( ret, "Failed to resolve the GSI auth plugin." ) ).ok() ) { // Attempt to load the plugin. std::string empty_context( "" ); ret = auth_mgr.init_from_type( AUTH_GSI_SCHEME, AUTH_GSI_SCHEME, AUTH_GSI_SCHEME, empty_context, ath ); result = ASSERT_PASS( ret, "Failed to load the GSI auth plugin." ); } if ( result.ok() ) { _ptr = boost::dynamic_pointer_cast<plugin_base>( ath ); } } return result; }
irods::error unix_check_params_and_path( irods::resource_plugin_context& _ctx ) { irods::error result = SUCCESS(); irods::error ret; // =-=-=-=-=-=-=- // verify that the resc context is valid ret = _ctx.valid< DEST_TYPE >(); if ( ( result = ASSERT_PASS( ret, "Resource context is invalid." ) ).ok() ) { result = unix_check_path( _ctx ); } return result; } // unix_check_params_and_path
error auth_manager::init_from_type( const std::string& _type, const std::string& _key, const std::string& _inst, const std::string& _ctx, auth_ptr& _rtn_auth ) { error result = SUCCESS(); error ret; auth_ptr auth; ret = load_auth_plugin( auth, _type, _inst, _ctx ); if ( ( result = ASSERT_PASS( ret, "Failed to load auth plugin." ) ).ok() ) { plugins_[_key] = auth; _rtn_auth = plugins_[_key]; } return result; }