Пример #1
0
/// Return an existing ImdbResource or NULL if no ImdbResource is found.
ImdbResource* ImdbResourceManager::find(const char* imdb /**< name of the imdb */)
{
    OsLock tableMutex(mImdbResourceTableLock);

    UtlString imdbName(imdb);

    return dynamic_cast<ImdbResource*>(mImdbResourceTable.find(&imdbName));
}
Пример #2
0
/// destructor
FileResourceManager::~FileResourceManager()
{
   OsLock tableMutex(mFileResourceTableLock);

   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_CRIT, "FileResourceManager::~ "
                 "delete %zu FileResources", mFileResourceTable.entries());

   mFileResourceTable.destroyAll();
}
Пример #3
0
/// destructor
ImdbResourceManager::~ImdbResourceManager()
{
    OsLock tableMutex(mImdbResourceTableLock);

    OsSysLog::add(FAC_SUPERVISOR, PRI_CRIT, "ImdbResourceManager::~ "
                  "delete %zu ImdbResources", mImdbResourceTable.entries());

    mImdbResourceTable.destroyAll();
}
Пример #4
0
/// Locate a SipxProcess object by name.
SipxProcess* SipxProcessManager::findProcess(const UtlString& processName)
{
   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,"SipxProcessManager::findProcess "
                 "searching for '%s'", processName.data()
                 );

   OsLock tableMutex(mProcessTableLock);

   return dynamic_cast<SipxProcess*>(mProcesses.find(&processName));
}
DirectoryResource*
DirectoryResourceManager::findFilename(const char* fullName ///< full path to a file
                                       )
{
   OsPath fullFileName(fullName);
   UtlString dirName  = fullFileName.getDirName();
   UtlString fileName;

   fileName.append(fullName, dirName.length(), UtlString::UTLSTRING_TO_END);
   dirName.strip(UtlString::trailing, OsPath::separator[0]);

   DirectoryResource* found = NULL;
   
   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,
                 "DirectoryResourceManager::findFilename: path '%s' file '%s'",
                 dirName.data(), fileName.data());

   {
      OsLock tableMutex(mDirectoryResourceTableLock);
      UtlSListIterator directories(mDirectoryResourceTable);
      DirectoryResource* dir;
   
      while (!found
             && (dir = dynamic_cast<DirectoryResource*>(directories.findNext(&dirName))))
      {
         if ( dir->matches(fileName) )
         {
            found = dir;
         }
      }
   }

   if (found)
   {
      UtlString matched;
      found->appendDescription(matched);
      Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,
                    "DirectoryResourceManager::findFilename: '%s' matches %s",
                    fullName, matched.data());
   }
   else
   {
      Os::Logger::instance().log(FAC_SUPERVISOR, PRI_WARNING,
                    "DirectoryResourceManager::findFilename: no match found for '%s'",
                    fullName);
   }
   
   return found;
}
Пример #6
0
/// Store a new FileResource
void FileResourceManager::save(FileResource* fileResource)
{
   OsLock tableMutex(mFileResourceTableLock);

   if (!mFileResourceTable.find(fileResource))
   {
      Os::Logger::instance().log(FAC_SUPERVISOR, PRI_INFO, "FileResourceManager::save "
                    "FileResource('%s')", fileResource->data());
      mFileResourceTable.insert(fileResource);
   }
   else
   {
      Os::Logger::instance().log(FAC_SUPERVISOR, PRI_CRIT, "FileResourceManager::save "
                    "duplicate FileResource('%s')", fileResource->data());
   }
}
Пример #7
0
/// Return an existing ImdbResource or NULL if no ImdbResource is found.
void ImdbResourceManager::save(ImdbResource* imdbResource)
{
    OsLock tableMutex(mImdbResourceTableLock);

    if (!mImdbResourceTable.find(imdbResource))
    {
        OsSysLog::add(FAC_SUPERVISOR, PRI_INFO, "ImdbResourceManager::save "
                      "ImdbResource('%s')", imdbResource->data());
        mImdbResourceTable.insert(imdbResource);
    }
    else
    {
        OsSysLog::add(FAC_SUPERVISOR, PRI_CRIT, "ImdbResourceManager::save "
                      "duplicate ImdbResource('%s')", imdbResource->data());
    }
}
Пример #8
0
/// Return an existing FileResource or NULL if no FileResource is found.
FileResource* FileResourceManager::find(const char* fileName, /**< full path to the file */
                                        FileMatchRule fileMatchRule
                                        )
{
   FileResource* returnedResource=NULL;
   
   UtlString path(fileName);

   {
      OsLock tableMutex(mFileResourceTableLock);
      returnedResource = dynamic_cast<FileResource*>(mFileResourceTable.find(&path));
   }

   if (!returnedResource && fileMatchRule == CheckForDirectoryMatches)
   {
      returnedResource =
         dynamic_cast<FileResource*>(
            DirectoryResourceManager::getInstance()->findFilename(fileName));
   }

   if ( Os::Logger::instance().willLog( FAC_SUPERVISOR, PRI_DEBUG ))
   {
      UtlString resourceDescription;

      if (returnedResource)
      {
         resourceDescription.append("found ");
         returnedResource->appendDescription(resourceDescription);
      }
      else
      {
         resourceDescription.append("not found");
      }
      
      Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG, "FileResourceManager::find '%s' %s",
                    fileName, resourceDescription.data());
   }

   return returnedResource;
}
Пример #9
0
/// destructor
SipxProcessManager::~SipxProcessManager()
{
   OsLock tableMutex(mProcessTableLock);

   SipxProcess* process;
   // send shutdowns to all processes before waiting for them to delete
   UtlHashBagIterator processes(mProcesses);
   while ((process = dynamic_cast<SipxProcess*>(processes())))
   {
      process->shutdown();
      OsTask::delay(100);
   }

   Os::Logger::instance().log(FAC_SUPERVISOR, PRI_NOTICE, "SipxProcessManager::~ "
                 "delete %zu SipxProcess objects", mProcesses.entries());

   mProcesses.destroyAll();

   while (mProcesses.entries() > 0)
   {
      OsTask::delay(1000);
   }
};
DirectoryResource*
DirectoryResourceManager::find(const UtlString& path,    ///< path of the directory
                               const UtlString& pattern  ///< pattern within directory
                               )
{
   DirectoryResource* found = NULL;
   
   {
      OsLock tableMutex(mDirectoryResourceTableLock);
      UtlSListIterator directories(mDirectoryResourceTable);
      DirectoryResource* dir;
   
      while (!found
             && (dir = dynamic_cast<DirectoryResource*>(directories.findNext(&path))))
      {
         if ( dir->isFilePattern(pattern) )
         {
            found = dir;
         }
      }
   }

   return found;
}
/// Return an existing DirectoryResource or NULL if no DirectoryResource is found.
void DirectoryResourceManager::save(DirectoryResource* directoryResource)
{
   OsLock tableMutex(mDirectoryResourceTableLock);

   mDirectoryResourceTable.insert(directoryResource);
}