本文整理汇总了C++中irods::resource_plugin_context::comm方法的典型用法代码示例。如果您正苦于以下问题:C++ resource_plugin_context::comm方法的具体用法?C++ resource_plugin_context::comm怎么用?C++ resource_plugin_context::comm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类irods::resource_plugin_context
的用法示例。
在下文中一共展示了resource_plugin_context::comm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
示例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: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: round_robin_file_truncate
/// =-=-=-=-=-=-=-
/// @brief interface for POSIX truncate
irods::error round_robin_file_truncate(
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 truncate on the child
return resc->call( _ctx.comm(), irods::RESOURCE_OP_TRUNCATE, _ctx.fco() );
} // round_robin_file_truncate
示例9: load_balanced_file_unregistered
/// =-=-=-=-=-=-=-
/// @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
示例10: load_balanced_file_stage_to_cache
/// =-=-=-=-=-=-=-
/// @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
示例11: load_balanced_file_close
/// =-=-=-=-=-=-=-
/// @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
示例12: round_robin_file_unregistered
/// =-=-=-=-=-=-=-
/// @brief interface to notify of a file unregistration
irods::error round_robin_file_unregistered(
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() ) {
std::stringstream msg;
msg << __FUNCTION__;
msg << " - failed.";
return PASSMSG( msg.str(), err );
}
// =-=-=-=-=-=-=-
// call unregistered on the child
return resc->call( _ctx.comm(), irods::RESOURCE_OP_UNREGISTERED, _ctx.fco() );
} // round_robin_file_unregistered
示例13: round_robin_file_closedir
// =-=-=-=-=-=-=-
/// @brief interface for POSIX closedir
irods::error round_robin_file_closedir(
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::collection_object >( _ctx, resc );
if ( !err.ok() ) {
std::stringstream msg;
msg << __FUNCTION__;
msg << " - failed.";
return PASSMSG( msg.str(), err );
}
// =-=-=-=-=-=-=-
// call closedir on the child
return resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSEDIR, _ctx.fco() );
} // round_robin_file_closedir
示例14: random_file_create
/// =-=-=-=-=-=-=-
/// @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
示例15: random_file_open
// =-=-=-=-=-=-=-
// 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