Пример #1
0
string gen_uuid()
{
    ACE_Utils::UUID uuid;
    ACE_Utils::UUID_GENERATOR::instance()->generate_UUID(uuid);

    return uuid.to_string()->c_str();
}
Пример #2
0
uint64 gen_uuid_hash()
{
    ACE_Utils::UUID uuid;
    ACE_Utils::UUID_GENERATOR::instance()->generate_UUID(uuid);

    return uuid.hash();
}
//
// handle_data
//
void Console_Printer_DataSubscriber_i::
handle_data (const OASIS::SubscriberDataPacket & packet)
{
  ACE_Utils::UUID einode;
  packet.einode >>= einode;

  std::cout
    << "received " << packet.data.length ()
    << " bytes of data from " << *einode.to_string () << std::endl;
}
//
// insert
//
void Metametrics_Table::
insert (const ACE_Utils::UUID & uuid,
        const char * name,
        int version_major,
        int version_minor,
        const char * schema)
{
  // First, let's make sure the typename is already in the database.
  this->insert_typename (name);

  // Now, let's insert the metametrics into the database.
  static const char * __sqlstr__ =
    "INSERT INTO oasis_metametrics "
    "(uuid, name, version_major, version_minor, schema) "
    "VALUES (?, (SELECT typeid FROM oasis_typenames WHERE typename = ?), ?, ?, ?)";

  ADBC::SQLite::Query q (this->db_.get_connection ());
  q.prepare (__sqlstr__);

  using ::ADBC::SQLite::Parameter_List;
  Parameter_List & params = q.parameters ();

  params[0].bind (uuid.to_string ()->c_str (), -1);
  params[1].bind (name, -1);
  params[2].bind (&version_major);
  params[3].bind (&version_minor);
  params[4].bind (schema, -1);

  // Execute the query.
  q.execute_no_record ();
}
Пример #5
0
RPS_Monitor::RPS_Monitor (ServerRequestInterceptor * interceptor)
  : location_ (1),
    interceptor_ (interceptor),
    last_time_ (ACE_OS::gettimeofday ()),
    lock_ ()
{
  this->location_.length (1);

  ACE_Utils::UUID_GENERATOR::instance ()->init ();

  ACE_Utils::UUID uuid;
  ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);

  this->location_[0].id = CORBA::string_dup (uuid.to_string ()->c_str ());
  this->location_[0].kind = CORBA::string_dup ("UUID");
}
Пример #6
0
void Gate::
init (ConsumerAdmin_ptr consumer_admin,
      SupplierAdmin_ptr supplier_admin)
{
  // Generate unique id. It is used to prevent event looping.
  //
  ACE_Utils::UUID uuid;
  ACE_Utils::UUID_GENERATOR::instance ()->init ();
  ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);

  id_ = string_alloc (ACE_Utils::truncate_cast<CORBA::ULong> (
                        uuid.to_string ()->length () + 2));
  ACE_OS::strcpy (id_.inout (), "_");
  ACE_OS::strcpy (id_.inout () + 1, uuid.to_string ()->rep ());

  // ACE_DEBUG ((LM_DEBUG, "ID: %s\n", id_.in ()));


  // Obtain proxy consumer.
  //
  ProxyConsumer_var pc (
    supplier_admin->obtain_notification_push_consumer (
      STRUCTURED_EVENT, consumer_id_));

  consumer_ = StructuredProxyPushConsumer::_narrow (pc.in ());

  consumer_->connect_structured_push_supplier (
    StructuredPushSupplier::_nil ());


  // Register as consumer.
  //
  StructuredPushConsumer_var ref (_this ()); // Activate on default POA.

  ProxySupplier_var ps (
    consumer_admin->obtain_notification_push_supplier (
      STRUCTURED_EVENT, supplier_id_));

  supplier_ = StructuredProxyPushSupplier::_narrow (ps.in ());

  supplier_->connect_structured_push_consumer (ref.in ());


  // Create tracker thread.
  //
  thread_mgr_.spawn (tracker_thunk, this);
}
Пример #7
0
ACE_TCHAR *
ACE::HTBP::ID_Requestor::get_HTID ()
{
  if (ACE::HTBP::ID_Requestor::htid_.length() != 0)
    return ACE::HTBP::ID_Requestor::htid_.rep();

  ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, ACE::HTBP::ID_Requestor::htid_lock_, 0);

  if (ACE::HTBP::ID_Requestor::htid_.length() != 0)
    return ACE::HTBP::ID_Requestor::htid_.rep();

  ACE_SOCK_Stream cli_stream;
  ACE_TCHAR * htid = 0;

  if (this->url_.length() == 0 ||
      this->connect_to_server (&cli_stream) == -1 ||
      this->send_request (&cli_stream) == -1)
    {
      ACE_Utils::UUID_Generator gen;
      ACE_Utils::UUID *uuid = gen.generate_UUID ();
      const ACE_CString *uuidstr = uuid->to_string();
      ACE::HTBP::ID_Requestor::htid_ = ACE_TEXT_CHAR_TO_TCHAR (uuidstr->c_str());
      delete uuid;
      return ACE::HTBP::ID_Requestor::htid_.rep();
    }
  iovec recv_buf;
  ssize_t result = cli_stream.recvv (&recv_buf);
  cli_stream.close();

  if (result > 0)
    {
      ACE_CString answer ((char *)recv_buf.iov_base,recv_buf.iov_len);
      ACE_CString::size_type start = answer.rfind (ACE_TEXT('\n'));
      if (start == ACE_CString::npos)
        start = 0;
      else
        start++;
      ACE::HTBP::ID_Requestor::htid_ = ACE_TEXT_CHAR_TO_TCHAR(answer.substr (start).c_str());
      htid = ACE::HTBP::ID_Requestor::htid_.rep();
    }
  return htid;
}
Пример #8
0
void ErrorTraceHelper::log(ACE_Log_Priority priorty)
{
  unsigned int i=0;
  ACSErr::ErrorTrace *c = m_errorTracePtr;
  char uuidBuf[40];
  ACE_Utils::UUID* uuid = ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID ();

  snprintf(uuidBuf, 40, "%s", uuid->to_string()->c_str());
  delete uuid;

  if (!m_depth) return;

  while (c->previousError.length()!=0){
    i++;
    log (c, m_depth-i, uuidBuf, priorty);
    c = &c->previousError[0];
  }
  i++;
  log (c, m_depth-i, uuidBuf, priorty);
}//log
Пример #9
0
  void Locality_Splitter::finalize_sub_plan (
      Deployment::DeploymentPlan &sub_plan,
      KEY &sub_plan_key)
  {
    DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan");

    // check for availability of LocalityManager instance
    if (!sub_plan_key.has_locality_manager ())
      {
        // add minimal default LocalityManager instance to sub plan
        uint32_t impl_index = sub_plan.implementation ().size ();
        sub_plan.implementation ().push_back (::Deployment::MonolithicDeploymentDescription ());
        uint32_t inst_index = sub_plan.instance ().size ();
        sub_plan.instance ().push_back (::Deployment::InstanceDeploymentDescription ());
        sub_plan.instance ().back ().implementationRef (impl_index);

        // set correct implementation type
        Deployment::Property exec_property;
        exec_property.name (IMPL_TYPE);
        exec_property.value () <<= DANCE_LOCALITYMANAGER;
        sub_plan.implementation ().back ().execParameter ().push_back (exec_property);

        // create unique name for Locality Manager
        ACE_Utils::UUID uuid;
        ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);
        std::string lm_name ("Locality Manager [");
        lm_name += uuid.to_string ()->c_str ();
        lm_name += "]";
        sub_plan.instance ().back ().name (lm_name);

        DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan - " <<
                            "No locality manager found, created a default locality named<" <<
                            sub_plan.instance ().back ().name () << ">");

        // add instance to sub plan key
        sub_plan_key.add_instance (inst_index);
        // mark as locality manager
        sub_plan_key.locality_manager_instance (
          sub_plan_key.instances ().size () - 1);
      }
  }
