Beispiel #1
0
// Whether or not the ImdbResource is ready for use by a Imdb.
bool ImdbResource::isReadyToStart(UtlString& missingResource)
{
   OsLock mutex(mLock);

   bool rc;
   rc = false;

        
   if (NULL == mDatabase)
   {
        mDatabase = SIPDBManager::getInstance()->getDatabase(*this);
   }
           
   rc = (NULL != mDatabase);
   if (rc)
   {
      // preload the database.  if it fails (i.e. no xml file) then resource not ready.
      if (SIPDBManager::getInstance()->preloadDatabaseTable(*this) != OS_SUCCESS)
      {
         OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "FAILED to load database %s returning missing resource", this->data());
         rc = false;
      }
   }
   else
   {
      missingResource = "";
      appendDescription(missingResource);
   } 
   return rc;
}
Beispiel #2
0
// Whether or not the SqldbResource is ready for use by a Sqldb.
bool SqldbResource::isReadyToStart(UtlString& missingResource)
{
   bool dbIsReady;

   // Check to ensure that we can connect to the database.
   OdbcHandle dbHandle = odbcConnect(mDbName, mServer, mUser, mDbDriver, mPassword);
   if (dbHandle)
   {
      odbcDisconnect(dbHandle);
      OsSysLog::add(FAC_SUPERVISOR, PRI_INFO, "SqldbResource::isReadyToStart "
                     "Successfully connected to database '%s'",
                     mDbName.data());
      dbIsReady = true;
   }
   else
   {
      OsSysLog::add(FAC_SUPERVISOR, PRI_ERR, "SqldbResource::isReadyToStart "
                     "Unable to connect to database '%s'",
                     mDbName.data());
      missingResource = "";
      appendDescription(missingResource);
      dbIsReady = false;
   }

   return dbIsReady;
}
Beispiel #3
0
// Whether or not the FileResource is ready for use by a SipxProcess.
bool FileResource::isReadyToStart(UtlString& missingResource)
{
   OsPath filePath(*this);
   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,
                 "FileResource::isReadyToStart checking for existence of %s",
                 data());
   bool bReady = OsFileSystem::exists(filePath);
   if ( !bReady )
   {
      missingResource = "";
      appendDescription(missingResource);
   }
   return bReady;
}
// Whether or not the SipxProcessResource is ready for use by a SipxProcess.
bool SipxProcessResource::isReadyToStart(UtlString& missingResource)
{
   SipxProcess* myProcess = getProcess();

   bool bReady = (myProcess && myProcess->isRunning());
   if ( !bReady )
   {
      missingResource = "";
      appendDescription(missingResource);
       OsSysLog::add(FAC_SUPERVISOR, PRI_WARNING, 
                     "SipxProcessResource::isReadyToStart returns false; %s is not running ",
                     data());
   }
   return bReady;
}
// Whether or not the DirectoryResource is ready for use by a SipxProcess.
bool DirectoryResource::isReadyToStart(UtlString& missingResource)
{
   OsPath directoryPath(*this);
   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,
                 "DirectoryResource::isReadyToStart checking for existence of %s",
                 data());
   bool bReady;

   if (mFilePattern.isNull())
   {
      bReady = true;
   }
   else
   {
      bReady = OsFileSystem::exists(directoryPath);
   }
   
   if ( !bReady )
   {
      missingResource = "";
      appendDescription(missingResource);
   }
   return bReady;
}