#include <SystemManager.h>
Definition at line 40 of file SystemManager.h.
CSystemManager::CSystemManager | ( | ) |
Definition at line 67 of file SystemManager.cpp.
00068 { 00069 m_BlockSize = 0; 00070 m_MaxDisks = 0; 00071 m_MaxReplications = 0; 00072 m_UseReplications = 0; 00073 m_MaxDataRequests = 0; 00074 m_MaxPendingRequests = 0; 00075 m_FileRoot = NULL; 00076 m_MetaRoot = NULL; 00077 m_UserRoot = NULL; 00078 m_MaxSessions = 0; 00079 m_MaxStreams = 0; 00080 m_MaxOpenObjects = 0; 00081 m_MaxRate = 0.0; 00082 m_NRTReservedRate = 0.0; 00083 00084 // to support buffers and new CAC 00085 m_NumberOfBuffersForEachClient = 0; 00086 m_BurstSizeOfEachClient = 0; 00087 m_MaxNumberAtDiskQueueToEachClient = 0; 00088 m_CollectMeasures = NULL; 00089 m_UseServerSideBuffers = NULL; 00090 m_UseNewCAC = NULL; 00091 m_NetworkRate = 0.0; 00092 m_EstimatedTimeParameter = 0.0; 00093 m_MaxIntervalEmpty = 0.0; 00094 m_NumberOfEmptyTimes = 0; 00095 // ------------------------------------------------------------------------ 00096 00097 m_GenerateLogs = 0; 00098 m_DiskMgr = NULL; 00099 m_objectManager = NULL; 00100 m_Router = NULL; 00101 m_StreamManager = NULL; 00102 m_SessionManager = NULL; 00103 m_UserManager = NULL; 00104 00105 m_initialized = false; 00106 m_started = false; 00107 00108 // Inicializacao das novas variaveis com o nome do diretorio com os 00109 // arquivos de configuracao e de senhas, e com o nome do diretorio onde 00110 // os logs serao salvos. 00111 m_ConfigsDirectory = NULL; 00112 m_LogsDirectory = NULL; 00113 00114 // Inicializacao das novas variaveis usadas para tentar a conexao com cada 00115 // servidor de armazenamento por mais de uma vez antes de abortar a 00116 // execucao do servidor de despacho. 00117 m_MaxAttempts = 20; // Numero de tentativas. 00118 m_TimeBetweenAttempts = 2; // Tempo entre as tentativas. 00119 // Inicializacao do novo parametro usado para indicar o tempo maximo que o 00120 // servidor espera por uma requisicao de um cliente. 00121 m_ClientsTimeOut = 0; // Nao usa o timeout, isto e, igual ao que ocorria 00122 // anteriormente. 00123 00124 // Inicializacao dos novos parametros usados pela classe de gerenciamento 00125 // dos logs. 00126 m_MaxLogFileSize = MAXLOGFILESIZE; 00127 m_MaxCombinedLogFilesSize = MAXCOMBINEDLOGSFILESIZE; 00128 // Inicializacao da nova variavel usada para indicar se devemos salvar os 00129 // logs. Por default (NULL), supomos que os logs devem ser salvos. 00130 m_SaveLogs = NULL; 00131 }
CSystemManager::~CSystemManager | ( | ) |
Definition at line 134 of file SystemManager.cpp.
00135 { 00136 #ifdef RIO_DEBUG1 00137 RioErr << "[CSystemManager] Destructor Start" << endl; 00138 #endif 00139 00140 if( m_FileRoot != 0 ) 00141 { 00142 delete[] m_FileRoot; 00143 } 00144 if( m_MetaRoot != 0 ) 00145 { 00146 delete[] m_MetaRoot; 00147 } 00148 if( m_UserRoot != 0 ) 00149 { 00150 delete[] m_UserRoot; 00151 } 00152 00153 // Remocao das novas variaveis com o nome do diretorio com os arquivos de 00154 // configuracao e de senhas, e com o nome do diretorio onde os logs serao 00155 // salvos. 00156 if( m_ConfigsDirectory != NULL ) 00157 delete[] m_ConfigsDirectory; 00158 00159 if( m_LogsDirectory != NULL ) 00160 delete[] m_LogsDirectory; 00161 00162 // Remove as strings usadas ao ler a configuracao. 00163 if( m_UseServerSideBuffers != NULL ) 00164 delete[] m_UseServerSideBuffers; 00165 if( m_UseNewCAC != NULL ) 00166 delete[] m_UseNewCAC; 00167 if( m_CollectMeasures != NULL ) 00168 delete[] m_CollectMeasures; 00169 if( m_SaveLogs != NULL ) 00170 delete[] m_SaveLogs; 00171 00172 #ifdef RIO_DEBUG1 00173 RioErr << "[CSystemManager] Destructor End" << endl; 00174 #endif 00175 }
int CSystemManager::CheckConfiguration | ( | ) | [private] |
Definition at line 641 of file SystemManager.cpp.
00642 { 00643 // check BlockSize 00644 if( ( m_BlockSize < 512 ) || ( m_BlockSize % 512 != 0 ) ) 00645 { 00646 RioErr << "SystemManager.CheckConfiguration " 00647 << " - Invalid block size " << m_BlockSize 00648 << " (must be multiple of physical sector) " << endl; 00649 return ERROR_SYSTEMMANAGER + ERROR_INVALID_BLOCKSIZE; 00650 } 00651 00652 // check MaxDisks 00653 if( ( m_MaxDisks < 1 ) || ( m_MaxDisks > (int) ( MAXNUMSTORAGES * 00654 MAXSTORAGEDISKSARRAY ) ) ) 00655 { 00656 RioErr << "SystemManager::CheckConfiguration " 00657 << "MaxDisks: " << m_MaxDisks 00658 << " invalid (range 1-" << MAXNUMSTORAGES * MAXSTORAGEDISKSARRAY 00659 << ")" << endl; 00660 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00661 } 00662 00663 if( m_MaxSessions < 1 ) 00664 { 00665 RioErr << "SystemManager.CheckConfiguration " 00666 << "MaxSessions: " << m_MaxSessions 00667 << " invalid (must be > 1)" << endl; 00668 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00669 } 00670 00671 if( m_MaxStreams < 1 ) 00672 { 00673 RioErr << "SystemManager.CheckConfiguration " 00674 << "MaxStreams: " << m_MaxStreams 00675 << " invalid (must be > 1)" << endl; 00676 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00677 } 00678 00679 if( m_MaxOpenObjects < 1 ) 00680 { 00681 RioErr << "SystemManager.CheckConfiguration " 00682 << "MaxOpenObjects: " << m_MaxOpenObjects 00683 << " invalid (must be > 1)" << endl; 00684 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00685 } 00686 00687 // check replication values 00688 if( ( m_UseReplications < 1 ) || ( m_UseReplications > 8 ) ) 00689 { 00690 RioErr << "SystemManager.CheckConfiguration " 00691 "UseReplications must be between 1 and 8" << endl; 00692 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00693 } 00694 if( ( m_MaxReplications < 1 ) || ( m_MaxReplications > 8 ) ) 00695 { 00696 RioErr << "SystemManager.CheckConfiguration " 00697 "MaxReplications must be between 1 and 8" << endl; 00698 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00699 } 00700 00701 if( m_UseReplications > m_MaxReplications ) 00702 { 00703 RioErr << "SystemManager.CheckConfiguration " 00704 "UseReplications > MaxReplications " << endl; 00705 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00706 } 00707 00708 if( ( m_UseReplications > 1 ) && ( m_MaxDisks < MAXSTORAGEDISKSARRAY ) ) 00709 { 00710 RioErr << "SystemManager.CheckConfiguration warning: " 00711 "using replication > 1 with few disks or nodes may not work " 00712 << endl; 00713 } 00714 00715 if( m_BurstSizeOfEachClient < 0 ) 00716 { 00717 RioErr << "SystemManager.CheckConfiguration " 00718 << "BurstSizeOfEachClient: " << m_BurstSizeOfEachClient 00719 << " invalid (must be > 0)" << endl; 00720 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00721 } 00722 00723 if( ( m_NumberOfBuffersForEachClient < 0 ) || 00724 ( m_NumberOfBuffersForEachClient > 20 )) 00725 { 00726 RioErr << "SystemManager.CheckConfiguration " 00727 << "NumberOfBuffersForEachClient: " 00728 << m_NumberOfBuffersForEachClient 00729 << " invalid (must be between 0 and 20)" << endl; 00730 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00731 } 00732 00733 if( m_NetworkRate < 0 ) 00734 { 00735 RioErr << "SystemManager.CheckConfiguration " 00736 << "NetworkRate: " << m_NetworkRate 00737 << " invalid (must be > 0)" << endl; 00738 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00739 } 00740 else 00741 { 00742 m_NetworkRate = (m_NetworkRate * 1024.0 * 1024.0) / 8; //in bytes/sec 00743 } 00744 00745 if( ( m_EstimatedTimeParameter < 0 ) || ( m_EstimatedTimeParameter > 1 ) ) 00746 { 00747 RioErr << "SystemManager.CheckConfiguration " 00748 << "EstimatedTimeParameter: " << m_EstimatedTimeParameter 00749 << " invalid (must be between 0 and 1)" << endl; 00750 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00751 } 00752 00753 if( ( strcasecmp( m_UseServerSideBuffers, "on" ) != 0 ) && 00754 ( strcasecmp( m_UseServerSideBuffers, "off" ) != 0 )) 00755 { 00756 RioErr << "SystemManager.CheckConfiguration " 00757 << "UseServerSideBuffers: " << m_UseServerSideBuffers 00758 << " invalid (must be 'on' or 'off')" << endl; 00759 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00760 } 00761 if( ( strcasecmp( m_UseNewCAC, "on" ) != 0 ) && 00762 ( strcasecmp( m_UseNewCAC, "off" ) != 0 )) 00763 { 00764 RioErr << "SystemManager.CheckConfiguration " 00765 << "UseNewCAC: " << m_UseNewCAC 00766 << " invalid (must be 'on' or 'off')" << endl; 00767 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00768 } 00769 if( ( strcasecmp( m_CollectMeasures, "on" ) != 0 ) && 00770 ( strcasecmp( m_CollectMeasures, "off" ) != 0 )) 00771 { 00772 RioErr << "SystemManager.CheckConfiguration " 00773 << "CollectMeasures: " << m_CollectMeasures 00774 << " invalid (must be 'on' or 'off')" << endl; 00775 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00776 } 00777 00778 if( ( m_GenerateLogs != 0 ) && ( m_GenerateLogs != 1 ) ) 00779 { 00780 RioErr << "SystemManager.CheckConfiguration " 00781 << "GenerateLogs: " << m_GenerateLogs 00782 << " invalid (must be '0' or '1')" << endl; 00783 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00784 } 00785 00786 if( strcasecmp( m_UseNewCAC, "on" ) == 0 ) 00787 { 00788 strcpy( m_UseNewCAC, "on" ); 00789 strcpy( m_UseServerSideBuffers, "on" ); 00790 strcpy( m_CollectMeasures, "on" ); 00791 } 00792 00793 if( m_NumberOfEmptyTimes < 0 ) 00794 { 00795 RioErr << "SystemManager.CheckConfiguration " 00796 << "NumberOfEmptyTimes: " << m_NumberOfEmptyTimes 00797 << " invalid (must be >= 0)" << endl; 00798 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00799 } 00800 if( m_MaxIntervalEmpty < 0 ) 00801 { 00802 RioErr << "SystemManager.CheckConfiguration " 00803 << "MaxIntervalEmpty: " << m_MaxIntervalEmpty 00804 << " invalid (must be >= 0)" << endl; 00805 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00806 } 00807 00808 RioErr << "UseNewCAC " << m_UseNewCAC << endl; 00809 RioErr << "UseServerSideBuffers " << m_UseServerSideBuffers << endl; 00810 RioErr << "CollectMeasures " << m_CollectMeasures << endl; 00811 // ------------------------------------------------------------------------ 00812 00813 // check Roots 00814 if( CheckString( "FileRoot", m_FileRoot ) ) 00815 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00816 if( CheckString( "MetaRoot", m_MetaRoot ) ) 00817 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00818 if( CheckString( "UserRoot", m_UserRoot ) ) 00819 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00820 00821 // Duas novas opcoes para permitir que o servidor tente se conectar mais de 00822 // uma vez a cada um dos servidores de armazenamento, antes de abortar com 00823 // erro. A opcao MaxAttempts define o numero de tentativas e a 00824 // TimeBetweenAttempts define o tempo (em segundos entre duas tentativas 00825 // consecutivas). 00826 00827 if( m_MaxAttempts < 0 ) 00828 { 00829 RioErr << "SystemManager.CheckConfiguration " 00830 << "MaxAttempts: " << m_MaxAttempts 00831 << " invalid (must be >= 0)" << endl; 00832 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00833 } 00834 00835 if( m_TimeBetweenAttempts < 0 ) 00836 { 00837 RioErr << "SystemManager.CheckConfiguration " 00838 << "TimeBetweenAttempts: " << m_TimeBetweenAttempts 00839 << " invalid (must be >= 0)" << endl; 00840 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00841 } 00842 00843 // Nova opcao usada para indicar o tempo maximo que o servidor espera por 00844 // uma requisicao de um cliente. Se a opcao nao for usada, ou se o seu valor 00845 // for 0, entao nao teremos um tempo maximo (como ocorria antes). 00846 00847 if( m_ClientsTimeOut < 0 ) 00848 { 00849 RioErr << "SystemManager.CheckConfiguration " 00850 << "ClientsTimeOut: " << m_ClientsTimeOut 00851 << " invalid (must be >= 0)" << endl; 00852 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00853 } 00854 00855 // Novas opcoes usadas pelo gerenciamento dos logs para limitar o tamanho 00856 // do arquivo de log nao compactado e o tamanho total combinado de todos 00857 // os logs (compactados ou nao). 00858 00859 if( m_MaxLogFileSize <= 0 ) 00860 { 00861 RioErr << "SystemManager.CheckConfiguration " 00862 << "MaxLogFileSize: " << m_MaxLogFileSize 00863 << " invalid (must be > 0)" << endl; 00864 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00865 } 00866 00867 if( m_MaxCombinedLogFilesSize <= 0 ) 00868 { 00869 RioErr << "SystemManager.CheckConfiguration " 00870 << "MaxCombinedLogFilesSize: " << m_MaxCombinedLogFilesSize 00871 << " invalid (must be > 0)" << endl; 00872 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00873 } 00874 00875 // Nova opcao para definir se os logs devem ou nao ser salvos, ou seja, se 00876 // devemos ou nao somente executar buscas nestes logs. 00877 if( ( m_SaveLogs != NULL ) && ( strcasecmp( m_SaveLogs, "on" ) != 0 ) && 00878 ( strcasecmp( m_SaveLogs, "off" ) != 0 ) ) 00879 { 00880 RioErr << "SystemManager.CheckConfiguration " 00881 << "LogRotation: " << m_SaveLogs 00882 << " invalid (must be 'on' or 'off')" << endl; 00883 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00884 } 00885 00886 printSystemConfiguration(); 00887 00888 return 0; 00889 }
int CSystemManager::CheckString | ( | const char * | name, | |
const char * | x | |||
) | [private] |
Definition at line 892 of file SystemManager.cpp.
00893 { 00894 if( ( x == 0 ) || ( strlen( x ) < 1 ) ) 00895 { 00896 RioErr << "SystemManager::CheckConfiguration " 00897 << name << " not specified or null string" << endl; 00898 return ERROR_SYSTEMMANAGER + ERROR_INVALID_PARAM; 00899 } 00900 return 0; 00901 }
int CSystemManager::Format | ( | ) | [private] |
Definition at line 321 of file SystemManager.cpp.
00322 { 00323 int rc = 0; 00324 00325 if( mkdir( m_FileRoot, 0700 ) ) 00326 { 00327 RioErr << "SystemManager.Format - mkdir failed for " 00328 << m_FileRoot << " (m_FileRoot) " 00329 << strerror(errno) << endl; 00330 rc = 1; 00331 } 00332 00333 if( mkdir( m_MetaRoot, 0700 ) ) 00334 { 00335 RioErr << "SystemManager.Format - mkdir failed for " 00336 << m_MetaRoot << " (m_MetaRoot) " 00337 << strerror(errno) << endl; 00338 rc = 1; 00339 } 00340 00341 if( mkdir( m_UserRoot, 0700 ) ) { 00342 RioErr << "SystemManager.Format - mkdir failed for " 00343 << m_UserRoot << " (m_UserRoot) " 00344 << strerror(errno) << endl; 00345 // allow failing to mkdir UserRoot to continue; 00346 // perhaps it has useful info in it... 00347 if( !rc ) 00348 RioErr << "\t\t...continuing anyway... " << endl; 00349 } 00350 00351 if( rc ) 00352 { 00353 RioErr << "fatal format error above, exiting.." << endl; 00354 return 1; 00355 } 00356 00357 // Initialize EventManager 00358 // Initialize allocates space for each type of event 00359 // The number of events of each type can not exceed the maximum 00360 // set at Initialization. Attempting to do so will block 00361 // the asking thread until one event of that type is freed by 00362 // other thread. If these values are too small system performance 00363 // may be degraded, since threads will be blocked waiting 00364 // for event entries 00365 EventManager.Initialize( EventTypeStorageRequest, 2*m_MaxDisks ); 00366 EventManager.Initialize( EventTypeStorageReply, 2*m_MaxDisks ); 00367 EventManager.Initialize( EventTypeAddDisk, m_MaxDisks ); 00368 00369 // Inicializa os novos eventos para tratar da queda/reinicio dos servidores 00370 // de armazenamento. 00371 EventManager.Initialize( EventTypeStorageDown, MAXNUMSTORAGES ); 00372 EventManager.Initialize( EventTypeStorageUp, MAXNUMSTORAGES ); 00373 00374 // Inicializa os novos eventos para tratar do termino das threads que usem 00375 // uma fila. 00376 EventManager.Initialize( EventTypeFinalizeThread, 1 ); 00377 00378 // Initialize DiskMgr (finds nodes) 00379 if( StartDiskMgr(1) ) 00380 return 1; 00381 00382 //### kludge wait to allow time for DiskMgr to contact storage nodes 00383 sleep(5); 00384 00385 //now build empty metadata for storage space etc. 00386 return m_DiskMgr->Format(); 00387 }
int CSystemManager::FreeMembers | ( | ) | [private] |
Definition at line 1378 of file SystemManager.cpp.
01379 { 01380 int result = S_OK; 01381 int result2; 01382 01383 if( m_UserManager != 0 ) 01384 { 01385 delete m_UserManager; 01386 m_UserManager = 0; 01387 } 01388 01389 if( m_SessionManager != 0 ) 01390 { 01391 delete m_SessionManager; 01392 m_SessionManager = 0; 01393 } 01394 01395 if( m_StreamManager != 0 ) 01396 { 01397 delete m_StreamManager; 01398 m_StreamManager = 0; 01399 } 01400 01401 if( m_Router != 0 ) 01402 { 01403 result2 = m_Router->Stop(); 01404 if( ( ( unsigned int ) result2 != 01405 ( ERROR_ROUTER + ERROR_NOT_STARTED ) 01406 ) && 01407 ( FAILED ( result2 ) ) 01408 ) 01409 { 01410 RioErr << "FreeMembers(): Failed to stop Router" << endl; 01411 result = result2; 01412 } 01413 delete m_Router; 01414 m_Router = 0; 01415 } 01416 01417 if( m_objectManager != 0 ) 01418 { 01419 result2 = m_objectManager->Stop(); 01420 if( FAILED( result2 ) ) 01421 { 01422 RioErr << "FreeMembers(): Failed to stop Object Manager" << endl; 01423 result = result2; 01424 } 01425 delete m_objectManager; 01426 m_objectManager = 0; 01427 } 01428 01429 //### have DiskMgr stop all storage nodes here... 01430 if( m_DiskMgr != 0 ) 01431 delete m_DiskMgr; 01432 01433 // Finaliza a thread de monitoramento. 01434 m_MonitorTable.Stop(); 01435 01436 return result; 01437 }
int CSystemManager::GetMonitorTable | ( | vector< ClientData > & | clientTable, | |
vector< StorageData > & | storageTable | |||
) |
Definition at line 1519 of file SystemManager.cpp.
01521 { 01522 m_MonitorTable.getData( clientTable, storageTable ); 01523 return 0; 01524 }
void CSystemManager::InvalidateStorageNatMappings | ( | int | StorageId | ) |
Funcao para invalidar todos os mapeamentos dos clientes conectados para um servidor de armazenamento identificado pela ID passada como parametro.
StorageId | Identificador do servidor de armazenamento. |
Definition at line 1530 of file SystemManager.cpp.
01531 { 01532 // Somente devemos executar este metodo se a classe ja foi criada e 01533 // inicializada. 01534 if( m_SessionManager != NULL ) 01535 m_SessionManager->InvalidateStorageNatMappings( StorageId ); 01536 else 01537 RioErr << "CSystemManager::InvalidateStorageNatMappings aviso a funcao " 01538 << "foi chamada antes da criacao e inicializacao do objecto da " 01539 << "classe CSessionManager" << endl; 01540 01541 }
void * CSystemManager::MonitorTableTrigger | ( | void * | param | ) | [static, private] |
Definition at line 1506 of file SystemManager.cpp.
01507 { 01508 ((CSystemManager *)param)->m_MonitorTable.Monitor(); 01509 return NULL; 01510 }
void CSystemManager::PostITEvent | ( | MonitorEvent * | event | ) |
Definition at line 1513 of file SystemManager.cpp.
01514 { 01515 m_MonitorTable.putMonitorEvent( event ); 01516 }
void CSystemManager::printSystemConfiguration | ( | ) | [private] |
Definition at line 1440 of file SystemManager.cpp.
01441 { 01442 cout << "---------------------------------------------------" << endl; 01443 cout << " RIO Configuration " << endl; 01444 cout << "---------------------------------------------------" << endl; 01445 cout << "RIO System Block Size \t\t" << m_BlockSize << " Bytes" << endl; 01446 cout << "Maximum Number of disks \t" << m_MaxDisks << endl; 01447 cout << "Maximum Number of sessions \t" << m_MaxSessions << endl; 01448 cout << "Maximum Number of streams \t" << m_MaxStreams << endl; 01449 cout << "Maximum Number of open objects \t" << m_MaxOpenObjects << endl; 01450 01451 cout << "MaxReplications \t\t" << m_MaxReplications << endl; 01452 cout << "UseReplications \t\t" << m_UseReplications << endl; 01453 01454 cout << "MaxDataRequests \t\t" << m_MaxDataRequests << endl; 01455 cout << "MaxPendingRequests \t\t" << m_MaxPendingRequests << endl; 01456 01457 cout << "FileRoot \t\t\t" << m_FileRoot << endl; 01458 cout << "MetaRoot \t\t\t" << m_MetaRoot << endl; 01459 cout << "UserRoot \t\t\t" << m_UserRoot << endl; 01460 01461 cout << "Buffers to each client \t\t" << m_NumberOfBuffersForEachClient << endl; 01462 cout << "Burst Size of each client \t" << m_BurstSizeOfEachClient << endl; 01463 01464 //convert B/sec -> Mb/sec 01465 double networkrate = (m_NetworkRate * 8 )/1024.0/1024.0; 01466 cout << "NetworkRate \t\t\t" << networkrate <<" Mbps"<< endl; 01467 cout << "CollectMeasures \t\t" << m_CollectMeasures << endl; 01468 cout << "UseServerSideBuffers \t\t" << m_UseServerSideBuffers << endl; 01469 cout << "UseNewCAC \t\t\t" << m_UseNewCAC << endl; 01470 cout << "EstimatedTimeParameter \t\t" << m_EstimatedTimeParameter << endl; 01471 cout << "NumberOfEmptyTimes \t\t" << m_NumberOfEmptyTimes << endl; 01472 cout << "MaxIntervalEmpty \t\t" << m_MaxIntervalEmpty << " msec" << endl; 01473 // ------------------------------------------------------------------------ 01474 cout << "GenerateLogs \t\t\t" << m_GenerateLogs << endl; 01475 // ------------------------------------------------------------------------ 01476 // Novas opcoes para permitir que o servidor tente se conectar mais de uma 01477 // vez a cada um dos servidores de armazenamento, antes de abortar com 01478 // erro. A opcao MaxAttempts define o numero de tentativas e a 01479 // TimeBetweenAttempts define o tempo (em segundos entre duas tentativas 01480 // consecutivas). 01481 cout << "MaxAttempts \t\t\t" << m_MaxAttempts << endl; 01482 cout << "TimeBetweenAttempts \t\t" << m_TimeBetweenAttempts << endl; 01483 // Nova opcao usada para indicar o tempo maximo que o servidor espera por 01484 // uma requisicao de um cliente. Se a opcao nao for usada, ou se o seu valor 01485 // for 0, entao nao teremos um tempo maximo (como ocorria antes). 01486 cout << "ClientsTimeOut \t\t\t" << m_ClientsTimeOut << endl; 01487 // Novas opcoes usadas pelo gerenciamento dos logs para limitar o tamanho 01488 // do arquivo de log nao compactado e o tamanho total combinado de todos 01489 // os logs (compactados ou nao). 01490 cout << "MaxLogFileSize \t\t\t" << m_MaxLogFileSize / 1024 << " Kbytes" 01491 << endl; 01492 cout << "MaxCombinedLogFilesSize \t" << m_MaxCombinedLogFilesSize / 1024 01493 << " Kbytes" << endl; 01494 // Nova opcao para definir se os logs devem ou nao ser salvos, ou seja, se 01495 // devemos ou nao somente executar buscas nestes logs. 01496 if( m_SaveLogs != NULL ) 01497 cout << "LogRotation \t\t\t" << m_SaveLogs << endl; 01498 else 01499 cout << "LogRotation \t\t\tOn" << endl; 01500 01501 cout << "---------------------------------------------------" << endl 01502 << endl; 01503 }
int CSystemManager::ReadConfiguration | ( | ) | [private] |
Definition at line 390 of file SystemManager.cpp.
00391 { 00392 // Variavel usada para compor o nome do arquivo com a configuracao do 00393 // servidor RIO. 00394 char ConfigFileName[ MaxPathSize ]; 00395 00396 enum keys 00397 { 00398 BlockSize = 1, MaxDisks, MaxSessions, MaxStreams, 00399 MaxOpenObjects, MaxReplications, UseReplications, 00400 MaxDataRequests, MaxPendingRequests, 00401 FileRoot, MetaRoot, UserRoot, TotalRate, NRTReservedRate, 00402 NumberOfBuffersForEachClient, BurstSizeOfEachClient, 00403 NetworkRate, CollectMeasures, 00404 UseServerSideBuffers, UseNewCAC, 00405 EstimatedTimeParameter, 00406 NumberOfEmptyTimes, MaxIntervalEmpty, 00407 GenerateLogs, MaxAttempts, TimeBetweenAttempts, 00408 ClientsTimeOut, MaxLogFileSize, MaxCombinedLogFilesSize, 00409 LogRotation 00410 }; 00411 00412 static struct token_kw mykeys[] = { 00413 {"BlockSize", BlockSize}, 00414 {"MaxDisks", MaxDisks}, 00415 {"MaxSessions", MaxSessions}, 00416 {"MaxStreams", MaxStreams}, 00417 {"MaxOpenObjects", MaxOpenObjects}, 00418 {"MaxReplications", MaxReplications}, 00419 {"UseReplications", UseReplications}, 00420 {"MaxDataRequests", MaxDataRequests}, 00421 {"MaxPendingRequests", MaxPendingRequests}, 00422 {"FileRoot", FileRoot}, 00423 {"MetaRoot", MetaRoot}, 00424 {"UserRoot", UserRoot}, 00425 {"TotalRate", TotalRate}, 00426 {"NRTReservedRate", NRTReservedRate}, 00427 {"NumberOfBuffersForEachClient", NumberOfBuffersForEachClient}, 00428 {"BurstSizeOfEachClient", BurstSizeOfEachClient}, 00429 {"NetworkRate", NetworkRate}, 00430 {"CollectMeasures", CollectMeasures}, 00431 {"UseServerSideBuffers", UseServerSideBuffers}, 00432 {"UseNewCAC", UseNewCAC}, 00433 {"EstimatedTimeParameter", EstimatedTimeParameter}, 00434 {"NumberOfEmptyTimes", NumberOfEmptyTimes}, 00435 {"MaxIntervalEmpty", MaxIntervalEmpty}, 00436 {"GenerateLogs", GenerateLogs}, 00437 // Duas novas opcoes para permitir que o servidor tente se conectar 00438 // mais de uma vez a cada um dos servidores de armazenamento, 00439 // antes de abortar com erro. A opcao MaxAttempts define o numero 00440 // de tentativas e a TimeBetweenAttempts define o tempo (em 00441 // segundos entre duas tentativas consecutivas). 00442 {"MaxAttempts", MaxAttempts}, 00443 {"TimeBetweenAttempts", TimeBetweenAttempts}, 00444 // Nova opcao usada para indicar o tempo maximo que o servidor espera 00445 // por uma requisicao de um cliente. Se a opcao nao for usada, ou se o 00446 // seu valor for 0, entao nao teremos um tempo maximo (como ocorria 00447 // antes). 00448 {"ClientsTimeOut", ClientsTimeOut}, 00449 // Novas opcoes usadas pelo gerenciamento dos logs para limitar o 00450 // tamanho do arquivo de log nao compactado e o tamanho total combinado 00451 // de todos os logs (compactados ou nao). 00452 {"MaxLogFileSize", MaxLogFileSize}, 00453 {"MaxCombinedLogFilesSize", MaxCombinedLogFilesSize}, 00454 // Nova opcao para definir se os logs devem ou nao ser salvos, ou seja, 00455 // se devemos ou nao somente executar buscas nestes logs. 00456 {"LogRotation", LogRotation}, 00457 // Define o final das opcoes. 00458 {NULL, 0} 00459 }; 00460 00461 cout << endl; 00462 token tok; 00463 //tok.setcerr(&cout); 00464 00465 // Alteracao para ler o arquivo de configuracao de um diretorio qualquer, 00466 // diferente de onde o servidor esta. Por default, o arquivo e lido do 00467 // diretorio em que esta o binario do servidor. 00468 // Compoe o nome do arquivo com a configuracao do servidor. 00469 strcpy( ConfigFileName, m_ConfigsDirectory ); 00470 strcat( ConfigFileName, CONFIGNAME ); 00471 00472 if( tok.openfile( ConfigFileName ) ) 00473 return 1; 00474 00475 int word; 00476 int number; 00477 00478 while( ( word = tok.parseline( mykeys )) != END_TOKEN ) 00479 { 00480 switch( word ) 00481 { 00482 case BlockSize: 00483 tok.getnumber(&m_BlockSize); 00484 break; 00485 00486 case MaxDisks: 00487 tok.getnumber(&m_MaxDisks); 00488 break; 00489 00490 case MaxSessions: 00491 tok.getnumber(&m_MaxSessions); 00492 break; 00493 00494 case MaxStreams: 00495 tok.getnumber(&m_MaxStreams); 00496 break; 00497 00498 case MaxOpenObjects: 00499 tok.getnumber(&m_MaxOpenObjects); 00500 break; 00501 00502 case MaxReplications: 00503 tok.getnumber(&m_MaxReplications); 00504 break; 00505 00506 case UseReplications: 00507 tok.getnumber(&m_UseReplications); 00508 break; 00509 00510 case MaxDataRequests: 00511 tok.getnumber(&m_MaxDataRequests); 00512 break; 00513 00514 case MaxPendingRequests: 00515 tok.getnumber(&m_MaxPendingRequests); 00516 break; 00517 00518 case FileRoot: 00519 tok.getstrnew(&m_FileRoot); 00520 break; 00521 00522 case MetaRoot: 00523 tok.getstrnew(&m_MetaRoot); 00524 break; 00525 00526 case UserRoot: 00527 tok.getstrnew(&m_UserRoot); 00528 break; 00529 00530 case TotalRate: 00531 tok.getnumber(&number); 00532 //convert Kbps to bytes/sec 00533 m_MaxRate = ((number * 1000) / 8); 00534 break; 00535 00536 case NRTReservedRate: 00537 tok.getnumber(&number); 00538 //convert Kbps to bytes/sec 00539 m_NRTReservedRate = ((number * 1000) / 8); 00540 break; 00541 00542 case NumberOfBuffersForEachClient: 00543 tok.getnumber(&m_NumberOfBuffersForEachClient); 00544 break; 00545 00546 case BurstSizeOfEachClient: 00547 tok.getnumber(&m_BurstSizeOfEachClient); 00548 break; 00549 00550 case NetworkRate: 00551 tok.getdouble(&m_NetworkRate); 00552 break; 00553 00554 case EstimatedTimeParameter: 00555 tok.getdouble(&m_EstimatedTimeParameter); 00556 break; 00557 00558 case UseServerSideBuffers: 00559 tok.getstrnew(&m_UseServerSideBuffers); 00560 break; 00561 00562 case UseNewCAC: 00563 tok.getstrnew(&m_UseNewCAC); 00564 break; 00565 00566 case CollectMeasures: 00567 tok.getstrnew(&m_CollectMeasures); 00568 break; 00569 00570 case NumberOfEmptyTimes: 00571 tok.getnumber(&m_NumberOfEmptyTimes); 00572 break; 00573 00574 case MaxIntervalEmpty: 00575 tok.getdouble(&m_MaxIntervalEmpty); 00576 break; 00577 // ---------------------------------------------------------------- 00578 case GenerateLogs: 00579 tok.getnumber(&m_GenerateLogs); 00580 break; 00581 // Duas novas opcoes para permitir que o servidor tente se conectar 00582 // mais de uma vez a cada um dos servidores de armazenamento, 00583 // antes de abortar com erro. A opcao MaxAttempts define o numero 00584 // de tentativas e a TimeBetweenAttempts define o tempo (em 00585 // segundos entre duas tentativas consecutivas). 00586 case MaxAttempts: 00587 tok.getnumber(&m_MaxAttempts); 00588 break; 00589 case TimeBetweenAttempts: 00590 tok.getnumber(&m_TimeBetweenAttempts); 00591 break; 00592 // Nova opcao usada para indicar o tempo maximo que o servidor 00593 // espera por uma requisicao de um cliente. Se a opcao nao for 00594 // usada, ou se o seu valor for 0, entao nao teremos um tempo maximo 00595 // (como ocorria antes). 00596 case ClientsTimeOut: 00597 tok.getnumber( &m_ClientsTimeOut ); 00598 break; 00599 // Novas opcoes usadas pelo gerenciamento dos logs para limitar o 00600 // tamanho do arquivo de log nao compactado e o tamanho total 00601 // combinado de todos os logs (compactados ou nao). 00602 case MaxLogFileSize: 00603 // Tamanho do log nao compactado e dado em KB. 00604 tok.getnumber( &number ); 00605 m_MaxLogFileSize = number * 1024; 00606 break; 00607 case MaxCombinedLogFilesSize: 00608 tok.getnumber( &number ); 00609 // Tamanho combinado dos logs e dado em KB. 00610 m_MaxCombinedLogFilesSize = ( ( unsigned long long int ) number ) * 00611 1024; 00612 break; 00613 // Nova opcao para definir se os logs devem ou nao ser salvos, ou 00614 // seja, se devemos ou nao somente executar buscas nestes logs. 00615 case LogRotation: 00616 tok.getstrnew( &m_SaveLogs ); 00617 break; 00618 00619 // Valor para uma opcao invalida. 00620 case ERROR_TOKEN: 00621 char *Aux; 00622 tok.getstrnew( &Aux ); 00623 RioErr << "warning: invalid keyword " << Aux << " ignored!" 00624 << endl; 00625 delete[] Aux; 00626 break; 00627 00628 // Chave invalida. 00629 default: 00630 RioErr << "word " << word << endl; 00631 tok.emsg("{default} invalid word"); 00632 continue; 00633 } 00634 tok.ckend(); 00635 } 00636 tok.closefile(); 00637 return CheckConfiguration(); 00638 }
int CSystemManager::Run | ( | int | DebugFlag, | |
int | FormatFlag, | |||
char * | PrefixDirectory | |||
) |
Definition at line 184 of file SystemManager.cpp.
00185 { 00186 // Inicializa as variaveis com o diretorio onde os arquivos de 00187 // configuracao do servidor e os arquivos com as senhas, e com o 00188 // diretorio onde os logs serao armazenados. 00189 if( PrefixDirectory == NULL ) 00190 { 00191 // Se um prefixo nao foi passado, entao inicializamos os dois 00192 // diretorios com uma string vazia, para que os arquivos sejam 00193 // lidos e salvos no diretorio em que o codigo binario do servidor 00194 // esta armazenado. 00195 m_ConfigsDirectory = new char[ 1 ]; 00196 if( m_ConfigsDirectory == NULL ) 00197 { 00198 RioErr << "CSystemManager::Run Erro ao alocar a memoria" << endl; 00199 return -1; 00200 } 00201 m_LogsDirectory = new char[ 1 ]; 00202 if( m_LogsDirectory == NULL ) 00203 { 00204 RioErr << "CSystemManager::Run Erro ao alocar a memoria" << endl; 00205 delete[] m_ConfigsDirectory; 00206 m_ConfigsDirectory = NULL; 00207 return -1; 00208 } 00209 m_ConfigsDirectory[ 0 ] = 0; 00210 m_LogsDirectory[ 0 ] = 0; 00211 } 00212 else 00213 { 00214 // Devemos agora verificar se o prefixo do nome do diretorio passado 00215 // como parametro possui, no final, uma "/". 00216 unsigned int PrefixDirectorySize, ConfigsDirectorySize, 00217 LogsDirectorySize; 00218 PrefixDirectorySize = strlen( PrefixDirectory ); 00219 ConfigsDirectorySize = PrefixDirectorySize + strlen( CONFIGSSUBDIR ) + 00220 1; 00221 LogsDirectorySize = PrefixDirectorySize + strlen( LOGSSUBDIR ) + 1; 00222 // Verifica se o prefixo do diretorio termina ou nao com uma '/'. 00223 if( PrefixDirectory[ PrefixDirectorySize - 1 ] != '/' ) 00224 { 00225 // Como nao temos uma "/" deveremos coloca-la e, com isso, o 00226 // tamanho de ambos os nomes de diretorio aumentarao em uma 00227 // unidade. 00228 ConfigsDirectorySize++; 00229 LogsDirectorySize++; 00230 } 00231 m_ConfigsDirectory = new char[ ConfigsDirectorySize ]; 00232 if( m_ConfigsDirectory == NULL ) 00233 { 00234 RioErr << "CSystemManager::Run Erro ao alocar a memoria" << endl; 00235 return -1; 00236 } 00237 m_LogsDirectory = new char[ LogsDirectorySize ]; 00238 if( m_LogsDirectory == NULL ) 00239 { 00240 RioErr << "CSystemManager::Run Erro ao alocar a memoria" << endl; 00241 delete[] m_ConfigsDirectory; 00242 m_ConfigsDirectory = NULL; 00243 return -1; 00244 } 00245 strcpy( m_ConfigsDirectory, PrefixDirectory ); 00246 strcpy( m_LogsDirectory, PrefixDirectory ); 00247 if( PrefixDirectory[ PrefixDirectorySize - 1 ] != '/' ) 00248 { 00249 // Como nao temos uma '/' deveremos coloca-la em ambos os nomes 00250 // de diretorio. 00251 strcat( m_ConfigsDirectory, "/" ); 00252 strcat( m_LogsDirectory, "/" ); 00253 } 00254 strcat( m_ConfigsDirectory, CONFIGSSUBDIR ); 00255 strcat( m_LogsDirectory, LOGSSUBDIR ); 00256 } 00257 00258 //Initialize random number generator seed 00259 InitializeRandomNumber(); 00260 00261 // read and check configuration values 00262 // {does not check them against any previous values} 00263 if( ReadConfiguration() ) 00264 { 00265 RioErr << "SystemManager::ReadConfiguration failed" << endl; 00266 RioErr << "Server not running. Check error messages!" << endl; 00267 return -1; 00268 } 00269 00270 if( FormatFlag ) 00271 { 00272 return Format(); 00273 } 00274 00275 //Start monitor table thread 00276 pthread_t monitor_table_thread; 00277 pthread_attr_t attr_monitor_table_thread; 00278 pthread_attr_init( &attr_monitor_table_thread ); 00279 pthread_attr_setstacksize( &attr_monitor_table_thread, 00280 2*PTHREAD_STACK_MIN ); 00281 00282 pthread_create( &monitor_table_thread, &attr_monitor_table_thread, 00283 CSystemManager::MonitorTableTrigger, (void *)this ); 00284 00285 int rc; 00286 rc = Start(); // start things up 00287 if( rc ) 00288 { 00289 RioErr << "Server not running. Check error messages!" << endl; 00290 return -1; 00291 } 00292 else 00293 { 00294 // now let things run... 00295 cout << endl; 00296 cout << " LAND/COPPE - UFRJ" << endl<<endl; 00297 cout << " RIO Multimedia Storage Server" << endl; 00298 cout << " Running ..." << endl; 00299 } 00300 // ------------------------------------------------------------------------ 00301 00302 pthread_join( monitor_table_thread, NULL ); 00303 00304 //the following loop is probably unnecessary, since the thread above is 00305 //supposed to never quit 00306 /*while( 1 ) 00307 { 00308 sleep( 10 ); 00309 }*/ 00310 00311 return 0; 00312 }
void CSystemManager::SetNumberOfDisks | ( | unsigned int | NumberOfDisks | ) |
Funcao para alterar o valor do numero de discos do servidor.
Ela foi necessaria porque, quando os servidores de armazenamento inicializam apos o servidor.
NumberOfDisks | novo numero de discos. |
Definition at line 1546 of file SystemManager.cpp.
01547 { 01548 // Somente devemos executar este metodo se a classe CSessionManagerja foi 01549 // criada e inicializada. 01550 if( m_SessionManager != NULL ) 01551 m_SessionManager->SetNumberOfDisks( NumberOfDisks ); 01552 else 01553 RioErr << "CSystemManager::SetNumberOfDisks aviso a funcao foi chamada " 01554 << "antes da criacao e inicializacao do objecto da classe " 01555 << "CSessionManager" << endl; 01556 // Somente devemos executar este metodo se a classe CStreamManager ja foi 01557 // criada e inicializada. 01558 if( m_StreamManager != NULL ) 01559 m_StreamManager->SetNumberOfDisks( NumberOfDisks ); 01560 else 01561 RioErr << "CSystemManager::SetNumberOfDisks aviso a funcao foi chamada " 01562 << "antes da criacao e inicializacao do objecto da classe " 01563 << "CStreamManager" << endl; 01564 }
int CSystemManager::Start | ( | void | ) | [private] |
Definition at line 904 of file SystemManager.cpp.
00905 { 00906 int hResult; 00907 00908 #ifdef RIO_DEBUG1 00909 RioErr << "### [CSystemManager - Start] Start" << endl; 00910 #endif 00911 00912 // Initialize EventManager 00913 // Initialize allocates space for each type of event 00914 // The number of events of each type can not exceed the maximum 00915 // set at Initialization. Attempting to do so will block 00916 // the asking thread until one event of that type is freed by 00917 // other thread. If these values are too small system performance 00918 // may be degraded, since threads will be blocked waiting 00919 // for event entries 00920 00921 EventManager.Initialize(EventTypeStorageRequest, 2*m_MaxDisks); 00922 EventManager.Initialize(EventTypeStorageReply, 2*m_MaxDisks); 00923 EventManager.Initialize(EventTypeAddDisk, m_MaxDisks); 00924 00925 // Inicializa os novos eventos para tratar da queda/reinicio dos servidores 00926 // de armazenamento. 00927 EventManager.Initialize( EventTypeStorageDown, MAXNUMSTORAGES ); 00928 EventManager.Initialize( EventTypeStorageUp, MAXNUMSTORAGES ); 00929 00930 // Inicializa os novos eventos para tratar do termino das threads que usem 00931 // uma fila. 00932 EventManager.Initialize( EventTypeFinalizeThread, 1 ); 00933 00934 Timer.Initialize (NUMBER_OF_TIMERS); 00935 00936 // Create, initialize and start DiskMgr 00937 cout << "Starting Disk Manager ....... "; 00938 #ifdef RIO_DEBUG2 00939 RioErr << "Starting Disk Manager ....... " << endl; 00940 #endif 00941 hResult = StartDiskMgr(0); 00942 if( hResult ) 00943 { 00944 cout << "failed "<<endl; 00945 RioErr << "Start Disk Manager failed" << endl; 00946 FreeMembers(); 00947 return hResult; 00948 } 00949 00950 // Create and start Object Manager 00951 cout << "Starting User Manager ..... "; 00952 #ifdef RIO_DEBUG2 00953 RioErr << "Starting User Manager ..... " << endl; 00954 #endif 00955 // Create and start User Manager 00956 hResult = StartUserManager(); 00957 if( hResult ) 00958 { 00959 cout << "failed "<<endl; 00960 RioErr << "Start User Manager failed" << endl; 00961 FreeMembers(); 00962 return hResult; 00963 } 00964 cout << "OK "<<endl; 00965 00966 // Create and start Object Manager 00967 cout << "Starting Object Manager ..... "; 00968 #ifdef RIO_DEBUG2 00969 RioErr << "Starting Object Manager ..... " << endl; 00970 #endif 00971 hResult = StartObjectManager(); 00972 if( hResult ) 00973 { 00974 cout << "failed "<<endl; 00975 RioErr << "Start Object Manager failed" << endl; 00976 FreeMembers(); 00977 return hResult; 00978 } 00979 cout << "OK "<<endl; 00980 00981 // Create and start Router 00982 cout << "Starting Router ............. "; 00983 #ifdef RIO_DEBUG2 00984 RioErr << "Starting Router ............. " << endl; 00985 #endif 00986 hResult = StartRouter(); 00987 if( hResult ) 00988 { 00989 cout << "failed "<<endl; 00990 RioErr << "Start Router failed" << endl; 00991 FreeMembers(); 00992 return hResult; 00993 } 00994 cout << "OK "<<endl; 00995 00996 // Create and start Stream Manager 00997 cout << "Starting Stream Manager ..... "; 00998 #ifdef RIO_DEBUG2 00999 RioErr << "Starting Stream Manager ..... " << endl; 01000 #endif 01001 hResult = StartStreamManager(); 01002 if( hResult ) 01003 { 01004 cout << "failed "<<endl; 01005 RioErr << "Start Stream Manager failed" << endl; 01006 FreeMembers(); 01007 return hResult; 01008 } 01009 cout << "OK "<<endl; 01010 01011 // Create and start Session Manager 01012 cout << "Starting Session Manager .... "; 01013 #ifdef RIO_DEBUG2 01014 RioErr << "Starting Session Manager .... " << endl; 01015 #endif 01016 hResult = StartSessionManager(); 01017 if( hResult ) 01018 { 01019 cout << "failed "<<endl; 01020 RioErr << "Start Session Manager failed" << endl; 01021 FreeMembers(); 01022 return hResult; 01023 } 01024 cout << "OK "<<endl; 01025 01026 m_started = true; 01027 01028 #ifdef RIO_DEBUG1 01029 RioErr << "### [CSystemManager - Start] End" << endl; 01030 #endif 01031 01032 return 0; 01033 }
int CSystemManager::StartConnectionManager | ( | ) | [private] |
int CSystemManager::StartDiskMgr | ( | int | formatflag | ) | [private] |
Definition at line 1036 of file SystemManager.cpp.
01037 { 01038 int hResult; 01039 01040 // create Router first and Initialize but don't start 01041 m_Router = new CRouter; 01042 01043 // must pass DiskMgr to router too so make it now (but don't init yet) 01044 m_DiskMgr = new DiskMgr; 01045 01046 // Initialize Router Config data 01047 RouterConfig Config; 01048 Config.nDisks = m_MaxDisks; 01049 Config.BlockSize = m_BlockSize; 01050 Config.MaxDataRequests = m_MaxDataRequests; 01051 Config.MaxPending = m_MaxPendingRequests; 01052 Config.CollectMeasures = (( strcasecmp( m_CollectMeasures, "on" ) == 0 )|| 01053 ( strcasecmp( m_UseNewCAC, "on" ) == 0 ))? true:false; 01054 Config.EstimatedTimeParameter = m_EstimatedTimeParameter; 01055 // O parametro m_DiskMgr agora esta na estrutura RouterConfig ao inves de 01056 // ser passado como parametro. 01057 Config.DiskManager = m_DiskMgr; 01058 Config.SystemManager = this; 01059 // Somente deveremos inicializar o campo LogdDirectory da estrutura 01060 // RouterConfig, para passar o nome do diretorio usados para salvar os 01061 // logs da classe, somente se a opcao __QUEUE_RESP_LOG estiver habilitada. 01062 #ifdef __QUEUE_RESP_LOG 01063 Config.LogsDirectory = m_LogsDirectory; 01064 #endif 01065 01066 hResult = m_Router->Initialize( &Config ); 01067 01068 if( hResult ) 01069 { 01070 RioErr << "Start(): Failed to initialize Router" 01071 << ". hresult=" << hResult << endl; 01072 delete m_Router; 01073 m_Router = 0; 01074 return hResult; 01075 } 01076 01077 // Initialize DiskMgr Config data 01078 DiskMgrConfig ConfigDisk; 01079 ConfigDisk.BlockSize = m_BlockSize; 01080 ConfigDisk.MaxDisks = m_MaxDisks; 01081 ConfigDisk.MetaRoot = m_MetaRoot; 01082 ConfigDisk.router = m_Router; 01083 ConfigDisk.manager = this; 01084 ConfigDisk.GenerateLogs = m_GenerateLogs; 01085 ConfigDisk.MaxReps = m_UseReplications; 01086 ConfigDisk.ConfigsDirectory = m_ConfigsDirectory; 01087 ConfigDisk.LogsDirectory = m_LogsDirectory; 01088 ConfigDisk.MaxAttempts = m_MaxAttempts; 01089 ConfigDisk.TimeBetweenAttempts = m_TimeBetweenAttempts; 01090 // Inicializa a variavel booleana que indica se estamos formatando os discos 01091 // do RIO. 01092 ConfigDisk.IsFormatting = ( formatflag != 0 ); 01093 01094 hResult = m_DiskMgr->Initialize( &ConfigDisk ); 01095 01096 if( hResult ) 01097 { 01098 RioErr << "SystemManager.StartDiskMgr: DiskMgr.Initialize failed." 01099 << endl; 01100 return hResult; 01101 } 01102 01103 // ### if formating don't start DiskMgr (which would try to load 01104 // up old metadata, instead just return (and call DiskMgr.Format) 01105 if( formatflag ) 01106 return 0; 01107 01108 hResult = m_DiskMgr->Start(); 01109 if( hResult ) 01110 { 01111 RioErr << "SystemManager.StartDiskMgr: DiskMgr.Start failed." << endl; 01112 return hResult; 01113 } 01114 01115 return 0; 01116 }
int CSystemManager::StartObjectManager | ( | ) | [private] |
Definition at line 1119 of file SystemManager.cpp.
01120 { 01121 // create to object manager 01122 m_objectManager = new CObjectManager; 01123 01124 // Initialize Object Manager Config data 01125 ObjectManagerConfig ObjectConfig; 01126 ObjectConfig.BlockSize = m_BlockSize; 01127 ObjectConfig.FileRoot = m_FileRoot; 01128 ObjectConfig.MaxNhandle = m_MaxOpenObjects; 01129 ObjectConfig.MaxReplications = m_MaxReplications; 01130 ObjectConfig.UseReplications = m_UseReplications; 01131 ObjectConfig.c_DiskMgr = m_DiskMgr; 01132 ObjectConfig.UserManager = m_UserManager; 01133 // Iniciaiza os novos campos da estrutura ObjectManagerConfig, com os 01134 // valores de m_GenerateLogs (passado antes como parametro) e 01135 // m_LogsDirectory (o novo parametro que define onde o log da classe devera 01136 // ser salvo). 01137 ObjectConfig.GenerateLogs = m_GenerateLogs; 01138 ObjectConfig.LogsDirectory = m_LogsDirectory; 01139 01140 // Initialize object manager 01141 // Mudanca na passagem de parametro ao inicializar a classe ObjectManager, 01142 // pois agora o campo m_GenerateLogs esta dentro da estrutura 01143 // ObjectManagerConfig. 01144 int hResult = m_objectManager->Initialize( &ObjectConfig ); 01145 if( hResult ) 01146 { 01147 RioErr << "Start(): Failed to initialize object manager" 01148 << ". hresult=" << hResult << endl; 01149 delete m_objectManager; 01150 m_objectManager = 0; 01151 return hResult; 01152 } 01153 01154 hResult = m_objectManager->Start(); 01155 if( hResult ) 01156 { 01157 RioErr << "Start(): Failed to start object manager" 01158 << ". hresult=" << hResult << endl; 01159 delete m_objectManager; 01160 m_objectManager = 0; 01161 return hResult; 01162 } 01163 01164 return 0; 01165 }
int CSystemManager::StartRouter | ( | ) | [private] |
Definition at line 1168 of file SystemManager.cpp.
01169 { 01170 01171 // already created & init -- just start 01172 int hResult = m_Router->Start(); 01173 if( hResult ) 01174 { 01175 RioErr << "Start(): Failed to initialize Router" 01176 << ". hresult=" << hResult << endl; 01177 delete m_Router; 01178 m_Router = 0; 01179 return hResult; 01180 } 01181 01182 return 0; 01183 }
int CSystemManager::StartSessionManager | ( | ) | [private] |
Definition at line 1272 of file SystemManager.cpp.
01273 { 01274 // create Session Manager 01275 m_SessionManager = new CSessionManager; 01276 01277 // Initialize Session Manager Config data 01278 SessionManagerConfig Config; 01279 Config.MaxSessions = m_MaxSessions; 01280 Config.BlockSize = m_BlockSize; 01281 Config.StreamManager = m_StreamManager; 01282 Config.ObjectManager = m_objectManager; 01283 Config.UserManager = m_UserManager; 01284 Config.Router = m_Router; 01285 Config.SystemManager = this; 01286 01287 //added to support df command ---------------------------------- 01288 Config.diskMgr = m_DiskMgr; 01289 m_DiskMgr->GetNumberOfActiveDisks( &Config.NumberOfDisks ); 01290 m_DiskMgr->GetNumberOfStorageNodes( &Config.NumberOfStorageNodes ); 01291 // ------------------------------------------------------------------------ 01292 01293 Config.FileRoot = m_FileRoot; 01294 // ------------------------------------------------------------------------ 01295 // Iniciaiza os novos campos da estrutura ObjectManagerConfig, com os 01296 // valores de m_GenerateLogs (passado antes como parametro) e 01297 // m_LogsDirectory (o novo parametro que define onde o log da classe devera 01298 // ser salvo). 01299 Config.GenerateLogs = m_GenerateLogs; 01300 Config.LogsDirectory = m_LogsDirectory; 01301 // Inicializa o novo campo usado para indicar o tempo maximo que o servidor 01302 // espera por uma requisicao de um cliente. Se a opcao nao for usada, ou se 01303 // o seu valor for 0, entao nao teremos um tempo maximo (como ocorria 01304 // antes). 01305 Config.ClientsTimeOut = m_ClientsTimeOut; 01306 // Novos parametros usados pela classe de controle de logs para limitar o 01307 // tamanho do arquivo nao compactado e o tamanho maximo dos arquivos com 01308 // os logs. 01309 Config.MaxLogFileSize = m_MaxLogFileSize; 01310 Config.MaxCombinedLogFilesSize = m_MaxCombinedLogFilesSize; 01311 // Inicializa a nova variavel usada para indicar se o salvamento dos logs 01312 // esta ou nao habilitado 01313 Config.SaveLogs = ( ( m_SaveLogs == NULL ) || 01314 ( strcasecmp( m_SaveLogs, "on" ) == 0 ) ); 01315 01316 // Initialize Session Manager 01317 // Mudanca na passagem de parametro ao inicializar a classe CSessionManager, para 01318 // passar nome do diretorio em que salvamos o log da classe. 01319 int hResult = m_SessionManager->Initialize( &Config ); 01320 if( hResult ) 01321 { 01322 RioErr << "Start(): Failed to initialize Session Manager" 01323 << ". hresult=" << (int *)hResult << endl; 01324 delete m_SessionManager; 01325 m_SessionManager = 0; 01326 return hResult; 01327 } 01328 01329 return 0; 01330 }
int CSystemManager::StartStreamManager | ( | ) | [private] |
Definition at line 1186 of file SystemManager.cpp.
01187 { 01188 #ifdef RIO_DEBUG1 01189 RioErr << "### [CSystemManager - StartStreamManager] Start" << endl; 01190 #endif 01191 01192 // create Stream Manager 01193 m_StreamManager = new CStreamManager; 01194 01195 // Initialize Stream Manager Config data 01196 StreamManagerConfig Config; 01197 Config.BlockSize = m_BlockSize; 01198 Config.MaxStreams = m_MaxStreams; 01199 Config.TotalRate = m_MaxRate; 01200 Config.NRTReservedRate = m_NRTReservedRate; 01201 Config.FileRoot = m_FileRoot; 01202 01203 Config.MaxPending = m_MaxPendingRequests; 01204 Config.NumberOfBuffersForEachClient = m_NumberOfBuffersForEachClient; 01205 Config.BurstSizeOfEachClient = m_BurstSizeOfEachClient; 01206 Config.NetworkRate = m_NetworkRate; 01207 Config.EstimatedTimeParameter = m_EstimatedTimeParameter; 01208 Config.NumberOfEmptyTimes = m_NumberOfEmptyTimes; 01209 Config.MaxIntervalEmpty = m_MaxIntervalEmpty; 01210 if( strcasecmp( m_UseNewCAC, "on" ) == 0 ) 01211 { 01212 Config.UseNewCAC = true; 01213 Config.UseServerSideBuffers = true; 01214 Config.CollectMeasures = true; 01215 } 01216 else 01217 { 01218 Config.UseNewCAC = false; 01219 Config.UseServerSideBuffers = ( strcasecmp( m_UseServerSideBuffers, "on" ) == 0 )? true:false; 01220 Config.CollectMeasures = ( strcasecmp( m_CollectMeasures, "on" ) == 0 )? true:false; 01221 } 01222 01223 //Config.MaxDiskQueueSize = 20; 01224 Config.MaxDiskQueueSize = m_MaxDataRequests; 01225 Config.ExtraStreamRequests = 3; 01226 //Config.nDisks = m_MaxDisks; 01227 unsigned int nDisks; 01228 //m_DiskMgr->GetNumberOfActiveDisks( &nDisks ); 01229 m_DiskMgr->GetNumberOfNeededDisks( &nDisks ); 01230 Config.nDisks = nDisks; 01231 #ifdef RIO_DEBUG2 01232 RioErr << "### [CSystemManager - StartStreamManager] Numero de discos " 01233 << Config.nDisks << endl; 01234 #endif 01235 01236 Config.ObjectManager = m_objectManager; 01237 Config.Router = m_Router; 01238 Config.SystemManager = this; 01239 01240 // Iniciaiza os novos campos da estrutura ObjectManagerConfig, com os 01241 // valores de m_GenerateLogs (passado antes como parametro) e 01242 // m_LogsDirectory (o novo parametro que define onde o log da classe devera 01243 // ser salvo). 01244 Config.GenerateLogs = m_GenerateLogs; 01245 Config.LogsDirectory = m_LogsDirectory; 01246 01247 // Inicializa a noca variavel usada para armazenar o tempo maximo de 01248 // inatividade de uma conexao TCP antes de ela ser fechada por timeout. 01249 Config.ClientsTimeOut = m_ClientsTimeOut; 01250 01251 // Initialize Stream Manager 01252 // Mudanca na passagem de parametro ao inicializar a classe StreamManager, 01253 // para passar o nome do diretorio em que salvamos o log da classe. 01254 int hResult = m_StreamManager->Initialize( &Config ); 01255 if( hResult ) 01256 { 01257 RioErr << "Start(): Failed to initialize Stream Manager" 01258 << ". hresult=" << (int *)hResult << endl; 01259 delete m_StreamManager; 01260 m_StreamManager = 0; 01261 return hResult; 01262 } 01263 01264 #ifdef RIO_DEBUG1 01265 RioErr << "### [CSystemManager - StartStreamManager] End" << endl; 01266 #endif 01267 01268 return 0; 01269 }
int CSystemManager::StartUserManager | ( | ) | [private] |
Definition at line 1333 of file SystemManager.cpp.
01334 { 01335 // create Session Manager 01336 m_UserManager = new CUserManager; 01337 01338 // Initialize CUserManager Config data 01339 UserManagerConfig Config; 01340 Config.UserRoot = m_UserRoot; 01341 Config.FileRoot = m_FileRoot; 01342 Config.GenerateLogs = m_GenerateLogs; 01343 Config.ConfigsDirectory = m_ConfigsDirectory; 01344 Config.LogsDirectory = m_LogsDirectory; 01345 01346 // Initialize User Manager 01347 int hResult = m_UserManager->Initialize( &Config ); 01348 if( hResult ) 01349 { 01350 RioErr << "Start(): Failed to initialize User Manager" 01351 << ". hresult=" << (int *)hResult << endl; 01352 01353 delete m_UserManager; 01354 01355 m_UserManager = 0; 01356 return hResult; 01357 } 01358 01359 return 0; 01360 }
int CSystemManager::Stop | ( | void | ) |
Funcao que para todos os modulos do servidor RIO.
Agora a funcao e publica porque precisamos parar estes modulos quando recebermos o sinal SIGTERM.
Definition at line 1363 of file SystemManager.cpp.
01364 { 01365 // make sure we are started 01366 01367 if( !m_started ) 01368 { 01369 RioErr << "stop(): System Manager not started" << endl; 01370 return ERROR_SYSTEMMANAGER + ERROR_NOT_STARTED; 01371 } 01372 01373 m_started = false; 01374 return FreeMembers(); 01375 }
int CSystemManager::m_BlockSize [private] |
Definition at line 44 of file SystemManager.h.
int CSystemManager::m_BurstSizeOfEachClient [private] |
Definition at line 60 of file SystemManager.h.
int CSystemManager::m_ClientsTimeOut [private] |
Definition at line 101 of file SystemManager.h.
char* CSystemManager::m_CollectMeasures [private] |
Definition at line 62 of file SystemManager.h.
char* CSystemManager::m_ConfigsDirectory [private] |
Definition at line 89 of file SystemManager.h.
CConnectionManager* CSystemManager::m_ConnectionManager [private] |
Definition at line 80 of file SystemManager.h.
DiskMgr* CSystemManager::m_DiskMgr [private] |
Definition at line 75 of file SystemManager.h.
double CSystemManager::m_EstimatedTimeParameter [private] |
Definition at line 66 of file SystemManager.h.
char* CSystemManager::m_FileRoot [private] |
Definition at line 50 of file SystemManager.h.
int CSystemManager::m_GenerateLogs [private] |
Definition at line 72 of file SystemManager.h.
bool CSystemManager::m_initialized [private] |
Definition at line 83 of file SystemManager.h.
char* CSystemManager::m_LogsDirectory [private] |
Definition at line 92 of file SystemManager.h.
int CSystemManager::m_MaxAttempts [private] |
Definition at line 96 of file SystemManager.h.
unsigned long long int CSystemManager::m_MaxCombinedLogFilesSize [private] |
Definition at line 108 of file SystemManager.h.
int CSystemManager::m_MaxDataRequests [private] |
Definition at line 48 of file SystemManager.h.
int CSystemManager::m_MaxDisks [private] |
Definition at line 45 of file SystemManager.h.
double CSystemManager::m_MaxIntervalEmpty [private] |
Definition at line 67 of file SystemManager.h.
unsigned int CSystemManager::m_MaxLogFileSize [private] |
Definition at line 104 of file SystemManager.h.
int CSystemManager::m_MaxNumberAtDiskQueueToEachClient [private] |
Definition at line 61 of file SystemManager.h.
int CSystemManager::m_MaxOpenObjects [private] |
Definition at line 55 of file SystemManager.h.
int CSystemManager::m_MaxPendingRequests [private] |
Definition at line 49 of file SystemManager.h.
double CSystemManager::m_MaxRate [private] |
Definition at line 56 of file SystemManager.h.
int CSystemManager::m_MaxReplications [private] |
Definition at line 46 of file SystemManager.h.
int CSystemManager::m_MaxSessions [private] |
Definition at line 53 of file SystemManager.h.
int CSystemManager::m_MaxStreams [private] |
Definition at line 54 of file SystemManager.h.
char* CSystemManager::m_MetaRoot [private] |
Definition at line 51 of file SystemManager.h.
MonitorTable CSystemManager::m_MonitorTable [private] |
Definition at line 131 of file SystemManager.h.
double CSystemManager::m_NetworkRate [private] |
Definition at line 65 of file SystemManager.h.
double CSystemManager::m_NRTReservedRate [private] |
Definition at line 57 of file SystemManager.h.
int CSystemManager::m_NumberOfBuffersForEachClient [private] |
Definition at line 59 of file SystemManager.h.
int CSystemManager::m_NumberOfEmptyTimes [private] |
Definition at line 68 of file SystemManager.h.
CObjectManager* CSystemManager::m_objectManager [private] |
Definition at line 76 of file SystemManager.h.
CRouter* CSystemManager::m_Router [private] |
Definition at line 77 of file SystemManager.h.
char* CSystemManager::m_SaveLogs [private] |
Definition at line 111 of file SystemManager.h.
CSessionManager* CSystemManager::m_SessionManager [private] |
Definition at line 79 of file SystemManager.h.
bool CSystemManager::m_started [private] |
Definition at line 84 of file SystemManager.h.
CStreamManager* CSystemManager::m_StreamManager [private] |
Definition at line 78 of file SystemManager.h.
int CSystemManager::m_TimeBetweenAttempts [private] |
Definition at line 97 of file SystemManager.h.
char* CSystemManager::m_UseNewCAC [private] |
Definition at line 64 of file SystemManager.h.
int CSystemManager::m_UseReplications [private] |
Definition at line 47 of file SystemManager.h.
CUserManager* CSystemManager::m_UserManager [private] |
Definition at line 81 of file SystemManager.h.
char* CSystemManager::m_UserRoot [private] |
Definition at line 52 of file SystemManager.h.
char* CSystemManager::m_UseServerSideBuffers [private] |
Definition at line 63 of file SystemManager.h.