Пример #10
0
ReplicaController::
ReplicaController (CORBA::ORB_ptr orb)
    : orb_ (CORBA::ORB::_duplicate (orb))
{
  try
  {
    CORBA::Object_var poa_object =
      orb_->resolve_initial_references ("RootPOA");

    root_poa_ = PortableServer::POA::_narrow (
      poa_object.in ());
  }
  catch (const CORBA::Exception& ex)
  {
    ex._tao_print_exception ("Caught exception:");
    ACE_OS::abort ();
  }

  // Generate member id
  ACE_Utils::UUID uuid;
  ACE_Utils::UUID_GENERATOR::instance ()->init ();
  ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);

  ACE_INET_Addr address (10000, "239.255.0.1");

  ACE_DEBUG ((LM_DEBUG, "Becoming a member with id %s\n",
              uuid.to_string ()->c_str ()));

  ACE_auto_ptr_reset (group_, new ACE_TMCast::Group (address, uuid.to_string ()->c_str ()));

  int r = ACE_Thread_Manager::instance ()->spawn (
    &ReplicaController::listener_thunk, this);

  if (r < 0)
  {
    orb_->shutdown (0);
  }
}
Пример #11
0
::Stock::Cookie *
StockDistributor_i::subscribe_notifier (::Stock::StockNameConsumer_ptr c,
                                              ::RTCORBA::Priority priority)
{
  // Get mutual exclusion of the <subscribers_list_>.
  ACE_WRITE_GUARD_RETURN (ACE_RW_Thread_Mutex, g, lock_, 0);

  // Generate a unique id for the cookie.
  ACE_Utils::UUID uuid;
  ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);

  // Create a new cookie object; initialize its value.
  Stock::Cookie_var cookie = new OBV_Stock::Cookie ();
  cookie->cookie_id (uuid.to_string ()->c_str ());

  // Insert the cookie into the <subscribers_list_>.
  this->subscribers_list_[cookie->cookie_id ()] =
    std::make_pair (Stock::StockNameConsumer::_duplicate (c),
                    priority);

  ACE_DEBUG ((LM_DEBUG, "Subscribing  %s\n", cookie->cookie_id ()));

  return cookie._retn();
}
Пример #12
0
//
// get_next
//
CORBA::Boolean CUTS_TestArchiveBrowser_i::
get_next (CUTS::TestProfiles_out profiles)
{
  try
  {
    // Execute the prepared query.
    ADBC::Record & record = this->query_->execute ();

    // Count the number of record returned.
    size_t count = 0;
    for (; !record.done (); record.advance ())
      ++ count;

    // Reset the cursor of the record.
    record.reset ();

    if (count)
    {
      // Allocate a new sequence for the profiles.
      ACE_NEW_THROW_EX (profiles,
                        CUTS::TestProfiles (count),
                        CORBA::NO_MEMORY ());

      profiles->length (count);

      char name[256];
      char uuid_str[37];
      ACE_Utils::UUID uuid;
      int index = 0;

      // Copy each of test profile to the sequence.
      for ( ; !record.done (); record.advance ())
      {
        record.get_data (2, name, sizeof (name));
        record.get_data (3, uuid_str, sizeof (uuid_str));

        // Conver the UUID from string format.
        uuid.from_string (uuid_str);

        // Save the profile in the collection.
        (*profiles)[index].uuid <<= uuid;
        (*profiles)[index].name = CORBA::string_dup (name);

        // Increment the index.
        ++ index;
      }

      // Increment the index count.
      this->index_ += count;
    }

    this->is_done_ = record.done ();
    return this->is_done_;
  }
  catch (const ADBC::Exception & ex)
  {
    ACE_ERROR ((LM_ERROR,
                "%T (%t) - %M - %s\n",
                ex.message ().c_str ()));

    throw CUTS::OperationFailed ();
  }
}
Пример #13
0
    MonolithicDeploymentDescription
    MDD_Handler::mono_deployment_description(
        const Deployment::MonolithicDeploymentDescription &src)
    {
      DANCE_TRACE("mono_deployment_description - reverse");

      //Get the name and instantiate the mdd
      XMLSchema::string < ACE_TCHAR > name (
        ACE_TEXT_CHAR_TO_TCHAR (src.name));
      MonolithicDeploymentDescription mdd (name);

      //Get the source(s) from the IDL and store them
      size_t total = src.source.length();
      for(size_t i = 0; i < total; i++)
        {
          XMLSchema::string< ACE_TCHAR > curr (
            ACE_TEXT_CHAR_TO_TCHAR(src.source[i]));
          //mdd.add_source(curr);
        }

      //Get the artifactRef(s) from the IDL and store them
      total = src.artifactRef.length();
      for(size_t j = 0; j < total; j++)
        {
          ACE_TString tmp;
          ADD_Handler::IDREF.find_ref(src.artifactRef[j], tmp);
          IdRef idref;
          idref.idref (tmp.c_str ());
          //mdd.add_artifact (idref);
        }

      //Get the execParameter(s) from the IDL and store them
      total = src.execParameter.length();
      for(size_t k = 0; k < total; k++)
        {
          //mdd.add_execParameter (Property_Handler::
          //get_property (src.execParameter[k]));
        }

      //Get the deployRequirement(s) from the IDL and store them
      total = src.deployRequirement.length();
      for(size_t l = 0; l < total; l++)
        {
          //mdd.add_deployRequirement(Req_Handler::
          //get_requirement (src.deployRequirement[l]));
        }

      // Generate a UUID to use for the IDREF.
      ACE_Utils::UUID uuid;
      ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);
      ACE_TString mdd_id (ACE_TEXT ("_"));
      mdd_id += ACE_TEXT_CHAR_TO_TCHAR (uuid.to_string ()->c_str ());

      XMLSchema::ID< ACE_TCHAR > xml_id (mdd_id.c_str ());

      // Bind the ref and set it in the IDD
      MDD_Handler::IDREF.bind_next_available (mdd_id);

      mdd.id (xml_id);

      return mdd;
    }