Esempio n. 1
0
void AOSDatabaseConnectionPool::adminEmitXml(AXmlElement& eBase, const AHTTPRequestHeader& request)
{ 
  AOSAdminInterface::adminEmitXml(eBase, request);

  adminAddProperty(eBase, ASW("isInitialized",13), (m_isInitialized ? AConstant::ASTRING_TRUE : AConstant::ASTRING_FALSE));
  if (mp_DatabasePool)
    adminAddProperty(eBase, ASW("DatabasePool",12), *mp_DatabasePool);
}
Esempio n. 2
0
void AOSOutputExecutor::adminEmitXml(AXmlElement& eBase, const AHTTPRequestHeader& request)
{
  AOSAdminInterface::adminEmitXml(eBase, request);

  OutputGeneratorContainer::const_iterator cit = m_OutputGenerators.begin();
  while (cit != m_OutputGenerators.end())
  {
    adminAddProperty(eBase, ASW("generator",9), (*cit).second->getClass());
    ++cit;
  }
}
Esempio n. 3
0
void AOSContextQueue_IsAvailable::adminEmitXml(AXmlElement& eBase, const AHTTPRequestHeader& request)
{
  AOSContextQueueInterface::adminEmitXml(eBase, request);

  adminAddProperty(
    eBase,
    ASW("CurrentQueue",12),
    AString::fromInt(m_currentQueue % m_queueCount)
  );

  adminAddProperty(
    eBase,
    ASW("NoDataTimeout",13),
    AString::fromInt(m_NoDataTimeout)
  );

  adminAddProperty(
    eBase,
    ASW("EmptyQueueDelay",15),
    AString::fromInt(m_EmptyQueueDelay)
  );

  adminAddProperty(
    eBase,
    ASW("LoopDelay",9),
    AString::fromInt(m_LoopDelay)
  );

  adminAddProperty(
    eBase,
    ASW("Queues.size",11),
    AString::fromSize_t(m_queueCount)
  );

  for (size_t i=0; i<m_Queues.size(); ++i)
  {
    QueueWithThread *p = m_Queues.at(i);
    AString str("queue[",6);
    str.append(AString::fromSize_t(i));

    adminAddProperty(
      eBase,
      str+ASW("].count",7),
      AString::fromSize_t(p->count)
    );

    adminAddProperty(
      eBase,
      str+ASW("].size",6),
      AString::fromSize_t(p->queue.size())
    );
  }
}
Esempio n. 4
0
void AOSContextManager::adminEmitXml(AXmlElement& eBase, const AHTTPRequestHeader& request)
{
  AOSAdminInterface::adminEmitXml(eBase, request);

  //a_Check if specific context is required
  AString contextId;
  if (request.getUrl().getParameterPairs().get(ASW("contextId",9), contextId))
  {
    //a_Find the specific context
    {
      ALock lock(m_InUseSync);
      for (CONTEXT_INUSE::const_iterator cit = m_InUse.begin(); cit != m_InUse.end(); ++cit)
      {
        if (contextId == AString::fromPointer(*cit))
        {
          adminAddProperty(eBase, ASW("contextDetail",7), *(*cit), AXmlElement::ENC_CDATADIRECT);
          return;
        }
      }
    }
    
    {
      ALock lock(m_ErrorHistory.useSync());
      for (ABase *p = m_ErrorHistory.useTail(); p; p = p->usePrev())
      {
        AOSContext *pContext = dynamic_cast<AOSContext *>(p);
        if (contextId == AString::fromPointer(pContext))
        {
          adminAddProperty(eBase, ASW("contextDetail",7), *pContext, AXmlElement::ENC_CDATADIRECT);
          return;
        }
      }
    }

    {
      ALock lock(m_History.useSync());
      for (ABase *p = m_History.useTail(); p; p = p->usePrev())
      {
        AOSContext *pContext = dynamic_cast<AOSContext *>(p);
        if (contextId == AString::fromPointer(pContext))
        {
          adminAddProperty(eBase, ASW("contextDetail",7), *pContext, AXmlElement::ENC_CDATADIRECT);
          return;
        }
      }
    }

	  //a_Context no longer available
    adminAddError(eBase, ASWNL("AOSContext no longer available"));
  }
  else
  {
    //a_Display context summary
    for (size_t i=0; i < m_Queues.size(); ++i)
    {
      AOSContextQueueInterface *pQueue = m_Queues.at(i);
      if (pQueue)
        adminAddProperty(eBase, AString::fromSize_t(i), pQueue->getClass());
      else
        adminAddProperty(eBase, AString::fromSize_t(i), AConstant::ASTRING_NULL);
    }

    adminAddPropertyWithAction(
      eBase,
      ASW("log_level",9), 
      AString::fromInt(m_DefaultEventLogLevel),
      ASW("Update",6), 
      ASWNL("Maximum event to log 0:Disabled 1:Error, 2:Event, 3:Warning, 4:Info, 5:Debug"),
      ASW("Set",3)
    );

    {
      AString str;
      str.assign('[');
      str.append(AString::fromSize_t(m_History.size()));
      str.append('/');
      str.append(AString::fromSize_t(m_HistoryMaxSize));
      str.append(']');

      AXmlElement& eHistory = eBase.addElement("object").addAttribute("name", "history");
      adminAddPropertyWithAction(eHistory, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext history size (objects not immediately deleted)"), ASW("Set",3));
    }
    
    adminAddPropertyWithAction(
      eBase,
      ASW("clear_history",13), 
      AConstant::ASTRING_EMPTY,
      ASW("Clear",5), 
      ASWNL("Clear context history: 0:all  1:history  2:error history"),
      ASW("Clear",5) 
    );
      
    {
      AString str;
      str.assign('[');
      str.append(AString::fromSize_t(m_ErrorHistory.size()));
      str.append('/');
      str.append(AString::fromSize_t(m_ErrorHistoryMaxSize));
      str.append(']');

      AXmlElement& eErrorHistory = eBase.addElement("object").addAttribute("name", "error_history");
      adminAddPropertyWithAction(eErrorHistory, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext error history size (objects not immediately deleted)"), ASW("Set",3));
    }

    {
      AString str;
      str.assign('[');
      str.append(AString::fromSize_t(m_FreeStore.size()));
      str.append('/');
      str.append(AString::fromSize_t(m_FreeStoreMaxSize));
      str.append(']');

      AXmlElement& eFreestore = eBase.addElement("object").addAttribute("name", "freestore");
      adminAddPropertyWithAction(eFreestore, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext freestore size (objects not immediately deleted)"), ASW("Set",3));
    }

    AXmlElement& eInUse = eBase.addElement("object");
    eInUse.addAttribute("name", "InUse");
    eInUse.addAttribute("size", AString::fromSize_t(m_InUse.size()));
    CONTEXT_INUSE::const_iterator citU = m_InUse.begin();
    if (citU != m_InUse.end())
    {
      ALock lock(m_InUseSync);
      while(citU != m_InUse.end())
      {
        AXmlElement& eProp = adminAddProperty(eInUse, ASW("context",7), (*citU)->useEventVisitor(), AXmlElement::ENC_CDATADIRECT);
        eProp.addAttribute(ASW("errors",6), AString::fromSize_t((*citU)->useEventVisitor().getErrorCount()));
        eProp.addElement(ASW("url",3)).addData((*citU)->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT);
        eProp.addElement(ASW("contextId",9)).addData(AString::fromPointer(*citU), AXmlElement::ENC_CDATADIRECT);
        ++citU;
      }
    }

    {
      AXmlElement& eHistory = eBase.addElement("object").addAttribute("name", "history");
      ALock lock(m_History.useSync());
      for (ABase *p = m_History.useTail(); p; p = p->usePrev())
      {
        AOSContext *pContext = dynamic_cast<AOSContext *>(p);
        if (pContext)
        {
          AXmlElement& eProp = adminAddProperty(eHistory, ASW("context",7), pContext->useEventVisitor(), AXmlElement::ENC_CDATADIRECT);
          eProp.addAttribute(ASW("errors",6), AString::fromSize_t(pContext->useEventVisitor().getErrorCount()));
          eProp.addElement(ASW("url",3), pContext->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT);
          eProp.addElement(ASW("contextId",3)).addData(AString::fromPointer(pContext), AXmlElement::ENC_CDATADIRECT);
        }
        else
          ATHROW(this, AException::InvalidObject);
      }
    }

    {
      AXmlElement& eErrorHistory = eBase.addElement("object").addAttribute("name", "error_history");
      ALock lock(m_ErrorHistory.useSync());
      for (ABase *p = m_ErrorHistory.useTail(); p; p = p->usePrev())
      {
        AOSContext *pContext = dynamic_cast<AOSContext *>(p);
        if (pContext)
        {
          AXmlElement& eProp = adminAddProperty(eErrorHistory, ASW("context",7), pContext->useEventVisitor(), AXmlElement::ENC_CDATADIRECT);
          eProp.addAttribute(ASW("errors",6), AString::fromSize_t(pContext->useEventVisitor().getErrorCount()));
          eProp.addElement(ASW("url",3), pContext->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT);
          eProp.addElement(ASW("contextId",3)).addData(AString::fromPointer(pContext), AXmlElement::ENC_CDATADIRECT);
        }
        else
          ATHROW(this, AException::InvalidObject);
      }
    }
  }
}