📄 ft_replicationmanager.cpp
字号:
result = group->reference ();
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::add_member to unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ());
}
METHOD_RETURN (TAO::FT_ReplicationManager::add_member) result._retn ();
}
//CORBA
PortableGroup::ObjectGroup_ptr
TAO::FT_ReplicationManager::remove_member (
PortableGroup::ObjectGroup_ptr object_group,
const PortableGroup::Location & the_location
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectGroupNotFound,
PortableGroup::MemberNotFound))
{
PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil ();
// Find the object group corresponding to this IOGR
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (object_group, group))
{
group->remove_member (the_location ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (result._retn ());
group->minimum_populate (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (result._retn ());
//@@ how about the case where the member was removed successfully,
// but for one reason or another we were unable to bring the group
// back up to minimum_number_of_replicas?
result = group->reference ();
}
else
{
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ());
}
return result._retn ();
}
//CORBA
PortableGroup::Locations *
TAO::FT_ReplicationManager::locations_of_members (
PortableGroup::ObjectGroup_ptr object_group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectGroupNotFound))
{
PortableGroup::Locations * result = 0;
// Find the object group corresponding to this IOGR
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (object_group, group))
{
result = group->locations_of_members (
ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::locations_of_members: unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), 0);
}
return result;
}
//CORBA
PortableGroup::ObjectGroups *
TAO::FT_ReplicationManager::groups_at_location (
const PortableGroup::Location & the_location
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException))
{
return this->group_factory_.groups_at_location (the_location ACE_ENV_ARG_PARAMETER);
}
//CORBA
PortableGroup::ObjectGroupId
TAO::FT_ReplicationManager::get_object_group_id (
PortableGroup::ObjectGroup_ptr object_group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectGroupNotFound))
{
PortableGroup::ObjectGroupId result = 0;
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (object_group, group))
{
group->get_object_group_id ();
ACE_CHECK_RETURN (result);
result = group->get_object_group_id ();
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::get_object_group_id: unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result);
}
return result;
}
//CORBA
PortableGroup::ObjectGroup_ptr
TAO::FT_ReplicationManager::get_object_group_ref (
PortableGroup::ObjectGroup_ptr object_group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectGroupNotFound))
{
PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil ();
// Find the object group corresponding to this IOGR
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (object_group, group))
{
result = group->reference ();
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::get_object_group_ref: unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ());
}
return result._retn();
}
//CORBA, TAO specific
PortableGroup::ObjectGroup_ptr
TAO::FT_ReplicationManager::get_object_group_ref_from_id (
PortableGroup::ObjectGroupId group_id
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (
CORBA::SystemException
, PortableGroup::ObjectGroupNotFound
))
{
PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil ();
// Find the object group corresponding to this IOGR
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (group_id, group))
{
result = group->reference ();
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::get_object_group_ref_from_id: unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ());
}
return result._retn();
}
//CORBA
CORBA::Object_ptr
TAO::FT_ReplicationManager::get_member_ref (
PortableGroup::ObjectGroup_ptr object_group,
const PortableGroup::Location & the_location
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectGroupNotFound,
PortableGroup::MemberNotFound))
{
CORBA::Object_var result = CORBA::Object::_nil();
// Find the object group corresponding to this IOGR
TAO::PG_Object_Group * group = 0;
if (this->group_factory_.find_group (object_group, group))
{
result = group->get_member_reference (the_location ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil());
}
else
{
if (TAO_debug_level > 0)
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::get_member_ref: unknown group\n")
));
}
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ());
}
return result._retn();
}
//////////////////////////////////////////////////////
// PortableGroup::GenericFactory methods
//CORBA
CORBA::Object_ptr
TAO::FT_ReplicationManager::create_object (
const char * type_id,
const PortableGroup::Criteria & the_criteria,
PortableGroup::GenericFactory::FactoryCreationId_out factory_creation_id
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::NoFactory,
PortableGroup::ObjectNotCreated,
PortableGroup::InvalidCriteria,
PortableGroup::InvalidProperty,
PortableGroup::CannotMeetCriteria))
{
METHOD_ENTRY (TAO::FT_ReplicationManager::create_object)
////////////////////////////////
// find the properties for this
// type of object group
TAO::PG_Property_Set * typeid_properties
= this->properties_support_.find_typeid_properties (
type_id
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
TAO::PG_Object_Group * group
= this->group_factory_.create_group (
type_id,
the_criteria,
typeid_properties
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
group->initial_populate (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
//@@ on error we should remove the group from the Group_Factory
// doing this "right" will require a var-type pointer to the object group
// that knows about the factory, too.
// Allocate a new FactoryCreationId for use as an "out" parameter.
PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0;
ACE_NEW_THROW_EX (factory_id,
PortableGroup::GenericFactory::FactoryCreationId,
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
TAO_DEFAULT_MINOR_CODE,
ENOMEM),
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (CORBA::Object::_nil ());
PortableGroup::ObjectGroupId group_id = group->get_object_group_id ();
factory_id <<= group_id;
factory_creation_id = factory_id._retn();
METHOD_RETURN (TAO::FT_ReplicationManager::create_object) group->reference ();
}
//CORBA
void
TAO::FT_ReplicationManager::delete_object (
const PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectNotFound))
{
PortableGroup::ObjectGroupId group_id = 0;
if (factory_creation_id >>= group_id)
{
this->group_factory_.delete_group (
group_id
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
else
{
ACE_THROW (PortableGroup::ObjectNotFound ());
}
}
//private
int TAO::FT_ReplicationManager::write_ior ()
{
int result = -1;
FILE* out = ACE_OS::fopen (this->ior_output_file_, "w");
if (out)
{
CORBA::String_var ior_str = this->orb_->object_to_string (
this->replication_manager_ref_.in ());
ACE_OS::fprintf (out, "%s", ior_str.in ());
ACE_OS::fclose (out);
result = 0;
}
else
{
ACE_ERROR ( (LM_ERROR,
ACE_TEXT ("%T %n (%P|%t) - Open failed for %s\n"), this->ior_output_file_
));
}
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -