本文整理汇总了C++中irods::resource_plugin_context::prop_map方法的典型用法代码示例。如果您正苦于以下问题:C++ resource_plugin_context::prop_map方法的具体用法?C++ resource_plugin_context::prop_map怎么用?C++ resource_plugin_context::prop_map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类irods::resource_plugin_context
的用法示例。
在下文中一共展示了resource_plugin_context::prop_map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: impostor_resource_redirect_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
示例2: round_robin_file_modified
/// =-=-=-=-=-=-=-
/// @brief interface to notify of a file modification
irods::error round_robin_file_modified(
irods::resource_plugin_context& _ctx ) {
// =-=-=-=-=-=-=-
// get the child resc to call
irods::resource_ptr resc;
irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
if ( !err.ok() ) {
return PASS( err );
}
// =-=-=-=-=-=-=-
// call modified on the child
err = resc->call( _ctx.comm(), irods::RESOURCE_OP_MODIFIED, _ctx.fco() );
if ( !err.ok() ) {
return PASS( err );
}
// =-=-=-=-=-=-=-
// if file modified is successful then we will update the next
// child in the round robin within the database
std::string name;
_ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
std::string next_child;
_ctx.prop_map().get< std::string >( NEXT_CHILD_PROP, next_child );
setRoundRobinContextInp_t inp;
strncpy( inp.resc_name_, name.c_str(), NAME_LEN );
strncpy( inp.context_, next_child.c_str(), MAX_NAME_LEN );
int status = irods::server_api_call(
SET_RR_CTX_AN,
_ctx.comm(),
&inp,
NULL,
( void** ) NULL,
NULL );
if ( status < 0 ) {
std::stringstream msg;
msg << "failed to update round robin context for [";
msg << name << "] with context [" << next_child << "]";
return ERROR(
status,
msg.str() );
}
else {
return SUCCESS();
}
} // round_robin_file_modified
示例3: round_robin_get_resc_for_call
irods::error round_robin_get_resc_for_call(
irods::resource_plugin_context& _ctx,
irods::resource_ptr& _resc ) {
// =-=-=-=-=-=-=-
// check incoming parameters
irods::error err = round_robin_check_params< DEST_TYPE >( _ctx );
if ( !err.ok() ) {
return PASSMSG( "round_robin_get_resc_for_call - bad resource context", err );
}
// =-=-=-=-=-=-=-
// get the object's name
std::string name;
err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
if ( !err.ok() ) {
return PASSMSG( "round_robin_get_resc_for_call - failed to get property 'name'.", err );
}
// =-=-=-=-=-=-=-
// get the object's hier string
boost::shared_ptr< DEST_TYPE > obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.fco() );
std::string hier = 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 );
if ( !err.ok() ) {
return PASSMSG( "round_robin_get_resc_for_call - get_next_child_in_hier failed.", err );
}
return SUCCESS();
} // round_robin_get_resc_for_call
示例4: univ_mss__file_rebalance
// =-=-=-=-=-=-=-
// univ_mss__file_rebalance - code which would rebalance the subtree
irods::error univ_mss__file_rebalance(
irods::resource_plugin_context& _ctx ) {
return update_resource_object_count(
_ctx.comm(),
_ctx.prop_map() );
} // univ_mss__file_rebalancec
示例5: pass_thru_file_rebalance
// =-=-=-=-=-=-=-
// pass_thru_file_rebalance - code which would rebalance the subtree
irods::error pass_thru_file_rebalance(
irods::resource_plugin_context& _ctx ) {
// =-=-=-=-=-=-=-
// forward request for rebalance to children
irods::error result = SUCCESS();
irods::resource_child_map::iterator itr = _ctx.child_map().begin();
for ( ; itr != _ctx.child_map().end(); ++itr ) {
irods::error ret = itr->second.second->call(
_ctx.comm(),
irods::RESOURCE_OP_REBALANCE,
_ctx.fco() );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
result = ret;
}
}
if( !result.ok() ) {
return PASS( result );
}
return update_resource_object_count(
_ctx.comm(),
_ctx.prop_map() );
} // pass_thru_file_rebalancec
示例6: random_get_resc_for_call
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
示例7: mock_archive_stagetocache_plugin
// =-=-=-=-=-=-=-
// 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
示例8: load_balanced_redirect
/// =-=-=-=-=-=-=-
/// @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
示例9: unix_check_path
// =-=-=-=-=-=-=-
/// @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
示例10: pass_thru_redirect_plugin
// =-=-=-=-=-=-=-
// unixRedirectPlugin - used to allow the resource to determine which host
// should provide the requested operation
irods::error pass_thru_redirect_plugin(
irods::resource_plugin_context& _ctx,
const std::string* _opr,
const std::string* _curr_host,
irods::hierarchy_parser* _out_parser,
float* _out_vote ) {
// =-=-=-=-=-=-=-
// check incoming parameters
irods::error result = SUCCESS();
irods::error ret = pass_thru_check_params( _ctx );
if ( !ret.ok() ) {
result = PASSMSG( "pass_thru_redirect_plugin - invalid resource context.", ret );
}
if ( !_opr ) {
return ERROR( SYS_INVALID_INPUT_PARAM, "pass_thru_redirect_plugin - null operation" );
}
if ( !_curr_host ) {
return ERROR( SYS_INVALID_INPUT_PARAM, "pass_thru_redirect_plugin - null operation" );
}
if ( !_out_parser ) {
return ERROR( SYS_INVALID_INPUT_PARAM, "pass_thru_redirect_plugin - null outgoing hier parser" );
}
if ( !_out_vote ) {
return ERROR( SYS_INVALID_INPUT_PARAM, "pass_thru_redirect_plugin - null outgoing vote" );
}
// =-=-=-=-=-=-=-
// get the name of this resource
std::string resc_name;
ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, resc_name );
if ( !ret.ok() ) {
std::stringstream msg;
msg << "pass_thru_redirect_plugin - failed in get property for name";
return ERROR( -1, msg.str() );
}
// =-=-=-=-=-=-=-
// add ourselves to the hierarchy parser by default
_out_parser->add_child( resc_name );
irods::resource_ptr resc;
ret = pass_thru_get_first_chid_resc( _ctx.child_map(), resc );
if ( !ret.ok() ) {
return PASSMSG( "pass_thru_redirect_plugin - failed getting the first child resource pointer.", ret );
}
return resc->call < const std::string*,
const std::string*,
irods::hierarchy_parser*,
float* > (
_ctx.comm(),
irods::RESOURCE_OP_RESOLVE_RESC_HIER,
_ctx.fco(),
_opr,
_curr_host,
_out_parser,
_out_vote );
} // pass_thru_redirect_plugin
示例11: mock_archive_rebalance
// =-=-=-=-=-=-=-
// mock_archive_rebalance - code which would rebalance the subtree
irods::error mock_archive_rebalance(
irods::resource_plugin_context& _ctx ) {
return update_resource_object_count(
_ctx.comm(),
_ctx.prop_map() );
} // mock_archive_file_rebalancec
示例12: mock_archive_rename_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
示例13: univ_mss_file_stage_to_cache
/// =-=-=-=-=-=-=-
/// @brief 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 univ_mss_file_stage_to_cache(
irods::resource_plugin_context& _ctx,
const char* _cache_file_name ) {
// =-=-=-=-=-=-=-
// check context
irods::error err = univ_mss_check_param< irods::file_object >( _ctx );
if ( !err.ok() ) {
std::stringstream msg;
msg << __FUNCTION__;
msg << " - invalid context";
return PASSMSG( msg.str(), err );
}
// =-=-=-=-=-=-=-
// snag a ref to the fco
irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
std::string filename = fco->physical_path();
// =-=-=-=-=-=-=-
// get the script property
std::string script;
err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
if ( !err.ok() ) {
return PASSMSG( __FUNCTION__, err );
}
int status = 0;
execCmd_t execCmdInp;
char cmdArgv[HUGE_NAME_LEN] = "";
execCmdOut_t *execCmdOut = NULL;
bzero( &execCmdInp, sizeof( execCmdInp ) );
rstrcpy( execCmdInp.cmd, script.c_str(), LONG_NAME_LEN );
strcat( cmdArgv, "stageToCache" );
strcat( cmdArgv, " '" );
strcat( cmdArgv, filename.c_str() );
strcat( cmdArgv, "' '" );
strcat( cmdArgv, _cache_file_name );
strcat( cmdArgv, "'" );
rstrcpy( execCmdInp.cmdArgv, cmdArgv, HUGE_NAME_LEN );
rstrcpy( execCmdInp.execAddr, "localhost", LONG_NAME_LEN );
status = _rsExecCmd( _ctx.comm(), &execCmdInp, &execCmdOut );
if ( status < 0 ) {
status = UNIV_MSS_STAGETOCACHE_ERR - errno;
std::stringstream msg;
msg << "univ_mss_file_stage_to_cache: staging from [";
msg << _cache_file_name;
msg << "] to [";
msg << filename;
msg << "] failed.";
return ERROR( status, msg.str() );
}
return CODE( status );
} // univ_mss_file_stage_to_cache
示例14: univ_mss_file_mkdir
/// =-=-=-=-=-=-=-
/// @brief interface for POSIX mkdir
irods::error univ_mss_file_mkdir(
irods::resource_plugin_context& _ctx ) {
// =-=-=-=-=-=-=-
// check context
irods::error err = univ_mss_check_param< irods::collection_object >( _ctx );
if ( !err.ok() ) {
std::stringstream msg;
msg << __FUNCTION__;
msg << " - invalid context";
return PASSMSG( msg.str(), err );
}
// =-=-=-=-=-=-=-
// get the script property
std::string script;
err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
if ( !err.ok() ) {
return PASSMSG( __FUNCTION__, err );
}
// =-=-=-=-=-=-=-
// snag a ref to the fco
irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
std::string dirname = fco->physical_path();
int status = 0;
execCmd_t execCmdInp;
char cmdArgv[HUGE_NAME_LEN] = "";
execCmdOut_t *execCmdOut = NULL;
bzero( &execCmdInp, sizeof( execCmdInp ) );
rstrcpy( execCmdInp.cmd, script.c_str(), LONG_NAME_LEN );
strcat( cmdArgv, "mkdir" );
strcat( cmdArgv, " '" );
strcat( cmdArgv, dirname.c_str() );
strcat( cmdArgv, "'" );
rstrcpy( execCmdInp.cmdArgv, cmdArgv, HUGE_NAME_LEN );
rstrcpy( execCmdInp.execAddr, "localhost", LONG_NAME_LEN );
status = _rsExecCmd( _ctx.comm(), &execCmdInp, &execCmdOut );
if ( status < 0 ) {
status = UNIV_MSS_MKDIR_ERR - errno;
std::stringstream msg;
msg << "univ_mss_file_mkdir - mkdir failed for [";
msg << dirname;
msg << "]";
return ERROR( status, msg.str() );
}
int mode = getDefDirMode();
fco->mode( mode );
err = univ_mss_file_chmod( _ctx );
return err;
} // univ_mss_file_mkdir
示例15: univ_mss_file_chmod
/// =-=-=-=-=-=-=-
/// @brief interface for POSIX chmod
irods::error univ_mss_file_chmod(
irods::resource_plugin_context& _ctx ) {
// =-=-=-=-=-=-=-
// check context
irods::error err = univ_mss_check_param< irods::data_object >( _ctx );
if ( !err.ok() ) {
std::stringstream msg;
msg << __FUNCTION__;
msg << " - invalid context";
return PASSMSG( msg.str(), err );
}
// =-=-=-=-=-=-=-
// get the script property
std::string script;
err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
if ( !err.ok() ) {
return PASSMSG( __FUNCTION__, err );
}
// =-=-=-=-=-=-=-
// snag a ref to the fco
irods::data_object_ptr fco = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
std::string filename = fco->physical_path();
int mode = fco->mode();
int status = 0;
execCmd_t execCmdInp;
if ( mode != getDefDirMode() ) {
mode = getDefFileMode();
}
bzero( &execCmdInp, sizeof( execCmdInp ) );
snprintf( execCmdInp.cmd, sizeof( execCmdInp.cmd ), "%s", script.c_str() );
snprintf( execCmdInp.cmdArgv, sizeof( execCmdInp.cmdArgv ), "chmod '%s' %o", filename.c_str(), mode );
snprintf( execCmdInp.execAddr, sizeof( execCmdInp.execAddr ), "%s", "localhost" );
execCmdOut_t *execCmdOut = NULL;
status = _rsExecCmd( &execCmdInp, &execCmdOut );
freeCmdExecOut( execCmdOut );
if ( status < 0 ) {
status = UNIV_MSS_CHMOD_ERR - errno;
std::stringstream msg;
msg << "univ_mss_file_chmod - failed for [";
msg << filename;
msg << "]";
return ERROR( status, msg.str() );
}
return CODE( status );
} // univ_mss_file_chmod