コード例 #1
0
ファイル: QoS_UDP.cpp プロジェクト: binary42/OCI
int
TAO_AV_UDP_QoS_Flow_Handler::translate (CosPropertyService::Properties &qos_params,
                                        ACE_Flow_Spec *ace_flow_spec)
{
    for (unsigned int i = 0;
            i < qos_params.length ();
            i++)
    {
        if (ACE_OS::strcmp (qos_params [i].property_name, "Service_Type") == 0)
        {
            CORBA::Short type;
            qos_params [i].property_value >>= type;
            ace_flow_spec->service_type (type);
        }
        else if (ACE_OS::strcmp (qos_params [i].property_name, "Token_Rate") == 0)
コード例 #2
0
void ACSServiceController::fireAlarm(acsdaemon::ServiceState state) {
    if (!alarmSystemInitialized)
    {

        // no reference yet, noop
        if (!getContext()->hasConfigurationReference(desc->getInstanceNumber(), acsServices[MANAGER].xmltag))
        	return;

        try {
           std::string managerReference = getContext()->getConfigurationReference(desc->getInstanceNumber(), acsServices[MANAGER].xmltag);
           ACS_SHORT_LOG((LM_DEBUG, "Initializing Alarm System using manager reference '%s'.", managerReference.c_str()));
           CORBA::Object_var obj = getContext()->getORB()->string_to_object(managerReference.c_str());
           if (CORBA::is_nil(obj.in())) {
               ACS_SHORT_LOG((LM_ERROR, "Failed to parse Corba URI '%s' as manager reference!", managerReference.c_str()));
               return;
           }

           obj = acsQoS::Timeout::setObjectTimeout(CORBA_TIMEOUT, obj.in());

	   ::maci::Manager_var manager = ::maci::Manager::_narrow(obj.in());
           if (manager.ptr() == ::maci::Manager::_nil()) {
               ACS_SHORT_LOG((LM_INFO, "Manager reference '%s' is not valid.", managerReference.c_str()));
               return;
           }

	   obj = manager->get_service(0, ::alarmsystem::AlarmServiceName, false);  
           if (CORBA::is_nil(obj.in())) {
               ACS_SHORT_LOG((LM_ERROR, "Failed to get '%s' service from manager!", ::alarmsystem::AlarmServiceName));
               return;
           }

           alarmService = ::alarmsystem::AlarmService::_narrow(obj.in());
           if (alarmService.ptr() == ::alarmsystem::AlarmService::_nil()) {
               ACS_SHORT_LOG((LM_INFO, "AlarmService reference is not valid."));
               return;
           }

	   alarmSystemInitialized = true; 

           ACS_SHORT_LOG((LM_DEBUG, "Alarm System initialized."));
       } catch (...) {
           ACS_SHORT_LOG((LM_DEBUG, "Failed to initialize Alarm System."));
           return;
       }
    } 

    ::alarmsystem::Triplet triplet;
    triplet.faultFamily = "Services";
    triplet.faultMember = desc->getACSServiceName();
    triplet.faultCode = 0; //(int)state;

    ACS::Time acsTime = ::getTimeStamp();

    bool hasName = (desc->getName() != 0);

    // create a Properties object and configure it
    CosPropertyService::Properties properties;
    properties.length(hasName ? 3 : 2);
    properties[0].property_name = "host";
    properties[0].property_value <<= desc->getHost();

    properties[1].property_name = "instance";
    properties[1].property_value <<= desc->getInstanceNumber();
/*    
    std::stringstream out;
    out << desc->getInstanceNumber();
    props.setProperty("instance", out.str());
*/
    // for named services (e.g. notification services)
    if (hasName)
    {
        properties[2].property_name = "name";
        properties[2].property_value <<= desc->getName();
    }
   
    ACE_TCHAR hostname[200];
    hostname[0] = 0;
    ACE_OS::hostname(hostname, 200);

    try
    {
       alarmService->submitAlarm(triplet, state != acsdaemon::RUNNING,
   	hostname, "ALARM_SOURCE_NAME", acsTime, properties);
    } catch (...) {
       ACS_SHORT_LOG((LM_DEBUG, "Failed to send an alarm."));
       return;
    }
}
コード例 #3
0
void
CDBPropertySet::define_properties (const CosPropertyService::Properties & nproperties)
{
  ACS_TRACE("baci::CDBPropertySet::define_properties");
  
  // Get the length.
  CORBA::ULong sequenceLength = nproperties.length ();
  
  // Define multiple exceptions object.
  CosPropertyService::MultipleExceptions multiEx;
  
  for (CORBA::ULong pi = 0UL; pi < sequenceLength; pi++)
      {
      try
        {
          // Define this property.
          this->define_property (nproperties [pi].property_name.in(),
                                 nproperties [pi].property_value);
        }
      catch (CosPropertyService::InvalidPropertyName ex)
        {
          CORBA::ULong len = multiEx.exceptions.length ();
          multiEx.exceptions.length (len + 1);
          multiEx.exceptions[len].reason =
            CosPropertyService::invalid_property_name;
          multiEx.exceptions[len].failing_property_name =
            nproperties[pi].property_name;
        }
      catch (CosPropertyService::ConflictingProperty ex)
        {
          CORBA::ULong len = multiEx.exceptions.length ();
          multiEx.exceptions.length (len + 1);
          multiEx.exceptions[len].reason =
            CosPropertyService::conflicting_property;
          multiEx.exceptions[len].failing_property_name =
            nproperties[pi].property_name;
        }
      catch (CosPropertyService::ReadOnlyProperty ex)
        {
          CORBA::ULong len = multiEx.exceptions.length ();
          multiEx.exceptions.length (len + 1);
          multiEx.exceptions[len].reason =
            CosPropertyService::read_only_property;
          multiEx.exceptions[len].failing_property_name =
            nproperties[pi].property_name;
        }
      catch (CosPropertyService::UnsupportedTypeCode ex)
        {
          CORBA::ULong len = multiEx.exceptions.length ();
          multiEx.exceptions.length (len + 1);
          multiEx.exceptions[len].reason =
            CosPropertyService::unsupported_type_code;
          multiEx.exceptions[len].failing_property_name =
            nproperties[pi].property_name;
        }
      catch (CosPropertyService::UnsupportedProperty ex)
	  {
	    CORBA::ULong len = multiEx.exceptions.length ();
	    multiEx.exceptions.length (len + 1);
	    multiEx.exceptions[len].reason =
	    CosPropertyService::unsupported_property;
	    multiEx.exceptions[len].failing_property_name =
		nproperties[pi].property_name;
	  }
      catch(...)
	  {
	  throw;
	  }
    }

  // Raise the multi exception if needed.
  if (multiEx.exceptions.length () > 0)
      {
      throw CosPropertyService::MultipleExceptions (multiEx);
      }
}