示例#1
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_forwarding_state (DsLogAdmin::ForwardingState state)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  DsLogAdmin::ForwardingState old_state =
    this->recordstore_->get_forwarding_state ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (state == old_state)
    return;

  this->recordstore_->set_forwarding_state (state);

  if (notifier_)
    {
      notifier_->forwarding_state_change (this->log_.in (),
                                          this->logid_,
                                          state);
    }
}
示例#2
0
文件: Log_i.cpp 项目: asdlei00/ACE
CORBA::ULong
TAO_Log_i::delete_records (const char *grammar,
                           const char *constraint)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  const CORBA::ULong count =
    this->recordstore_->delete_records (grammar,
                                        constraint);

  if (count > 0)
    {
      if (avail_status_.log_full)
        {
          const CORBA::ULongLong current_size =
            this->recordstore_->get_current_size ();

          const CORBA::ULongLong max_size =
            this->recordstore_->get_max_size ();

          if (current_size < max_size)
            {
              avail_status_.log_full = 0;
            }
        }

      this->reset_capacity_alarm_threshold ();
    }

  return count;
}
示例#3
0
文件: Log_i.cpp 项目: asdlei00/ACE
CORBA::ULong
TAO_Log_i::delete_records_by_id (const DsLogAdmin::RecordIdList &ids)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  const CORBA::ULong count =
    this->recordstore_->delete_records_by_id (ids);

  if (count > 0)
    {
      if (avail_status_.log_full)
        {
          const CORBA::ULongLong current_size =
            this->recordstore_->get_current_size ();

          const CORBA::ULongLong max_size =
            this->recordstore_->get_max_size ();

          if (current_size < max_size)
            {
              avail_status_.log_full = 0;
            }
        }

      this->reset_capacity_alarm_threshold ();
    }

  return count;
}
示例#4
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::remove_old_records (void)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  const CORBA::ULong count =
    this->recordstore_->remove_old_records ();

  if (count > 0)
    {
      if (avail_status_.log_full)
        {
          const CORBA::ULongLong current_size =
            this->recordstore_->get_current_size ();

          const CORBA::ULongLong max_size =
            this->recordstore_->get_max_size ();

          if (current_size < max_size)
            {
              avail_status_.log_full = 0;
            }
        }

      this->reset_capacity_alarm_threshold ();
    }
}
示例#5
0
void
TAO_Hash_Naming_Context::bind_context (const CosNaming::Name &n,
                                       CosNaming::NamingContext_ptr nc)
{
  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Do not allow binding of nil context reference.
  if (CORBA::is_nil (nc))
    throw CORBA::BAD_PARAM ();

  // Get the length of the name.
  CORBA::ULong const name_len = n.length ();

  // Check for invalid name.
  if (name_len == 0)
    throw CosNaming::NamingContext::InvalidName();

  // If we received compound name, resolve it to get the context in
  // which the binding should take place, then perform the binding on
  // target context.
  if (name_len > 1)
    {
      CosNaming::NamingContext_var context = this->get_context (n);

      CosNaming::Name simple_name;
      simple_name.length (1);
      simple_name[0] = n[name_len - 1];
      try
        {
          context->bind_context (simple_name, nc);
        }
      catch (const CORBA::SystemException&)
        {
          throw CosNaming::NamingContext::CannotProceed(
            context.in (), simple_name);
        }
    }
  // If we received a simple name, we need to bind it in this context.
  else
    {
      ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
                                this->lock_,
                                CORBA::INTERNAL ());

      // Try binding the name.
      int result = this->context_->bind (n[0].id,
                                        n[0].kind,
                                        nc,
                                        CosNaming::ncontext);
      if (result == 1)
        throw CosNaming::NamingContext::AlreadyBound();

      // Something went wrong with the internal structure
      else if (result == -1)
        throw CORBA::INTERNAL ();
    }
}
void
TAO_Service_Type_Repository::
mask_type (const char *name)
{
  if (TAO_Trader_Base::is_valid_identifier_name (name) == 0)
    throw CosTrading::IllegalServiceType (name);

  ACE_WRITE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ());

  // Make sure the type exists.
  CORBA::String_var type_name (name);
  Service_Type_Map::ENTRY *type_entry = 0;
  if (this->type_map_.find (type_name,
                            type_entry) != -1)
    throw CosTrading::UnknownServiceType (name);

  // Make sure the type is unmasked.
  CORBA::Boolean &mask =
    type_entry->int_id_->type_struct_.masked;

  if (mask == 1)
    throw CosTradingRepos::ServiceTypeRepository::AlreadyMasked (name);
  else
    mask = 1;
}
示例#7
0
void
TAO_Hash_LogStore::create_with_id (DsLogAdmin::LogId id,
                                               DsLogAdmin::LogFullActionType full_action,
                                               CORBA::ULongLong max_size,
                                               const DsLogAdmin::CapacityAlarmThresholdList* thresholds)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            lock_,
                            CORBA::INTERNAL ());

  if (this->hash_map_.find (id) == 0)
    {
      throw DsLogAdmin::LogIdAlreadyExists ();
    }

  TAO_Hash_LogRecordStore* impl = 0;
  ACE_NEW_THROW_EX (impl,
                    TAO_Hash_LogRecordStore (this->logmgr_i_,
                                             id,
                                             full_action,
                                             max_size,
                                             thresholds
                                             ),
                    CORBA::NO_MEMORY ());

  auto_ptr<TAO_Hash_LogRecordStore> recordstore (impl);

  if (this->hash_map_.bind (id, recordstore.get ()) != 0)
    {
      throw CORBA::INTERNAL ();
    }

  recordstore.release ();
}
示例#8
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_max_size (CORBA::ULongLong size)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  CORBA::ULongLong old_size =
    this->recordstore_->get_max_size ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (size == old_size)
    return;

  // size == 0 => infinite size.
  if (size != 0)
    {
      CORBA::ULongLong current_size =
        this->recordstore_->get_current_size ();

      if (size < current_size)
        throw DsLogAdmin::InvalidParam ();
    }

  this->recordstore_->set_max_size (size);

  if (notifier_)
    {
      notifier_->max_log_size_value_change (this->log_.in (),
                                            this->logid_,
                                            old_size,
                                            size);
    }

  // @@ The current revision of the specification (formal/03-07-01)
  // doesn't specify the interaction between set_max_size() and the
  // capacity alarm thresholds list.  Publicly available documentation
  // I've read for other log service implementations doesn't offer any
  // guidance either.  I have submitted a defect report to the OMG for
  // clarification.
  //
  // In the mean time, we will call reset_capacity_alarm_threshold()
  // to reset the "current_threshold_" index.  This will result in
  // ThresholdAlarm being sent when the next threshold is crossed.  An
  // argument could be made that an event should be be sent for each
  // threshold that has already been crossed.  Hopefully, this will be
  // clarified when/if the OMG charters a RTF for the log service.
  //    --jtc
  //
  this->reset_capacity_alarm_threshold ();
}
示例#9
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_capacity_alarm_thresholds (const
                                          DsLogAdmin::CapacityAlarmThresholdList
                                          &threshs)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  const CORBA::Boolean validated =
    TAO_Log_i::validate_capacity_alarm_thresholds (threshs);

  if (!validated)
    throw DsLogAdmin::InvalidThreshold ();

  DsLogAdmin::CapacityAlarmThresholdList_var old_threshs =
    this->recordstore_->get_capacity_alarm_thresholds ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (threshs == old_threshs.in ())
      return;

  this->recordstore_->set_capacity_alarm_thresholds (threshs);

  if (notifier_)
    {
      notifier_->capacity_alarm_threshold_value_change (this->log_.in (),
                                                        this->logid_,
                                                        old_threshs.in (),
                                                        threshs);
    }

  // @@ The current revision of the specification (formal/03-07-01)
  // doesn't completly describe the behavior of changing the capacity
  // alarm threshold list.  Publicly available documentation I've read
  // for other log service implementations doesn't offer much guidance
  // either.  I have submitted a defect report to the OMG for
  // clarification.
  //
  // In the mean time, we will call reset_capacity_alarm_threshold()
  // to reset the "current_threshold_" index.  This will result in
  // ThresholdAlarm being sent when the next threshold is crossed.  An
  // argument could be made that an event should be be sent for each
  // threshold that has already been crossed.  Hopefully, this will be
  // clarified when/if the OMG charters a RTF for the log service.
  //    --jtc
  //
  this->thresholds_ = threshs;
  this->reset_capacity_alarm_threshold ();
}
示例#10
0
void
TAO_Hash_Naming_Context::rebind_context (const CosNaming::Name &n,
                                         CosNaming::NamingContext_ptr nc)
{
  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Get the length of the name.
  CORBA::ULong const name_len = n.length ();

  // Check for invalid name.
  if (name_len == 0)
    throw CosNaming::NamingContext::InvalidName();

  // If we received compound name, resolve it to get the context in
  // which the rebinding should take place, then perform the rebinding
  // on target context.
  if (name_len > 1)
    {
      CosNaming::NamingContext_var context = this->get_context (n);

      CosNaming::Name simple_name;
      simple_name.length (1);
      simple_name[0] = n[name_len - 1];
      try
        {
          context->rebind_context (simple_name, nc);
        }
      catch (const CORBA::SystemException&)
        {
          throw CosNaming::NamingContext::CannotProceed(
            context.in (), simple_name);
        }
    }
  else
    // If we received a simple name, we need to rebind it in this
    // context.
    {
      ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
                                this->lock_,
                                CORBA::INTERNAL ());

      int result = this->context_->rebind (n[0].id,
                                           n[0].kind,
                                           nc,
                                           CosNaming::ncontext);
      // Check for error conditions.
      if (result == -1)
        throw CORBA::INTERNAL ();

      else if (result == -2)
        throw CosNaming::NamingContext::NotFound(
          CosNaming::NamingContext::not_context,
          n);
    }
}
示例#11
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_record_attribute (DsLogAdmin::RecordId id,
                                 const DsLogAdmin::NVList &attr_list)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  this->recordstore_->set_record_attribute (id, attr_list);
}
示例#12
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_interval (const DsLogAdmin::TimeInterval &interval)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  // validate interval
  if (interval.start != 0)
    {
      if (interval.start >= interval.stop)
        throw DsLogAdmin::InvalidTimeInterval ();
    }

  DsLogAdmin::TimeInterval old_interval =
    this->recordstore_->get_interval ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (interval == old_interval)
    return;

  this->recordstore_->set_interval (interval);

  if (notifier_)
    {
      if (interval.start != old_interval.start)
        {
          notifier_->start_time_value_change (this->log_.in (),
                                              this->logid_,
                                              old_interval.start,
                                              interval.start);
        }

      if (interval.stop != old_interval.stop)
        {
          notifier_->stop_time_value_change (this->log_.in (),
                                             this->logid_,
                                             old_interval.stop,
                                             interval.stop);
        }
    }
}
示例#13
0
文件: Log_i.cpp 项目: asdlei00/ACE
CORBA::ULong
TAO_Log_i::set_records_attribute (const char *grammar,
                                  const char *constraint,
                                  const DsLogAdmin::NVList
                                  &attr_list)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  return this->recordstore_->set_records_attribute (grammar,
                                                    constraint,
                                                    attr_list);
}
示例#14
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_log_qos (const DsLogAdmin::QoSList &qos)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  // @@ The current revision of the specification (formal/03-07-01)
  // does not clearly define the semantics to follow when the QoSList
  // contains mutually exclusive, unsupported, or unknown properties.
  // I have submitted a defect report to the OMG for clarification.
  //
  // In the mean time, the last known/supported property found in the
  // QoSList takes presidence.  If any unknown/unsupported properties
  // were found, an UnsupportedQoS exception is thrown.
  //    --jtc

  validate_log_qos (qos);

  DsLogAdmin::QoSList_var old_qos =
    this->recordstore_->get_log_qos ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (qos == old_qos.in ())
    return;

  this->recordstore_->set_log_qos (qos);

  reset_log_qos (qos);

  if (notifier_)
    {
      notifier_->quality_of_service_value_change (this->log_.in (),
                                                  this->logid_,
                                                  old_qos.in (),
                                                  qos);
    }
}
示例#15
0
int
TAO_Hash_LogStore::remove (DsLogAdmin::LogId id)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            lock_,
                            CORBA::INTERNAL ());

  TAO_Hash_LogRecordStore* recordstore = 0;

  int retval = this->hash_map_.unbind (id, recordstore);
  if (retval == 0)
    {
      delete recordstore;
    }

  return retval;
}
示例#16
0
void
TAO_Service_Type_Repository::remove_type (const char *name)
{
  if (TAO_Trader_Base::is_valid_identifier_name (name) == 0)
    throw CosTrading::IllegalServiceType (name);

  ACE_WRITE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ());

  // Check if the type exists.
  Service_Type_Map::ENTRY* type_entry = 0; ;
  if (this->type_map_.find (name,
                            type_entry) == -1)
    throw CosTrading::UnknownServiceType (name);

  // Check if it has any subtypes.
  Type_Info *type_info = type_entry->int_id_;
  if (type_info->has_subtypes_)
    throw CosTradingRepos::ServiceTypeRepository::HasSubTypes (name, "");

  // Remove the type from the map.
  this->type_map_.unbind (type_entry);
  delete type_info;
}
示例#17
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::set_max_record_life (CORBA::ULong life)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  CORBA::ULong old_life =
    this->recordstore_->get_max_record_life ();

  // @@ The current revision of the specification (formal/03-07-01) is
  // unclear whether an AttributeValueChange event should be sent if a
  // log attribute was changed (to a new value), or whether the events
  // should be sent unconditionally.  I have submitted a defect report
  // to the OMG for clarification.
  //
  // In the mean time, we're interepreting it to mean that events are
  // only sent when the value has changed.
  if (life == old_life)
    return;

  this->recordstore_->set_max_record_life (life);

  if (life != 0)
    this->log_compaction_handler_.schedule();
  else
    this->log_compaction_handler_.cancel();

  if (notifier_)
    {
      notifier_->max_record_life_value_change (this->log_.in (),
                                               this->logid_,
                                               old_life,
                                               life);
  }
}
示例#18
0
CosTradingRepos::ServiceTypeRepository::IncarnationNumber
TAO_Service_Type_Repository::
add_type (const char *name,
          const char *if_name,
          const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props,
          const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types)
{
  Prop_Map prop_map;
  Service_Type_Map super_map;

  ACE_WRITE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ());

  // Make sure Type name is valid.
  if (TAO_Trader_Base::is_valid_identifier_name (name) == 0)
    throw CosTrading::IllegalServiceType (name);

  // Check if the service type already exists.
  CORBA::String_var type_name (name);
  if (this->type_map_.find (type_name) == 0)
    throw CosTradingRepos::ServiceTypeRepository::ServiceTypeExists ();

  // Make sure all property names are valid and appear only once.
  this->validate_properties (prop_map,
                             props);

  // Check that all super_types exist, and none are duplicated.
  this->validate_supertypes (super_map,
                             super_types);

  // NOTE: I don't really know a way to do this without an Interface
  // Repository, since the Interface Repository IDs don't contain
  // information about supertypes.
  //
  // make sure interface name is legal.
  //  this->validate_interface (if_name, super_types);
  //
  // Instead, we do this:
  //
  if (if_name == 0)
    throw CosTradingRepos::ServiceTypeRepository::InterfaceTypeMismatch ();

  // Collect and make sure that properties of all supertypes and this
  // type are compatible.  We can use prop_map and super_types_map for
  // the job.
  this->validate_inheritance (prop_map,
                              super_types);

  // We can now use prop_map to construct a sequence of all properties
  // the this type.
  this->update_type_map (name,
                         if_name,
                         props,
                         super_types,
                         prop_map,
                         super_map);

  CosTradingRepos::ServiceTypeRepository::IncarnationNumber return_value =
    this->incarnation_;

  // Increment incarnation number.
  this->incarnation_.low++;

  // If we wrapped around in lows...
  if (this->incarnation_.low == 0)
    this->incarnation_.high++;

  return return_value;
}
示例#19
0
文件: Log_i.cpp 项目: asdlei00/ACE
void
TAO_Log_i::write_recordlist (const DsLogAdmin::RecordList &reclist)
{
  ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
                            guard,
                            this->recordstore_->lock (),
                            CORBA::INTERNAL ());

  DsLogAdmin::LogFullActionType log_full_action =
    this->recordstore_->get_log_full_action ();

  DsLogAdmin::AdministrativeState admin_state =
    this->recordstore_->get_administrative_state ();

  // @@ The current revision of the specification (formal/03-07-01)
  // does not explicitly specify the preference of exceptions to be
  // thrown when multiple error conditions are present.
  //
  // However, the because log is considered off duty if the log's
  // operational state is disabled or its administrative state is
  // locked, we handle the LogOffDuty exception last so the more
  // specific LogLocked and LogDisabled exceptions will be thrown.

  DsLogAdmin::AvailabilityStatus avail_stat =
    this->get_availability_status_i ();

  if (admin_state == DsLogAdmin::locked)
    {
      throw DsLogAdmin::LogLocked ();
    }
  else if (this->op_state_ == DsLogAdmin::disabled)
    {
      throw DsLogAdmin::LogDisabled ();
    }
  else if (avail_stat.off_duty == 1)
    {
      throw DsLogAdmin::LogOffDuty ();
    }

  CORBA::Short num_written (0);

  for (CORBA::ULong i = 0; i < reclist.length (); i++)
    {
      // retval == 1 => log store reached max size.

      int retval = this->recordstore_->log (reclist[i]);

      if (retval == 1)
        {
          // The Log is full . check what the policy is and take
          // appropriate action.
          if (log_full_action == DsLogAdmin::halt)
            {
              avail_status_.log_full = 1;
              throw DsLogAdmin::LogFull (num_written);
            }

          // the policy is to wrap. for this we need to delete a few
          // records. let the record store decide how many.

          if (this->recordstore_->purge_old_records () == -1)
            throw CORBA::PERSIST_STORE ();

          // Now, we want to attempt to write the same record again
          // so decrement the index to balance the inc. in the for loop.
          --i;
        }
      else if (retval == 0)
        {
          num_written++;

          this->check_capacity_alarm_threshold ();
        }
      else
        {
          throw CORBA::PERSIST_STORE ();
        }
    } // for
}