#include <SessionManager.h>
Public Member Functions | |
CSessionManager (CRioTCP *TCPconnection) | |
~CSessionManager () | |
HRESULT | Open (const char *Username, const char *Password, RioSessionId *Session) |
HRESULT | Close (const RioSessionId Session) |
HRESULT | OpenStream (const RioSessionId Session, const RioStreamTraffic *Traffic, RioStreamId *Stream, int *MaxRequests) |
HRESULT | CreateObject (const RioSessionId Session, const char *ObjectName, const short Type) |
HRESULT | DeleteObject (const RioSessionId Session, const char *ObjectName) |
HRESULT | RenameObject (const RioSessionId Session, const char *CurrentName, const char *NewName) |
HRESULT | GetBlockSize (const RioSessionId Session, unsigned int *BlockSize) |
HRESULT | GetnStorageNodes (const RioSessionId Session, short *nStorageNodes) |
HRESULT | FirstObject (RioSessionId Session, signed char *DirectoryName, ObjectHandle *Handle, int *IsDirectory, int BufferSize, signed char *ObjectName) |
HRESULT | ChangeDir (RioSessionId Session, signed char *Dir) |
HRESULT | GetCurrentDir (RioSessionId Session, int size, signed char *Dir) |
HRESULT | GetObjectInfo (RioSessionId Session, const char *ObjectName, ObjectInfo *ObjectInfo) |
HRESULT | GetNumberOfDisks (const RioSessionId Session, unsigned int *NumberOfDisks) |
HRESULT | GetNumberOfStorageNodes (const RioSessionId Session, unsigned int *NumberOfStorageNodes) |
HRESULT | GetStorageNodeInfo (RioSessionId Session, RioStorageNodeInfo *StorageNodeInfo, unsigned int StorageNodeIndex) |
HRESULT | SendNATMappings (int *addrs, int *ports, unsigned int size) |
HRESULT | GetMonitorTable (char *UserName, vector< ClientData > *client_data, vector< StorageData > *storage_data) |
HRESULT | GetNumberOfActiveAndMaxSessions (const RioSessionId Session, unsigned int *NumberOfActiveSessions, unsigned int *NumberOfMaxSessions) |
HRESULT | SaveMeasures (const RioSessionId Session) |
HRESULT | GetRTT (struct timeval *RTT_openConnection, struct timeval *RTT_openStream) |
HRESULT | GetAverageRTT (struct timeval *average_RTT) |
HRESULT | GetServerAddress (struct sockaddr_in **ServerAddress, unsigned int *ServerAddressSize) |
Esta funcao faz uma chamada remota a um procedimento do Servidor RIO para obter todos os pares IP, porta para os quais precisaremos enviar periodicamente mensagens Fake para garantir que os enderecos associados ao mapeamento continuarao validos. | |
HRESULT | CheckStreamControl (bool *IsImplemented) |
Esta funcao faz uma chamada remota a um procedimento do Servidor RIO para verificar se a versao do servidor suporta o controle de fluxo. | |
HRESULT | SearchLogsRequest (unsigned int SearchType, time_t StartTime, time_t EndTime, int ServerIP, int ServerPort, int ClientIP, int ClientPort, int ReqId) |
Nova funcao para solicitar uma busca em um conjunto de logs de um dos servidores. | |
HRESULT | ResultFileBlockRequest (int ServerIP, int ServerPort, int ClientIP, int ClientPort, unsigned long long int ResultFileId, unsigned int Block, int ReqId) |
Nova funcao para ler um bloco do arquivo com os resultados da busca. | |
HRESULT | RemoveResultFile (int ServerIP, int ServerPort, unsigned long long int ResultFileId) |
Nova funcao para informar ao servidor que o arquivo com o resultado da busca pode ser removido. | |
HRESULT | CreateUser (char *UserName, char *Password) |
Nova funcao para criar um usuario. | |
HRESULT | RemoveUser (char *UserName) |
Nova funcao para remover a senha do usuario. | |
HRESULT | ChangePassword (char *UserName, char *Password) |
Nova funcao para alterar a senha de um usuario. | |
HRESULT | GetUserList (vector< string > &UserList) |
Nova funcao para obter a lista com todos os usuarios. | |
CSessionManager () | |
~CSessionManager () | |
int | SaveMeasures () |
int | Initialize (SessionManagerConfig *Config) |
void | InvalidateStorageNatMappings (int StorageId) |
Funcao para invalidar todos os mapeamentos dos clientes conectados para um servidor de armazenamento identificado pela ID passada como parametro. | |
void | SetNumberOfDisks (unsigned int NumberOfDisks) |
Funcao para alterar o valor do numero de discos do servidor. | |
Private Member Functions | |
int | CleanUp () |
void | PostITEvent (MonitorEvent *event) |
void | GetMonitorTable (vector< ClientData > &, vector< StorageData > &) |
void | KillConnectionThread () |
void | SetNATMapping (NATData server_map, int stor_id, NATData stor_map) |
SetNATMapping informa ao Router o mapeamento NAT de um cliente com um storage. | |
int | GetVideoDuration (char *VideoName) |
Le do arquivo cactimes que contem o tempo para tocar cada bloco do video. | |
Static Private Member Functions | |
static void * | ConnectionThread (void *param) |
static void * | ClientThread (void *param) |
Private Attributes | |
CRioTCP * | m_TCPconnection |
struct timeval m_RTT_openConnection | m_RTT_openStream |
unsigned int | m_BlockSize |
unsigned int | m_NumberOfDisks |
unsigned int | m_NumberOfStorageNodes |
DiskMgr * | m_DiskMgr |
char * | m_FileRoot |
int | m_MaxSessions |
CSystemManager * | m_SystemManager |
CStreamManager * | m_StreamManager |
CObjectManager * | m_ObjectManager |
CUserManager * | m_UserManager |
CRouter * | m_Router |
NetMgr * | m_NetMgr |
CNetInterface * | m_NetInterface |
int | m_used |
SessionEntry * | m_SessionTable |
pthread_mutex_t | m_mutex |
bool | m_initialized |
ofstream | m_log |
pthread_t | m_ConnectionThreadId |
bool | m_threadStopEvent |
SOCKADDR_IN * | m_ServerAddress |
unsigned int | m_ServerAddressSize |
int | m_ClientsTimeOut |
CLogRotation * | m_LogRotation |
char * | m_LogsDirectory |
CSearchLogs * | m_SearchLogs |
Friends | |
class | RioSession |
Definition at line 34 of file interface/SessionManager.h.
CSessionManager::CSessionManager | ( | CRioTCP * | TCPconnection | ) |
Definition at line 43 of file interface/SessionManager.cpp.
00044 { 00045 m_TCPconnection = TCPconnection; 00046 #ifdef WINDOWS 00047 m_RTT_openConnection.wSecond = 0; 00048 m_RTT_openConnection.wMilliseconds = 0; 00049 m_RTT_openStream.wSecond = 0; 00050 m_RTT_openStream.wMilliseconds = 0; 00051 #else 00052 m_RTT_openConnection.tv_sec = 0; 00053 m_RTT_openConnection.tv_usec = 0; 00054 m_RTT_openStream.tv_sec = 0; 00055 m_RTT_openStream.tv_usec = 0; 00056 #endif 00057 }
CSessionManager::~CSessionManager | ( | ) |
Definition at line 59 of file interface/SessionManager.cpp.
CSessionManager::CSessionManager | ( | ) |
Definition at line 85 of file server/SessionManager.cpp.
00086 { 00087 m_BlockSize = 0; 00088 m_NumberOfDisks = 0; 00089 m_NumberOfStorageNodes = 0; 00090 m_DiskMgr = NULL; 00091 m_FileRoot = NULL; 00092 m_MaxSessions = 0; 00093 m_StreamManager = NULL; 00094 m_ObjectManager = NULL; 00095 m_SystemManager = NULL; 00096 m_UserManager = NULL; 00097 m_Router = NULL; 00098 m_TCPconnection = NULL; 00099 m_NetMgr = NULL; 00100 m_used = 0; 00101 m_SessionTable = NULL; 00102 pthread_mutex_init( &m_mutex, NULL ); 00103 m_initialized = false; 00104 // m_log does not to be initialized 00105 m_ConnectionThreadId = 0; 00106 m_threadStopEvent = false; 00107 00108 // Inicializa as variaveis m_ServerAddress e m_ServerAddressSize. Usado 00109 // pelo suporte aos clientes atras de NAT. 00110 m_ServerAddress = NULL; 00111 m_ServerAddressSize = 0; 00112 00113 // Inicializacao do novo parametro usado para indicar o tempo maximo que o 00114 // servidor espera por uma requisicao de um cliente. 00115 m_ClientsTimeOut = 0; // Nao usa o timeout, isto e, igual ao que ocorria 00116 // anteriormente. 00117 00118 // Inicializa o ponteiro para o objeto com os logs de acesso dos clientes 00119 m_LogRotation = NULL; 00120 00121 // Inicializa o ponteiro para o objeto que faz as buscas nos logs de acesso 00122 // dos clientes 00123 m_SearchLogs = NULL; 00124 00125 // Inicializa o ponteiro da nova classe de gerenciamento de rede. 00126 m_NetInterface = NULL; 00127 }
CSessionManager::~CSessionManager | ( | ) |
HRESULT CSessionManager::ChangeDir | ( | RioSessionId | Session, | |
signed char * | Dir | |||
) |
Definition at line 1031 of file interface/SessionManager.cpp.
01032 { 01033 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01034 char *Result; 01035 unsigned int ParameterSize; 01036 unsigned int ResultSize; 01037 HRESULT status; 01038 01039 if( Parameter == NULL ) 01040 { 01041 RioErr << "malloc error ChangeDir:" << strerror(errno) << endl; 01042 free( Parameter ); 01043 01044 return ERROR_RIOPROXY + ERROR_MEMORY; 01045 } 01046 01047 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01048 01049 ParameterSize = 2 * MAX_LONG_STRING_SIZE + strlen ( ( char * )Dir )+1 + 1; 01050 // Check if Parameter buffer is large enough 01051 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01052 { 01053 free( Parameter ); 01054 01055 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01056 } 01057 01058 int offset = 0; 01059 01060 // Set parameters on asii buffer 01061 // Set Session Id 01062 SetLong( Parameter,Session.Version,&offset ); 01063 SetLong( Parameter,Session.Index,&offset ); 01064 01065 // Set Directory name 01066 SetString( Parameter,( char * )Dir,&offset ); 01067 01068 // Update Parameter size to actual size 01069 // ( previously was maximum possible size ) 01070 ParameterSize = offset; 01071 01072 // Set Maximum result size ( Size of buffer ) 01073 ResultSize = MaxTCPDataSize; 01074 01075 // Call remote method 01076 status = m_TCPconnection->Call( RioClassSessionManager, 01077 RioMethodSessionManagerChangeDir, 01078 ParameterSize, 01079 Parameter, 01080 &ResultSize, 01081 &Result ); 01082 01083 01084 // check if call failed 01085 if( FAILED( status ) ) 01086 { 01087 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01088 status = ERROR_RIOPROXY + ERROR_MEMORY; 01089 if( Result != NULL ) 01090 free( Result ); 01091 free( Parameter ); 01092 01093 return status; 01094 } 01095 01096 offset = 0; 01097 // Get results from result buffer 01098 // Get method return value 01099 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01100 { 01101 free( Parameter ); 01102 free( Result ); 01103 01104 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01105 } 01106 01107 free( Parameter ); 01108 free( Result ); 01109 01110 return status; 01111 }
HRESULT CSessionManager::ChangePassword | ( | char * | UserName, | |
char * | Password | |||
) |
Nova funcao para alterar a senha de um usuario.
UserName | ponteiro para a string com o nome do usuario. | |
Password | ponteiro para a string com a senha do usuario. |
Definition at line 3019 of file interface/SessionManager.cpp.
03020 { 03021 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 03022 char *Result; 03023 unsigned int ParameterSize; 03024 unsigned int ResultSize; 03025 HRESULT status; 03026 03027 if( Parameter == NULL ) 03028 { 03029 RioErr << "malloc error ChangePassword:" << strerror(errno) << endl; 03030 free( Parameter ); 03031 03032 return ERROR_RIOPROXY + ERROR_MEMORY; 03033 } 03034 03035 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 03036 03037 ParameterSize = strlen( UserName ) + strlen( Password ) + 2; 03038 // Check if Parameter buffer is large enough 03039 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 03040 { 03041 free( Parameter ); 03042 03043 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 03044 } 03045 03046 int offset = 0; 03047 03048 // Set UserName 03049 SetString( Parameter, UserName, &offset ); 03050 // Set Password 03051 SetString( Parameter, Password, &offset ); 03052 03053 // Update Parameter size to actual size 03054 // ( previously was maximum possible size ) 03055 ParameterSize = offset; 03056 03057 // Call remote method 03058 status = m_TCPconnection->Call( RioClassUserManager, 03059 RioMethodUserManagerChangePassword, 03060 ParameterSize, 03061 Parameter, 03062 &ResultSize, 03063 &Result ); 03064 03065 // check if call failed 03066 if( FAILED( status ) ) 03067 { 03068 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 03069 status = ERROR_RIOPROXY + ERROR_MEMORY; 03070 if( Result != NULL ) 03071 free( Result ); 03072 free( Parameter ); 03073 03074 return status; 03075 } 03076 03077 offset = 0; 03078 // Get results from result buffer 03079 // Get method return value 03080 if( !GetLong( Result, ResultSize, &status, &offset ) ) 03081 { 03082 free( Parameter ); 03083 free( Result ); 03084 03085 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 03086 } 03087 03088 free( Parameter ); 03089 free( Result ); 03090 03091 return status; 03092 }
HRESULT CSessionManager::CheckStreamControl | ( | bool * | IsImplemented | ) |
Esta funcao faz uma chamada remota a um procedimento do Servidor RIO para verificar se a versao do servidor suporta o controle de fluxo.
IsImplemented | ponteiro para um valor booleano que sera, apos a execucao da funcao, igual a true se a versao do servidor suporta o controle de fluxo, e false caso nao suporte o controle ou se algum outro erro (diferente do de metodo invalido) ocorreu ao fazer a chamada remota (neste caso, o retorno indicara o erro). |
Definition at line 2509 of file interface/SessionManager.cpp.
02510 { 02511 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02512 char *Result; 02513 unsigned int ParameterSize; 02514 unsigned int ResultSize; 02515 HRESULT status; 02516 02517 if( Parameter == NULL ) 02518 { 02519 #ifdef RIO_DEBUG1 02520 RioErr << "malloc error CheckStreamControl:" << strerror(errno) 02521 << endl; 02522 #endif 02523 free( Parameter ); 02524 02525 return ERROR_RIOPROXY + ERROR_MEMORY; 02526 } 02527 02528 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02529 02530 ParameterSize = 0; 02531 02532 // Faz a chamada remota a uma funcao do Servidor RIO para verificar se a 02533 // versao do servidor faz ou nao o controle de fluxo. 02534 status = m_TCPconnection->Call( RioClassSessionManager, 02535 RioMethodSessionManagerCheckStreamControl, 02536 ParameterSize, 02537 Parameter, 02538 &ResultSize, 02539 &Result ); 02540 02541 02542 free( Parameter ); 02543 if( Result != NULL ) 02544 free( Result ); 02545 // check if call failed 02546 if( FAILED( status ) ) 02547 { 02548 // Se ocorreu algum erro, ou o metodo nao existe, ou ocorreu algum 02549 // erro ao executar o metodo. 02550 *IsImplemented = false; 02551 if ( ( unsigned int ) status == ERROR_CONNECTIONMANAGER + 02552 ERROR_INVALID_METHOD ) 02553 return S_OK; 02554 else 02555 { 02556 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02557 status = ERROR_RIOPROXY + ERROR_MEMORY; 02558 return status; 02559 } 02560 } 02561 else 02562 { 02563 // Se o metodo foi executado com sucesso (isto e, ele existe), entao 02564 // a versao do servidor usa o controle de fluxo. 02565 *IsImplemented = true; 02566 return S_OK; 02567 } 02568 02569 }
int CSessionManager::CleanUp | ( | ) | [private] |
Definition at line 375 of file server/SessionManager.cpp.
00376 { 00377 KillConnectionThread(); 00378 00379 if( m_TCPconnection != 0 ) 00380 { 00381 m_TCPconnection->Disconnect(); 00382 delete m_TCPconnection; 00383 m_TCPconnection = 0; 00384 } 00385 00386 if( m_FileRoot != NULL ) 00387 delete[] m_FileRoot; 00388 m_FileRoot = NULL; 00389 00390 m_initialized = false; 00391 00392 return S_OK; 00393 }
void * CSessionManager::ClientThread | ( | void * | param | ) | [static, private] |
Definition at line 532 of file server/SessionManager.cpp.
00533 { 00534 ClientThreadParameter *ClientParam = ( ClientThreadParameter * ) Param; 00535 SOCKET sock = ClientParam->Socket; 00536 SOCKADDR_IN remoteAddress = ClientParam->RemoteAddress; 00537 CSessionManager* SessionManager = ClientParam->SessionManager; 00538 unsigned int Class = 0; 00539 unsigned int Method = 0; 00540 unsigned int Size = 0; 00541 HRESULT Status = 0; 00542 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00543 char *Result = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00544 unsigned int ParameterSize = MaxTCPDataSize; 00545 unsigned int ResultSize = MaxTCPDataSize; 00546 CRioTCP TCPconnection; 00547 00548 #ifdef RIO_DEBUG2 00549 RioErr << "CLIENTTHREADID " << syscall( SYS_gettid ) << endl; 00550 #endif 00551 00552 //Initializing variables 00553 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00554 memset( Result , 0, MaxTCPDataSize*sizeof( char ) ); 00555 00556 // First accept client connection 00557 Status = TCPconnection.AcceptConnection( sock, 00558 SessionManager->m_ClientsTimeOut ); 00559 if( FAILED( Status ) ) 00560 { 00561 RioErr << "[ClientThread] Erro ao aceitar a conexao do cliente a " 00562 << "partir do IP " 00563 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00564 << " e da porta " << ntohs( ClientParam->RemoteAddress.sin_port ) 00565 << ". Terminando a thread do cliente!" << endl; 00566 00567 if( SessionManager->m_log.is_open() ) 00568 { 00569 char *info = myInfo(); 00570 SessionManager->m_log << info 00571 << "Error accepting TCP connection at " 00572 << "ClienThread. Exiting Session thread." 00573 << endl; 00574 free( info ); 00575 } 00576 free( Parameter ); 00577 free( Result ); 00578 00579 delete ClientParam; 00580 00581 return( 0 ); 00582 } 00583 00584 // This sessions/threads RioSession allocated right on this threads 00585 // stack -- if this thread ends then the RioSession destructor will 00586 // free anything opened by the session. 00587 00588 RioSession Session( SessionManager, remoteAddress ); 00589 00590 // assign global session id now 00591 pthread_mutex_lock( &SessionManager->m_mutex ); 00592 int i = SessionManager->m_MaxSessions; 00593 if( SessionManager->m_used < SessionManager->m_MaxSessions ) 00594 { 00595 for( i = 0; i < SessionManager->m_MaxSessions; i++ ) 00596 { 00597 if( SessionManager->m_SessionTable[i].Session.Index != -1 ) 00598 continue; 00599 break; 00600 } 00601 } 00602 00603 // if no session available fail this call 00604 if( i >= SessionManager->m_MaxSessions ) 00605 { 00606 RioErr << "[ClientThread] Erro ao criar a sessao do cliente a " 00607 << "partir do IP " 00608 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00609 << " e da porta " << ntohs( ClientParam->RemoteAddress.sin_port ) 00610 << ": numero maximo de sessoes " << SessionManager->m_MaxSessions 00611 << " atingido! Terminando a thread do cliente!" << endl; 00612 00613 if( SessionManager->m_log.is_open() ) 00614 { 00615 char *info = myInfo(); 00616 SessionManager->m_log << info 00617 << "Too many sessions opened." 00618 << " Refusing new session" << endl; 00619 free( info ); 00620 } 00621 pthread_mutex_unlock( &SessionManager->m_mutex ); 00622 Status = TCPconnection.ReceiveCall( &Class, &Method, 00623 Parameter, ParameterSize ); 00624 Status = ERROR_SESSIONMANAGER + ERROR_MAX_SESSIONS; 00625 00626 TCPconnection.SendCallError(Status); 00627 if( SessionManager->m_log.is_open() ) 00628 { 00629 char *info = myInfo(); 00630 SessionManager->m_log << info 00631 << "Exiting Session thread" << endl; 00632 free( info ); 00633 } 00634 00635 free( Parameter ); 00636 free( Result ); 00637 00638 delete ClientParam; 00639 00640 return 0; 00641 } 00642 00643 Session.s_id = i; 00644 SessionManager->m_used++; 00645 // Salva uma linha no log, para informar que o cliente iniciou a sessao. 00646 Session.SaveLogLine( "Connected", "<<open session>>" ); 00647 SessionManager->m_SessionTable[i].Session.Index = i; 00648 00649 #ifdef RIO_DEBUG2 00650 struct tm *date; 00651 time_t segundos; 00652 00653 struct in_addr clientip; 00654 clientip.s_addr = remoteAddress.sin_addr.s_addr; 00655 00656 if( SessionManager->m_log.is_open() ) 00657 { 00658 time( &segundos ); 00659 date = localtime( &segundos ); 00660 00661 char *info = myInfo(); 00662 SessionManager->m_log << info 00663 << " New connection accepted. Active Sessions " 00664 << SessionManager->m_used 00665 << ". New client ip: " << inet_ntoa(clientip) 00666 << " port: " << htons( remoteAddress.sin_port ) 00667 << endl; 00668 free( info ); 00669 } 00670 #endif 00671 // ------------------------------------------------------------------------ 00672 00673 // Should not reset version since this should be incremented for 00674 // each new session using the same table entry (commented out) 00675 // SessionManager->m_SessionTable[i].Session.Version = 0; 00676 00677 SessionManager->m_SessionTable[i].s_ptr = &Session; 00678 00679 pthread_mutex_unlock( &SessionManager->m_mutex ); 00680 00681 while( true ) 00682 { 00683 // Receive a client method call 00684 Status = TCPconnection.ReceiveCall( &Class, &Method, Parameter, 00685 ParameterSize ); 00686 00687 // Check if call was received successfully 00688 if( FAILED( Status ) ) 00689 { 00690 if( Status == (int )(ERROR_RIOTCP + ERROR_CLOSED_CONNECTION) ) 00691 { 00692 #ifdef RIO_DEBUG2 00693 RioErr << "[ClientThread] Fechando a conexao do cliente com o " 00694 << "IP " 00695 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00696 << " e a porta " 00697 << ntohs( ClientParam->RemoteAddress.sin_port ) 00698 << ". Terminando a thread do cliente!" << endl; 00699 #endif 00700 00701 if( SessionManager->m_log.is_open() ) 00702 { 00703 char *info = myInfo(); 00704 SessionManager->m_log << info 00705 << "Client exiting ... " 00706 << "Closing Connection." << endl; 00707 free( info ); 00708 } 00709 } 00710 else 00711 { 00712 #ifdef RIO_DEBUG2 00713 RioErr << "[ClientThread] Erro 0x" << hex << Status << dec 00714 << " (" << GetErrorDescription( Status) << ") ao " 00715 << "executar a funcao ReceiveCall para o cliente com o " 00716 << "IP " 00717 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00718 << " e a porta " 00719 << ntohs( ClientParam->RemoteAddress.sin_port ) 00720 << ". Terminando a thread do cliente!" << endl; 00721 #endif 00722 00723 if( SessionManager->m_log.is_open() ) 00724 { 00725 char *info = myInfo(); 00726 SessionManager->m_log << info 00727 << "ERROR on TCP connection receive. " 00728 << "Closing Connection: " 00729 << GetErrorDescription( Status ) 00730 << endl; 00731 free( info ); 00732 } 00733 } 00734 // ---------------------------------------------------------------- 00735 TCPconnection.Disconnect(); 00736 if( SessionManager->m_log.is_open() ) 00737 { 00738 char *info = myInfo(); 00739 SessionManager->m_log << info 00740 << "Exiting Session thread" << endl; 00741 free( info ); 00742 } 00743 00744 free( Parameter ); 00745 free( Result ); 00746 00747 delete ClientParam; 00748 00749 return(0); 00750 } 00751 else // else do if( FAILED( Status ) ) 00752 { 00753 Size = ResultSize; 00754 // execute method 00755 Status = Session.ExecuteCall( Class, Method, 00756 Parameter, ParameterSize, 00757 &Result, &Size ); 00758 00759 #ifdef RIO_DEBUG2 00760 RioErr << "CSessionManager::ClientThread enviando uma mensagem " 00761 << "de " << Size << " bytes." << endl; 00762 #endif 00763 // Return result or call error to client 00764 if( FAILED( Status ) ) 00765 { 00766 char *info = myInfo(); 00767 SessionManager->m_log << info 00768 << "Failed executing call. " << endl; 00769 free( info ); 00770 00771 Status = TCPconnection.SendCallError( Status ); 00772 } 00773 else 00774 { 00775 Status = TCPconnection.SendResult(Result, Size); 00776 } 00777 00778 // Volta ao tamanho original. Nao podemos ter um erro de memoria 00779 // neste caso, porque estamos reduzindo a memoria que foi alocada. 00780 if( Size > ResultSize ) 00781 { 00782 #ifdef RIO_DEBUG2 00783 RioErr << "CSessionManager::ClientThread Reduzindo tamanho " 00784 << "alocado de " << Size << " bytes para " << ResultSize 00785 << " bytes " << endl; 00786 #endif 00787 char *NewResult = ( char * ) realloc( Result, ResultSize ); 00788 if( NewResult == NULL ) 00789 RioErr << "CSessionManager::ClientThread falhou em reduzir " 00790 << "o tamanho da area alocada de " << Size 00791 << " para " << ResultSize << ". Tamanho mantido!" 00792 << endl; 00793 else 00794 Result = NewResult; 00795 } 00796 00797 if( FAILED( Status ) ) 00798 { 00799 RioErr << "[ClientThread] Erro ao enviar os resultados ao " 00800 << "cliente com o IP " 00801 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00802 << " e a porta " 00803 << ntohs( ClientParam->RemoteAddress.sin_port ) 00804 << ". Terminando a thread do cliente!" << endl; 00805 00806 // If anything goes wrong when sending result close 00807 // connection and abort thread 00808 TCPconnection.Disconnect(); 00809 RioErr << "SessionManager - Exiting Session thread" << endl; 00810 00811 free( Parameter ); 00812 free( Result ); 00813 00814 delete ClientParam; 00815 00816 return(0); 00817 } 00818 } // fim do else do if( FAILED( Status ) ) 00819 } // fim do while( true ) 00820 00821 free( Parameter ); 00822 free( Result ); 00823 00824 RioErr << "[ClientThread] A thread para o IP " 00825 << inet_ntoa( ClientParam->RemoteAddress.sin_addr ) 00826 << " e a porta " 00827 << ntohs( ClientParam->RemoteAddress.sin_port ) 00828 << "for terminada no final!" << endl; 00829 00830 delete ClientParam; 00831 00832 return( 0 ); 00833 }
HRESULT CSessionManager::Close | ( | const RioSessionId | Session | ) |
Definition at line 215 of file interface/SessionManager.cpp.
00216 { 00217 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00218 char *Result; 00219 unsigned int ParameterSize; 00220 unsigned int ResultSize; 00221 HRESULT status; 00222 00223 if( Parameter == NULL ) 00224 { 00225 RioErr << "malloc error Close:" << strerror(errno) << endl; 00226 free( Parameter ); 00227 00228 return ERROR_RIOPROXY + ERROR_MEMORY; 00229 } 00230 00231 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00232 00233 ParameterSize = 2*MAX_LONG_STRING_SIZE; 00234 // Check if Parameter buffer is large enough 00235 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00236 { 00237 free( Parameter ); 00238 00239 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00240 } 00241 00242 int offset = 0; 00243 00244 // Set parameters on asii buffer 00245 // Set Session Id 00246 SetLong( Parameter,Session.Version,&offset ); 00247 SetLong( Parameter,Session.Index,&offset ); 00248 00249 // Update Parameter size to actual size 00250 // ( previously was maximum possible size ) 00251 ParameterSize = offset; 00252 00253 // Call remote method 00254 status = m_TCPconnection->Call( RioClassSessionManager, 00255 RioMethodSessionManagerClose, 00256 ParameterSize, 00257 Parameter, 00258 &ResultSize, 00259 &Result ); 00260 00261 // check if call failed 00262 if( FAILED( status ) ) 00263 { 00264 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00265 status = ERROR_RIOPROXY + ERROR_MEMORY; 00266 if( Result != NULL ) 00267 free( Result ); 00268 free( Parameter ); 00269 00270 return status; 00271 } 00272 00273 offset = 0; 00274 // Get results from result buffer 00275 // Get method return value 00276 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00277 { 00278 free( Parameter ); 00279 free( Result ); 00280 00281 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00282 } 00283 00284 free( Parameter ); 00285 free( Result ); 00286 00287 return status; 00288 }
void * CSessionManager::ConnectionThread | ( | void * | param | ) | [static, private] |
Definition at line 456 of file server/SessionManager.cpp.
00457 { 00458 CRioTCP* TCPconnection; 00459 SOCKET ConnectedSocket; 00460 00461 RioErr << "CONNECTIONTHREADID " << syscall( SYS_gettid ) << endl; 00462 00463 // Get pointer to SessionManger (this) 00464 CSessionManager *SessionManager = (CSessionManager *) Param; 00465 00466 // Get Socket 00467 TCPconnection = SessionManager->m_TCPconnection; 00468 while( true ) 00469 { 00470 // Wait for client connection 00471 HRESULT hResult = TCPconnection->WaitConnection(&ConnectedSocket); 00472 00473 // Check if thread should terminate 00474 if( SessionManager->m_threadStopEvent ) 00475 { 00476 TCPconnection->Disconnect(); 00477 return(0); 00478 } 00479 00480 // Check if TCPconnection->WaitConnection() failed 00481 if( FAILED( hResult ) ) 00482 { 00483 if( SessionManager->m_log.is_open() ) 00484 SessionManager->m_log << "ConnectionThread: " 00485 << "Connection waiting failed" << endl; 00486 if( hResult != ( ( HRESULT ) ( ERROR_RIOTCP + ERROR_SOCKET_ACCEPT ) 00487 ) ) 00488 { 00489 RioErr << "[ConnectionThread] Erro critico 0x" << hex 00490 << hResult << dec << " (" 00491 << GetErrorDescription( hResult ) << ") gerado. " 00492 << "Forcando a finalizacao do servidor com um sinal " 00493 << "SIGTERM." << endl; 00494 raise( SIGTERM ); 00495 } 00496 } 00497 // Create thread to handle new client connection 00498 else 00499 { 00500 ClientThreadParameter *Param = new ClientThreadParameter(); 00501 Param->Socket = ConnectedSocket; 00502 Param->SessionManager = SessionManager; 00503 pthread_t junk; 00504 pthread_attr_t attrib; 00505 00506 // to correct ip problem (when using dhcp 00507 // the client's ip sent in the packet is wrong ) 00508 Param->RemoteAddress = TCPconnection->m_RemoteAddress; 00509 // to fix memory bug 00510 pthread_attr_init( &attrib ); 00511 pthread_attr_setstacksize( &attrib, 6*PTHREAD_STACK_MIN ); 00512 00513 // ---------------------------------------------------------------- 00514 if( pthread_create( &junk, &attrib, &ClientThread, (void*) Param ) ) 00515 { 00516 delete Param; 00517 if( SessionManager->m_log.is_open() ) 00518 SessionManager->m_log << "ConnectionThread: " 00519 << "Failed to create client thread" 00520 << endl; 00521 shutdown( ConnectedSocket, 2 ); 00522 } 00523 else 00524 pthread_detach( junk ); 00525 } 00526 } 00527 00528 return 0; 00529 }
HRESULT CSessionManager::CreateObject | ( | const RioSessionId | Session, | |
const char * | ObjectName, | |||
const short | Type | |||
) |
Definition at line 472 of file interface/SessionManager.cpp.
00475 { 00476 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00477 char *Result; 00478 unsigned int ParameterSize; 00479 unsigned int ResultSize; 00480 00481 if( Parameter == NULL ) 00482 { 00483 RioErr << "malloc error CreateObject:" << strerror(errno) << endl; 00484 free( Parameter ); 00485 00486 return ERROR_RIOPROXY + ERROR_MEMORY; 00487 } 00488 00489 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00490 00491 HRESULT status; 00492 ParameterSize = 2 * MAX_LONG_STRING_SIZE + 00493 strlen( ObjectName )+1 + 00494 MAX_SHORT_STRING_SIZE; 00495 00496 // Check if Parameter buffer is large enough 00497 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00498 { 00499 free( Parameter ); 00500 00501 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00502 } 00503 00504 int offset = 0; 00505 00506 // Set parameters on ascii buffer 00507 // Set Session Id 00508 SetLong( Parameter,Session.Version,&offset ); 00509 SetLong( Parameter,Session.Index,&offset ); 00510 00511 // Set Object Name 00512 SetString( Parameter,ObjectName,&offset ); 00513 00514 // Set Object type 00515 SetShort( Parameter,Type,&offset ); 00516 00517 // Update Parameter size to actual size ( previously was maximum possible size ) 00518 ParameterSize = offset; 00519 00520 // Call remote method 00521 status = m_TCPconnection->Call( RioClassSessionManager, 00522 RioMethodSessionManagerCreateObject, 00523 ParameterSize, 00524 Parameter, 00525 &ResultSize, 00526 &Result ); 00527 00528 // check if call failed 00529 if( FAILED( status ) ) 00530 { 00531 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00532 status = ERROR_RIOPROXY + ERROR_MEMORY; 00533 if( Result != NULL ) 00534 free( Result ); 00535 free( Parameter ); 00536 00537 return status; 00538 } 00539 00540 offset = 0; 00541 // Get results from result buffer 00542 // Get method return value 00543 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00544 { 00545 free( Parameter ); 00546 free( Result ); 00547 00548 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00549 } 00550 00551 free( Parameter ); 00552 free( Result ); 00553 00554 return status; 00555 }
HRESULT CSessionManager::CreateUser | ( | char * | UserName, | |
char * | Password | |||
) |
Nova funcao para criar um usuario.
UserName | ponteiro para a string com o nome do usuario. | |
Password | ponteiro para a string com a senha do usuario. |
Definition at line 2869 of file interface/SessionManager.cpp.
02870 { 02871 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02872 char *Result; 02873 unsigned int ParameterSize; 02874 unsigned int ResultSize; 02875 HRESULT status; 02876 02877 if( Parameter == NULL ) 02878 { 02879 RioErr << "malloc error CreateUser:" << strerror(errno) << endl; 02880 free( Parameter ); 02881 02882 return ERROR_RIOPROXY + ERROR_MEMORY; 02883 } 02884 02885 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02886 02887 ParameterSize = strlen( UserName ) + strlen( Password ) + 2; 02888 // Check if Parameter buffer is large enough 02889 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02890 { 02891 free( Parameter ); 02892 02893 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02894 } 02895 02896 int offset = 0; 02897 02898 // Set UserName 02899 SetString( Parameter, UserName, &offset ); 02900 // Set Password 02901 SetString( Parameter, Password, &offset ); 02902 02903 // Update Parameter size to actual size 02904 // ( previously was maximum possible size ) 02905 ParameterSize = offset; 02906 02907 // Call remote method 02908 status = m_TCPconnection->Call( RioClassUserManager, 02909 RioMethodUserManagerCreateUser, 02910 ParameterSize, 02911 Parameter, 02912 &ResultSize, 02913 &Result ); 02914 02915 // check if call failed 02916 if( FAILED( status ) ) 02917 { 02918 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02919 status = ERROR_RIOPROXY + ERROR_MEMORY; 02920 if( Result != NULL ) 02921 free( Result ); 02922 free( Parameter ); 02923 02924 return status; 02925 } 02926 02927 offset = 0; 02928 // Get results from result buffer 02929 // Get method return value 02930 if( !GetLong( Result, ResultSize, &status, &offset ) ) 02931 { 02932 free( Parameter ); 02933 free( Result ); 02934 02935 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02936 } 02937 02938 free( Parameter ); 02939 free( Result ); 02940 02941 return status; 02942 }
HRESULT CSessionManager::DeleteObject | ( | const RioSessionId | Session, | |
const char * | ObjectName | |||
) |
Definition at line 558 of file interface/SessionManager.cpp.
00560 { 00561 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00562 char *Result; 00563 unsigned int ParameterSize; 00564 unsigned int ResultSize; 00565 HRESULT status; 00566 00567 if( Parameter == NULL ) 00568 { 00569 RioErr << "malloc error DeleteObject:" << strerror(errno) << endl; 00570 free( Parameter ); 00571 00572 return ERROR_RIOPROXY + ERROR_MEMORY; 00573 } 00574 00575 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00576 00577 ParameterSize = 2 * MAX_LONG_STRING_SIZE + 00578 strlen( ObjectName )+1; 00579 // Check if Parameter buffer is large enough 00580 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00581 { 00582 free( Parameter ); 00583 00584 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00585 } 00586 00587 int offset = 0; 00588 00589 // Set parameters on asii buffer 00590 // Set Session Id 00591 SetLong( Parameter,Session.Version,&offset ); 00592 SetLong( Parameter,Session.Index,&offset ); 00593 00594 // Set Object Current Name 00595 SetString( Parameter,ObjectName,&offset ); 00596 00597 // Update Parameter size to actual size 00598 // ( previously was maximum possible size ) 00599 ParameterSize = offset; 00600 00601 // Call remote method 00602 status = m_TCPconnection->Call( RioClassSessionManager, 00603 RioMethodSessionManagerDeleteObject, 00604 ParameterSize, 00605 Parameter, 00606 &ResultSize, 00607 &Result ); 00608 00609 // check if call failed 00610 if( FAILED( status ) ) 00611 { 00612 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00613 status = ERROR_RIOPROXY + ERROR_MEMORY; 00614 if( Result != NULL ) 00615 free( Result ); 00616 free( Parameter ); 00617 00618 return status; 00619 } 00620 00621 offset = 0; 00622 // Get results from result buffer 00623 // Get method return value 00624 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00625 { 00626 free( Parameter ); 00627 free( Result ); 00628 00629 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00630 } 00631 00632 free( Parameter ); 00633 free( Result ); 00634 00635 return status; 00636 }
HRESULT CSessionManager::FirstObject | ( | RioSessionId | Session, | |
signed char * | DirectoryName, | |||
ObjectHandle * | Handle, | |||
int * | IsDirectory, | |||
int | BufferSize, | |||
signed char * | ObjectName | |||
) |
Definition at line 897 of file interface/SessionManager.cpp.
00903 { 00904 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00905 char *Result; 00906 unsigned int ParameterSize; 00907 unsigned int ResultSize; 00908 HRESULT status; 00909 00910 if( Parameter == NULL ) 00911 { 00912 RioErr << "malloc error FirstObject:" << strerror(errno) << endl; 00913 free( Parameter ); 00914 00915 return ERROR_RIOPROXY + ERROR_MEMORY; 00916 } 00917 00918 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00919 00920 ParameterSize = 3 * MAX_LONG_STRING_SIZE + 00921 strlen( ( char * )DirectoryName ) + 1; 00922 // Check if Parameter buffer is large enough 00923 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00924 { 00925 free( Parameter ); 00926 00927 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00928 } 00929 00930 int offset = 0; 00931 00932 // Set parameters on asii buffer 00933 // Set Session Id 00934 SetLong( Parameter,Session.Version,&offset ); 00935 SetLong( Parameter,Session.Index,&offset ); 00936 00937 // Set Directory name 00938 SetString( Parameter,( char * )DirectoryName,&offset ); 00939 00940 // Set Buffer size 00941 SetLong ( Parameter,BufferSize, &offset ); 00942 00943 // Update Parameter size to actual size 00944 // ( previously was maximum possible size ) 00945 ParameterSize = offset; 00946 00947 // Call remote method 00948 status = m_TCPconnection->Call( RioClassSessionManager, 00949 RioMethodSessionManagerFirstObject, 00950 ParameterSize, 00951 Parameter, 00952 &ResultSize, 00953 &Result ); 00954 00955 // check if call failed 00956 if( FAILED( status ) ) 00957 { 00958 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00959 status = ERROR_RIOPROXY + ERROR_MEMORY; 00960 if( Result != NULL ) 00961 free( Result ); 00962 free( Parameter ); 00963 00964 return status; 00965 } 00966 00967 offset = 0; 00968 // Get results from result buffer 00969 // Get method return value 00970 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00971 { 00972 free( Parameter ); 00973 free( Result ); 00974 00975 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00976 } 00977 00978 00979 if( FAILED( status ) ) 00980 { 00981 free( Parameter ); 00982 free( Result ); 00983 00984 return status; 00985 } 00986 00987 // Get Object Hanlde 00988 if( !GetLong( Result,ResultSize,&( Handle->Version ),&offset ) ) 00989 { 00990 free( Parameter ); 00991 free( Result ); 00992 00993 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00994 } 00995 if( !GetLong( Result,ResultSize,&( Handle->Index ),&offset ) ) 00996 { 00997 free( Parameter ); 00998 free( Result ); 00999 01000 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01001 } 01002 01003 // Get Directory flag 01004 if( !GetLong( Result,ResultSize, IsDirectory ,&offset ) ) 01005 { 01006 free( Parameter ); 01007 free( Result ); 01008 01009 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01010 } 01011 01012 char *str = NULL; 01013 // Get Object Name 01014 if( !GetString( Result,ResultSize,&str,&offset ) ) 01015 { 01016 free( Parameter ); 01017 free( Result ); 01018 01019 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01020 } 01021 01022 strcpy( ( char * )ObjectName, str ); 01023 01024 free( Parameter ); 01025 free( Result ); 01026 01027 return status; 01028 }
HRESULT CSessionManager::GetAverageRTT | ( | struct timeval * | average_RTT | ) |
Definition at line 2275 of file interface/SessionManager.cpp.
02276 { 02277 int numRTT = 0; 02278 double averagems = 0; 02279 02280 average_RTT->tv_sec = m_RTT_openConnection.tv_sec; 02281 average_RTT->tv_usec = m_RTT_openConnection.tv_usec; 02282 02283 if( ( m_RTT_openStream.tv_sec != 0 ) || ( m_RTT_openStream.tv_usec != 0 ) ) 02284 { 02285 average_RTT->tv_sec += m_RTT_openStream.tv_sec; 02286 average_RTT->tv_usec += m_RTT_openStream.tv_usec; 02287 numRTT = 1; 02288 } 02289 02290 numRTT += 1; 02291 02292 02293 if( average_RTT->tv_usec > 1000000 ) 02294 { 02295 average_RTT->tv_usec -= 1000000; 02296 average_RTT->tv_sec += 1; 02297 } 02298 02299 if( numRTT > 1 ) 02300 { 02301 averagems = ( average_RTT->tv_sec * 1000.0 + 02302 average_RTT->tv_usec / 1000.0 ) / numRTT; 02303 long double averagemicrosec = averagems * 1000; 02304 average_RTT->tv_sec = ( unsigned int ) ( averagemicrosec / 1000000 ); 02305 average_RTT->tv_usec = 02306 ( unsigned int )( ( unsigned int )averagemicrosec % 1000000 ); 02307 } 02308 return S_OK; 02309 }
HRESULT CSessionManager::GetBlockSize | ( | const RioSessionId | Session, | |
unsigned int * | BlockSize | |||
) |
Definition at line 725 of file interface/SessionManager.cpp.
00727 { 00728 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00729 char *Result; 00730 unsigned int ParameterSize; 00731 unsigned int ResultSize; 00732 HRESULT status; 00733 00734 if( Parameter == NULL ) 00735 { 00736 RioErr << "malloc error GetBlockSize:" << strerror(errno) << endl; 00737 free( Parameter ); 00738 00739 return ERROR_RIOPROXY + ERROR_MEMORY; 00740 } 00741 00742 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00743 00744 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 00745 // Check if Parameter buffer is large enough 00746 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00747 { 00748 free( Parameter ); 00749 00750 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00751 } 00752 00753 int offset = 0; 00754 00755 // Set parameters on asii buffer 00756 // Set Session Id 00757 SetLong( Parameter,Session.Version,&offset ); 00758 SetLong( Parameter,Session.Index,&offset ); 00759 00760 // Update Parameter size to actual size 00761 // ( previously was maximum possible size ) 00762 ParameterSize = offset; 00763 00764 // Call remote method 00765 status = m_TCPconnection->Call( RioClassSessionManager, 00766 RioMethodSessionManagerGetBlockSize, 00767 ParameterSize, 00768 Parameter, 00769 &ResultSize, 00770 &Result ); 00771 00772 // check if call failed 00773 if( FAILED( status ) ) 00774 { 00775 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00776 status = ERROR_RIOPROXY + ERROR_MEMORY; 00777 if( Result != NULL ) 00778 free( Result ); 00779 free( Parameter ); 00780 00781 return status; 00782 } 00783 00784 offset = 0; 00785 // Get results from result buffer 00786 // Get method return value 00787 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00788 { 00789 free( Parameter ); 00790 free( Result ); 00791 00792 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00793 } 00794 00795 // Get Block Size 00796 if( !GetULong( Result,ResultSize,BlockSize,&offset ) ) 00797 { 00798 free( Parameter ); 00799 free( Result ); 00800 00801 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00802 } 00803 00804 free( Parameter ); 00805 free( Result ); 00806 00807 return status; 00808 }
HRESULT CSessionManager::GetCurrentDir | ( | RioSessionId | Session, | |
int | size, | |||
signed char * | Dir | |||
) |
Definition at line 1114 of file interface/SessionManager.cpp.
01117 { 01118 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01119 char *Result; 01120 unsigned int ParameterSize; 01121 unsigned int ResultSize; 01122 HRESULT status; 01123 01124 if( Parameter == NULL ) 01125 { 01126 RioErr << "malloc error GetCurrentDir:" << strerror(errno) << endl; 01127 free( Parameter ); 01128 01129 return ERROR_RIOPROXY + ERROR_MEMORY; 01130 } 01131 01132 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01133 01134 ParameterSize = 3 * MAX_LONG_STRING_SIZE + 1; 01135 // Check if Parameter buffer is large enough 01136 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01137 { 01138 free( Parameter ); 01139 01140 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01141 } 01142 01143 int offset = 0; 01144 01145 // Set parameters on asii buffer 01146 // Set Session Id 01147 SetLong( Parameter,Session.Version,&offset ); 01148 SetLong( Parameter,Session.Index,&offset ); 01149 01150 // Set Buffer size 01151 SetLong ( Parameter, size, &offset ); 01152 01153 // Update Parameter size to actual size 01154 // ( previously was maximum possible size ) 01155 ParameterSize = offset; 01156 01157 //RioErr << "antes do CALL na SessionManager" << endl; 01158 01159 // Call remote method 01160 status = m_TCPconnection->Call( RioClassSessionManager, 01161 RioMethodSessionManagerGetCurrentDir, 01162 ParameterSize, 01163 Parameter, 01164 &ResultSize, 01165 &Result ); 01166 01167 // check if call failed 01168 if( FAILED( status ) ) 01169 { 01170 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01171 status = ERROR_RIOPROXY + ERROR_MEMORY; 01172 if( Result != NULL ) 01173 free( Result ); 01174 free( Parameter ); 01175 01176 return status; 01177 } 01178 01179 offset = 0; 01180 // Get results from result buffer 01181 // Get method return value 01182 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01183 { 01184 free( Parameter ); 01185 free( Result ); 01186 01187 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01188 } 01189 01190 char *str; 01191 // Get current directory name 01192 if( !GetString( Result,ResultSize,&str,&offset ) ) 01193 { 01194 free( Parameter ); 01195 free( Result ); 01196 01197 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01198 } 01199 01200 strcpy( ( char * )Dir,str ); 01201 01202 free( Parameter ); 01203 free( Result ); 01204 01205 return status; 01206 }
void CSessionManager::GetMonitorTable | ( | vector< ClientData > & | clientTable, | |
vector< StorageData > & | storageTable | |||
) | [private] |
Definition at line 846 of file server/SessionManager.cpp.
00848 { 00849 m_SystemManager->GetMonitorTable( clientTable, storageTable ); 00850 }
HRESULT CSessionManager::GetMonitorTable | ( | char * | UserName, | |
vector< ClientData > * | client_data, | |||
vector< StorageData > * | storage_data | |||
) |
Definition at line 2065 of file interface/SessionManager.cpp.
02068 { 02069 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02070 char *Result; 02071 unsigned int ParameterSize; 02072 unsigned int ResultSize; 02073 HRESULT status; 02074 02075 if( Parameter == NULL ) 02076 { 02077 RioErr << "malloc error GetStorageNodeInfo:" << strerror(errno) << endl; 02078 free( Parameter ); 02079 02080 return ERROR_RIOPROXY + ERROR_MEMORY; 02081 } 02082 02083 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02084 02085 ParameterSize = 2*MAX_LONG_STRING_SIZE; 02086 // Check if Parameter buffer is large enough 02087 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02088 { 02089 free( Parameter ); 02090 02091 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02092 } 02093 02094 int offset = 0; 02095 02096 // Set Session Id 02097 SetString( Parameter,UserName,&offset ); 02098 02099 // Update Parameter size to actual size 02100 // ( previously was maximum possible size ) 02101 ParameterSize = offset; 02102 02103 // Call remote method 02104 status = m_TCPconnection->Call( RioClassSessionManager, 02105 RioMethodSessionManagerGetMonitorTable, 02106 ParameterSize, 02107 Parameter, 02108 &ResultSize, 02109 &Result ); 02110 02111 // check if call failed 02112 if( FAILED( status ) ) 02113 { 02114 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02115 status = ERROR_RIOPROXY + ERROR_MEMORY; 02116 if( Result != NULL ) 02117 free( Result ); 02118 free( Parameter ); 02119 02120 return status; 02121 } 02122 02123 offset = 0; 02124 unsigned short client_table_size, storage_table_size; 02125 // Get results from result buffer 02126 // Get method first value 02127 if( !GetUShort( Result,ResultSize,&client_table_size,&offset ) ) 02128 { 02129 free( Parameter ); 02130 free( Result ); 02131 02132 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02133 } 02134 // Get method second value 02135 if( !GetUShort( Result,ResultSize,&storage_table_size,&offset ) ) 02136 { 02137 free( Parameter ); 02138 free( Result ); 02139 02140 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02141 } 02142 02143 int i; 02144 for( i = 0; i < client_table_size; i++) 02145 { 02146 ClientData data; 02147 char *ip, *video; 02148 if( !GetString( Result, ResultSize, &ip, &offset ) ) 02149 { 02150 free( Parameter ); 02151 free( Result ); 02152 02153 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02154 } 02155 if( !GetUShort( Result, ResultSize, &(data.m_port), &offset ) ) 02156 { 02157 free( Parameter ); 02158 free( Result ); 02159 02160 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02161 } 02162 if( !GetString( Result, ResultSize, &video, &offset ) ) 02163 { 02164 free( Parameter ); 02165 free( Result ); 02166 02167 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02168 } 02169 if( !GetUShort( Result, ResultSize, &(data.m_time), &offset ) ) 02170 { 02171 free( Parameter ); 02172 free( Result ); 02173 02174 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02175 } 02176 if( !GetUShort( Result, ResultSize, &(data.m_queue), &offset ) ) 02177 { 02178 free( Parameter ); 02179 free( Result ); 02180 02181 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02182 } 02183 data.m_ip = ip; 02184 data.m_video = video; 02185 client_data->push_back( data ); 02186 } 02187 02188 for( i = 0; i < storage_table_size; i++) 02189 { 02190 StorageData data; 02191 char *ip, *hostname, *diskname; 02192 if( !GetString( Result, ResultSize, &ip, &offset ) ) 02193 { 02194 free( Parameter ); 02195 free( Result ); 02196 02197 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02198 } 02199 if( !GetString( Result, ResultSize, &hostname, &offset ) ) 02200 { 02201 free( Parameter ); 02202 free( Result ); 02203 02204 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02205 } 02206 if( !GetString( Result, ResultSize, &diskname, &offset ) ) 02207 { 02208 free( Parameter ); 02209 free( Result ); 02210 02211 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02212 } 02213 if( !GetUShort( Result, ResultSize, &(data.m_queue), &offset ) ) 02214 { 02215 free( Parameter ); 02216 free( Result ); 02217 02218 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02219 } 02220 data.m_ip = ip; 02221 data.m_hostname = hostname; 02222 data.m_diskname = diskname; 02223 storage_data->push_back( data ); 02224 } 02225 02226 free( Parameter ); 02227 free( Result ); 02228 02229 return status; 02230 }
HRESULT CSessionManager::GetnStorageNodes | ( | const RioSessionId | Session, | |
short * | nStorageNodes | |||
) |
Definition at line 811 of file interface/SessionManager.cpp.
00813 { 00814 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00815 char *Result; 00816 unsigned int ParameterSize; 00817 unsigned int ResultSize; 00818 HRESULT status; 00819 00820 if( Parameter == NULL ) 00821 { 00822 RioErr << "malloc error GetnStorageNodes:" << strerror(errno) << endl; 00823 free( Parameter ); 00824 00825 return ERROR_RIOPROXY + ERROR_MEMORY; 00826 } 00827 00828 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00829 00830 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 00831 // Check if Parameter buffer is large enough 00832 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00833 { 00834 free( Parameter ); 00835 00836 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00837 } 00838 00839 int offset = 0; 00840 00841 // Set parameters on asii buffer 00842 // Set Session Id 00843 SetLong( Parameter,Session.Version,&offset ); 00844 SetLong( Parameter,Session.Index,&offset ); 00845 00846 // Update Parameter size to actual size 00847 // ( previously was maximum possible size ) 00848 ParameterSize = offset; 00849 00850 // Call remote method 00851 status = m_TCPconnection->Call( RioClassSessionManager, 00852 RioMethodSessionManagerGetnStorageNodes, 00853 ParameterSize, 00854 Parameter, 00855 &ResultSize, 00856 &Result ); 00857 00858 // check if call failed 00859 if( FAILED( status ) ) 00860 { 00861 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00862 status = ERROR_RIOPROXY + ERROR_MEMORY; 00863 if( Result != NULL ) 00864 free( Result ); 00865 free( Parameter ); 00866 00867 return status; 00868 } 00869 00870 offset = 0; 00871 // Get results from result buffer 00872 // Get method return value 00873 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00874 { 00875 free( Parameter ); 00876 free( Result ); 00877 00878 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00879 } 00880 00881 // Get number of storage nodes 00882 if( !GetShort( Result,ResultSize,nStorageNodes,&offset ) ) 00883 { 00884 free( Parameter ); 00885 free( Result ); 00886 00887 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00888 } 00889 00890 free( Parameter ); 00891 free( Result ); 00892 00893 return status; 00894 }
HRESULT CSessionManager::GetNumberOfActiveAndMaxSessions | ( | const RioSessionId | Session, | |
unsigned int * | NumberOfActiveSessions, | |||
unsigned int * | NumberOfMaxSessions | |||
) |
Definition at line 1649 of file interface/SessionManager.cpp.
01653 { 01654 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01655 char *Result; 01656 unsigned int ParameterSize; 01657 unsigned int ResultSize; 01658 HRESULT status; 01659 01660 if( Parameter == NULL ) 01661 { 01662 RioErr << "malloc error GetNumberOfActiveAndMaxSessions:" 01663 << strerror(errno) << endl; 01664 free( Parameter ); 01665 01666 return ERROR_RIOPROXY + ERROR_MEMORY; 01667 } 01668 01669 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01670 01671 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 01672 // Check if Parameter buffer is large enough 01673 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01674 { 01675 free( Parameter ); 01676 01677 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01678 } 01679 01680 int offset = 0; 01681 01682 // Set parameters on asii buffer 01683 // Set Session Id 01684 SetLong( Parameter,Session.Version,&offset ); 01685 SetLong( Parameter,Session.Index,&offset ); 01686 01687 // Update Parameter size to actual size 01688 // ( previously was maximum possible size ) 01689 ParameterSize = offset; 01690 01691 // Call remote method 01692 status = m_TCPconnection->Call( RioClassSessionManager, 01693 RioMethodSessionManagerGetNumberOfActiveAndMaxSessions, 01694 ParameterSize, 01695 Parameter, 01696 &ResultSize, 01697 &Result ); 01698 01699 // check if call failed 01700 if( FAILED( status ) ) 01701 { 01702 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01703 status = ERROR_RIOPROXY + ERROR_MEMORY; 01704 if( Result != NULL ) 01705 free( Result ); 01706 free( Parameter ); 01707 01708 return status; 01709 } 01710 01711 offset = 0; 01712 // Get results from result buffer 01713 // Get method return value 01714 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01715 { 01716 free( Parameter ); 01717 free( Result ); 01718 01719 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01720 } 01721 01722 // Get NumberOfActiveSessions 01723 if( !GetULong( Result,ResultSize,NumberOfActiveSessions,&offset ) ) 01724 { 01725 free( Parameter ); 01726 free( Result ); 01727 01728 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01729 } 01730 // Get NumberOfMaxSessions 01731 if( !GetULong( Result,ResultSize,NumberOfMaxSessions,&offset ) ) 01732 { 01733 free( Parameter ); 01734 free( Result ); 01735 01736 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01737 } 01738 01739 free( Parameter ); 01740 free( Result ); 01741 01742 return status; 01743 }
HRESULT CSessionManager::GetNumberOfDisks | ( | const RioSessionId | Session, | |
unsigned int * | NumberOfDisks | |||
) |
Definition at line 1475 of file interface/SessionManager.cpp.
01477 { 01478 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01479 char *Result; 01480 unsigned int ParameterSize; 01481 unsigned int ResultSize; 01482 HRESULT status; 01483 01484 if( Parameter == NULL ) 01485 { 01486 RioErr << "malloc error GetNumberOfDisks:" << strerror(errno) << endl; 01487 free( Parameter ); 01488 01489 return ERROR_RIOPROXY + ERROR_MEMORY; 01490 } 01491 01492 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01493 01494 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 01495 // Check if Parameter buffer is large enough 01496 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01497 { 01498 free( Parameter ); 01499 01500 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01501 } 01502 01503 int offset = 0; 01504 01505 // Set parameters on asii buffer 01506 // Set Session Id 01507 SetLong( Parameter,Session.Version,&offset ); 01508 SetLong( Parameter,Session.Index,&offset ); 01509 01510 // Update Parameter size to actual size 01511 // ( previously was maximum possible size ) 01512 ParameterSize = offset; 01513 01514 // Call remote method 01515 status = m_TCPconnection->Call( RioClassSessionManager, 01516 RioMethodSessionManagerGetNumberOfDisks, 01517 ParameterSize, 01518 Parameter, 01519 &ResultSize, 01520 &Result ); 01521 01522 // check if call failed 01523 if( FAILED( status ) ) 01524 { 01525 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01526 status = ERROR_RIOPROXY + ERROR_MEMORY; 01527 if( Result != NULL ) 01528 free( Result ); 01529 free( Parameter ); 01530 01531 return status; 01532 } 01533 01534 offset = 0; 01535 // Get results from result buffer 01536 // Get method return value 01537 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01538 { 01539 free( Parameter ); 01540 free( Result ); 01541 01542 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01543 } 01544 01545 // Get NumberOfDisks 01546 if( !GetULong( Result,ResultSize,NumberOfDisks,&offset ) ) 01547 { 01548 free( Parameter ); 01549 free( Result ); 01550 01551 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01552 } 01553 01554 free( Parameter ); 01555 free( Result ); 01556 01557 return status; 01558 }
HRESULT CSessionManager::GetNumberOfStorageNodes | ( | const RioSessionId | Session, | |
unsigned int * | NumberOfStorageNodes | |||
) |
Definition at line 1562 of file interface/SessionManager.cpp.
01564 { 01565 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01566 char *Result; 01567 unsigned int ParameterSize; 01568 unsigned int ResultSize; 01569 HRESULT status; 01570 01571 if( Parameter == NULL ) 01572 { 01573 RioErr << "malloc error GetNumberOfStorageNodes:" << strerror(errno) << endl; 01574 free( Parameter ); 01575 01576 return ERROR_RIOPROXY + ERROR_MEMORY; 01577 } 01578 01579 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01580 01581 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 01582 // Check if Parameter buffer is large enough 01583 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01584 { 01585 free( Parameter ); 01586 01587 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01588 } 01589 01590 int offset = 0; 01591 01592 // Set parameters on asii buffer 01593 // Set Session Id 01594 SetLong( Parameter,Session.Version,&offset ); 01595 SetLong( Parameter,Session.Index,&offset ); 01596 01597 // Update Parameter size to actual size 01598 // ( previously was maximum possible size ) 01599 ParameterSize = offset; 01600 01601 // Call remote method 01602 status = m_TCPconnection->Call( RioClassSessionManager, 01603 RioMethodSessionManagerGetNumberOfStorageNodes, 01604 ParameterSize, 01605 Parameter, 01606 &ResultSize, 01607 &Result ); 01608 01609 // check if call failed 01610 if( FAILED( status ) ) 01611 { 01612 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01613 status = ERROR_RIOPROXY + ERROR_MEMORY; 01614 if( Result != NULL ) 01615 free( Result ); 01616 free( Parameter ); 01617 01618 return status; 01619 } 01620 01621 offset = 0; 01622 // Get results from result buffer 01623 // Get method return value 01624 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01625 { 01626 free( Parameter ); 01627 free( Result ); 01628 01629 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01630 } 01631 01632 // Get NumberOfStorageNodes 01633 if( !GetULong( Result,ResultSize,NumberOfStorageNodes,&offset ) ) 01634 { 01635 free( Parameter ); 01636 free( Result ); 01637 01638 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01639 } 01640 01641 free( Parameter ); 01642 free( Result ); 01643 01644 return status; 01645 }
HRESULT CSessionManager::GetObjectInfo | ( | RioSessionId | Session, | |
const char * | ObjectName, | |||
ObjectInfo * | ObjectInfo | |||
) |
Definition at line 1209 of file interface/SessionManager.cpp.
01212 { 01213 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01214 char *Result; 01215 unsigned int ParameterSize; 01216 unsigned int ResultSize; 01217 AccessTime LastModificationTime; 01218 HRESULT status; 01219 01220 if( Parameter == NULL ) 01221 { 01222 RioErr << "malloc error GetObjectInfo:" << strerror(errno) << endl; 01223 free( Parameter ); 01224 01225 return ERROR_RIOPROXY + ERROR_MEMORY; 01226 } 01227 01228 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01229 01230 ParameterSize = 2*MAX_LONG_STRING_SIZE + strlen( ObjectName )+1 + 1; 01231 // Check if Parameter buffer is large enough 01232 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01233 { 01234 free( Parameter ); 01235 01236 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01237 } 01238 01239 int offset = 0; 01240 01241 // Set parameters on asii buffer 01242 // Set Session Id 01243 SetLong( Parameter,Session.Version,&offset ); 01244 SetLong( Parameter,Session.Index,&offset ); 01245 01246 // Set Object name 01247 SetString( Parameter, ObjectName, &offset ); 01248 01249 // Update Parameter size to actual size 01250 // ( previously was maximum possible size ) 01251 ParameterSize = offset; 01252 01253 // Call remote method 01254 status = m_TCPconnection->Call( RioClassSessionManager, 01255 RioMethodSessionManagerGetObjectInfo, 01256 ParameterSize, 01257 Parameter, 01258 &ResultSize, 01259 &Result ); 01260 01261 // check if call failed 01262 if( FAILED( status ) ) 01263 { 01264 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01265 status = ERROR_RIOPROXY + ERROR_MEMORY; 01266 if( Result != NULL ) 01267 free( Result ); 01268 free( Parameter ); 01269 01270 return status; 01271 } 01272 01273 offset = 0; 01274 // Get results from result buffer 01275 // Get method return value 01276 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01277 { 01278 free( Parameter ); 01279 free( Result ); 01280 01281 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01282 } 01283 01284 // Get Object Info 01285 01286 short shortvalue; 01287 01288 // Get Object type 01289 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01290 { 01291 free( Parameter ); 01292 free( Result ); 01293 01294 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01295 } 01296 ObjectInfo->setType( shortvalue ); 01297 01298 // Get Permission 01299 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01300 { 01301 free( Parameter ); 01302 free( Result ); 01303 01304 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01305 } 01306 ObjectInfo->setPermission( shortvalue ); 01307 01308 // Get Object Size 01309 unsigned int highpart; 01310 unsigned int lowpart; 01311 if( !GetULong( Result,ResultSize,&highpart,&offset ) ) 01312 { 01313 free( Parameter ); 01314 free( Result ); 01315 01316 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM; 01317 } 01318 if( !GetULong( Result,ResultSize,&lowpart,&offset ) ) 01319 { 01320 free( Parameter ); 01321 free( Result ); 01322 01323 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM; 01324 } 01325 ObjectInfo->setSize( ( ( ( RioObjectSize ) highpart ) << 32 ) | lowpart ); 01326 01327 // Get Last modification time ( year ) 01328 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01329 { 01330 free( Parameter ); 01331 free( Result ); 01332 01333 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01334 } 01335 01336 LastModificationTime.Year = shortvalue; 01337 01338 // Get Last modification time ( month ) 01339 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01340 { 01341 free( Parameter ); 01342 free( Result ); 01343 01344 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01345 } 01346 LastModificationTime.Month = shortvalue; 01347 01348 // Get Last modification time ( day of week ) 01349 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01350 { 01351 free( Parameter ); 01352 free( Result ); 01353 01354 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01355 } 01356 LastModificationTime.DayOfWeek = shortvalue; 01357 01358 // Get Last modification time ( day ) 01359 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01360 { 01361 free( Parameter ); 01362 free( Result ); 01363 01364 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01365 } 01366 LastModificationTime.Day = shortvalue; 01367 01368 // Get Last modification time ( hour ) 01369 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01370 { 01371 free( Parameter ); 01372 free( Result ); 01373 01374 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01375 } 01376 LastModificationTime.Hour = shortvalue; 01377 01378 // Get Last modification time ( Minute ) 01379 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01380 { 01381 free( Parameter ); 01382 free( Result ); 01383 01384 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01385 } 01386 LastModificationTime.Minute = shortvalue; 01387 ObjectInfo->setTime( LastModificationTime ); 01388 01389 char *str; 01390 01391 // Get Owner User Name 01392 if( !GetString( Result,ResultSize,&str,&offset ) ) 01393 { 01394 free( Parameter ); 01395 free( Result ); 01396 01397 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01398 } 01399 if( strlen( str ) <= ( unsigned int ) MaxObjectInfoNameSize ) 01400 { 01401 ObjectInfo->setOwner( str ); 01402 } 01403 else 01404 { 01405 char owner[MaxObjectInfoNameSize]; 01406 strncpy ( owner,str,MaxObjectInfoNameSize ); 01407 owner[MaxObjectInfoNameSize-1] = 0; 01408 ObjectInfo->setOwner( owner ); 01409 } 01410 01411 // Get Owner Group Name 01412 if( !GetString( Result,ResultSize,&str,&offset ) ) 01413 { 01414 free( Parameter ); 01415 free( Result ); 01416 01417 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01418 } 01419 if( strlen( str ) <= ( unsigned int ) MaxObjectInfoNameSize ) 01420 { 01421 ObjectInfo->setGroup( str ); 01422 } 01423 else 01424 { 01425 char group[MaxObjectInfoNameSize]; 01426 strncpy ( group,str,MaxObjectInfoNameSize ); 01427 group[MaxObjectInfoNameSize-1] = 0; 01428 ObjectInfo->setGroup( group ); 01429 } 01430 01431 // Get Video Rate (usado pela implementacao do controle de fluxo). 01432 unsigned int VideoRate; 01433 if( !GetULong( Result,ResultSize,&VideoRate,&offset ) ) 01434 { 01435 #ifdef RIO_DEBUG2 01436 RioErr << "CSessionManager::GetObjectInfo metodo nao possui a taxa. " 01437 << "Usando a taxa igual a 0" << endl; 01438 #endif 01439 VideoRate = 0; 01440 } 01441 ObjectInfo->setVideoRate( VideoRate ); 01442 01443 // Get MD5 checksum 01444 if( !GetString( Result,ResultSize,&str,&offset ) ) 01445 { 01446 #ifdef RIO_DEBUG2 01447 RioErr << "CSessionManager::GetObjectInfo metodo nao possui o MD5. " 01448 << "Usando um valor NULL" << endl; 01449 ObjectInfo->setMd5sum( NULL ); 01450 #endif 01451 } 01452 else 01453 { 01454 if( strlen( str ) <= ( unsigned int ) MaxObjectInfoNameSize ) 01455 { 01456 ObjectInfo->setMd5sum( str ); 01457 } 01458 else 01459 { 01460 char md5[MaxObjectInfoNameSize]; 01461 strncpy ( md5,str,MaxObjectInfoNameSize ); 01462 md5[MaxObjectInfoNameSize-1] = 0; 01463 ObjectInfo->setMd5sum( md5 ); 01464 } 01465 } 01466 01467 free( Parameter ); 01468 free( Result ); 01469 01470 return status; 01471 }
HRESULT CSessionManager::GetRTT | ( | struct timeval * | RTT_openConnection, | |
struct timeval * | RTT_openStream | |||
) |
Definition at line 2328 of file interface/SessionManager.cpp.
02330 { 02331 RTT_openConnection->tv_sec = m_RTT_openConnection.tv_sec; 02332 RTT_openConnection->tv_usec = m_RTT_openConnection.tv_usec; 02333 02334 RTT_openStream->tv_sec = m_RTT_openStream.tv_sec; 02335 RTT_openStream->tv_usec = m_RTT_openStream.tv_usec; 02336 02337 return S_OK; 02338 }
HRESULT CSessionManager::GetServerAddress | ( | struct sockaddr_in ** | ServerAddress, | |
unsigned int * | ServerAddressSize | |||
) |
Esta funcao faz uma chamada remota a um procedimento do Servidor RIO para obter todos os pares IP, porta para os quais precisaremos enviar periodicamente mensagens Fake para garantir que os enderecos associados ao mapeamento continuarao validos.
Nota: esta funcao foi baseada na funcao Open da classe.
ServerAddress | ponteiro para um ponteiro para um vetor que contera os enderecos (pares IP, porta) do Rio Server e dos Storage Servers. | |
ServerAddressSize | ponteiro para a variavel que armazenara o tamanho deste vetor com os enderecos. |
Definition at line 2348 of file interface/SessionManager.cpp.
02350 { 02351 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02352 char *Result; 02353 unsigned int ParameterSize; 02354 unsigned int ResultSize; 02355 HRESULT status; 02356 unsigned int IP, Size; 02357 unsigned short Port; 02358 int offset = 0; 02359 02360 if( Parameter == NULL ) 02361 { 02362 #ifdef RIO_DEBUG1 02363 RioErr << "malloc error GetServerAddress:" << strerror(errno) << endl; 02364 #endif 02365 free( Parameter ); 02366 02367 return ERROR_RIOPROXY + ERROR_MEMORY; 02368 } 02369 02370 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02371 02372 // Inicializa o retorno da funcao 02373 02374 *ServerAddress = NULL; 02375 *ServerAddressSize = 0; 02376 02377 // Set Maximum result size ( Size of buffer ) 02378 //ResultSize = MaxTCPDataSize; 02379 02380 ParameterSize = 0; 02381 02382 // Faz a chamada remota a uma funcao do Servidor RIO para obter os IPs e 02383 // as portas dos servidores. 02384 status = m_TCPconnection->Call( RioClassSessionManager, 02385 RioMethodSessionManagerGetServerAddress, 02386 ParameterSize, 02387 Parameter, 02388 &ResultSize, 02389 &Result ); 02390 02391 02392 // check if call failed 02393 if( FAILED( status ) ) 02394 { 02395 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02396 status = ERROR_RIOPROXY + ERROR_MEMORY; 02397 if( Result != NULL ) 02398 free( Result ); 02399 free( Parameter ); 02400 02401 return status; 02402 } 02403 02404 // Extrai da mensagem recebida como resposta a chamada anterior a 02405 // lista com os IPs e as portas dos servidores. 02406 02407 offset = 0; 02408 02409 // O primeiro campo da mensagem e o numero pares IP, porta da lista. 02410 if( !GetULong( Result, ResultSize, &Size, &offset ) ) 02411 { 02412 free( Parameter ); 02413 free( Result ); 02414 02415 #ifdef RIO_DEBUG1 02416 RioErr << "CSessionManager::GetServerAddress GetULong em Size" 02417 << endl; 02418 #endif 02419 02420 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02421 } 02422 02423 *ServerAddressSize = Size; 02424 02425 #ifdef RIO_DEBUG1 02426 RioErr << "CSessionManager::GetServerAddress ServerAddressSize = " 02427 << *ServerAddressSize << endl; 02428 #endif 02429 02430 // Aloca o vetor que armazenara as estruturas com os enderecos dos 02431 // servidores. 02432 *ServerAddress = new sockaddr_in[ *ServerAddressSize ]; 02433 if( *ServerAddress == NULL ) 02434 { 02435 #ifdef RIO_DEBUG1 02436 RioErr << "CSessionManager::GetServerAddress Erro ao alocar o vetor" 02437 << endl; 02438 #endif 02439 free( Parameter ); 02440 free( Result ); 02441 02442 return ERROR_RIOPROXY + ERROR_MEMORY; 02443 } 02444 02445 // Extrai o endereco IP e a porta de cada um dos servidores da mensagem. 02446 for( unsigned int i = 0; i < *ServerAddressSize; i++ ) 02447 { 02448 // Obtem o IP de um dos servidores. 02449 if( !GetULong( Result, ResultSize, &IP, &offset ) ) 02450 { 02451 free( Parameter ); 02452 free( Result ); 02453 free( *ServerAddress ); 02454 02455 #ifdef RIO_DEBUG1 02456 RioErr << "CSessionManager::GetServerAddress GetULong em IP" 02457 << " no indice i = " << i << endl; 02458 #endif 02459 02460 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02461 } 02462 // Obtem a porta de um dos servidores. 02463 if( !GetUShort( Result, ResultSize, &Port, &offset ) ) 02464 { 02465 free( Parameter ); 02466 free( Result ); 02467 free( *ServerAddress ); 02468 02469 #ifdef RIO_DEBUG1 02470 RioErr << "CSessionManager::GetServerAddress GetUShort em Port" 02471 << " no indice i = " << i << endl; 02472 #endif 02473 02474 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02475 } 02476 (*ServerAddress)[ i ].sin_family = AF_INET; 02477 (*ServerAddress)[ i ].sin_port = htons( Port ); 02478 (*ServerAddress)[ i ].sin_addr.s_addr = htonl( IP ); 02479 02480 #ifdef RIO_DEBUG1 02481 RioErr << "CSessionManager::GetServerAddress ServerAddress[" 02482 << i << "].sin_port = " 02483 << ntohs( (*ServerAddress)[ i ].sin_port ) << endl; 02484 RioErr << "CSessionManager::GetServerAddress ServerAddress[" 02485 << i << "].sin_addr.s_addr = " 02486 << inet_ntoa( (*ServerAddress)[ i ].sin_addr ) << endl; 02487 #endif 02488 02489 } 02490 02491 free( Parameter ); 02492 free( Result ); 02493 02494 return S_OK; 02495 }
HRESULT CSessionManager::GetStorageNodeInfo | ( | RioSessionId | Session, | |
RioStorageNodeInfo * | StorageNodeInfo, | |||
unsigned int | StorageNodeIndex | |||
) |
Definition at line 1824 of file interface/SessionManager.cpp.
01827 { 01828 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01829 char *Result; 01830 unsigned int ParameterSize; 01831 unsigned int ResultSize; 01832 HRESULT status; 01833 01834 if( Parameter == NULL ) 01835 { 01836 RioErr << "malloc error GetStorageNodeInfo:" << strerror(errno) << endl; 01837 free( Parameter ); 01838 01839 return ERROR_RIOPROXY + ERROR_MEMORY; 01840 } 01841 01842 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01843 01844 ParameterSize = 2*MAX_LONG_STRING_SIZE + sizeof( StorageNodeIndex ); 01845 // Check if Parameter buffer is large enough 01846 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01847 { 01848 free( Parameter ); 01849 01850 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01851 } 01852 01853 int offset = 0; 01854 01855 // Set parameters on asii buffer 01856 // Set Session Id 01857 SetLong( Parameter,Session.Version,&offset ); 01858 SetLong( Parameter,Session.Index,&offset ); 01859 01860 // Set StorageNodeIndex 01861 SetLong( Parameter,StorageNodeIndex,&offset ); 01862 01863 // Update Parameter size to actual size 01864 // ( previously was maximum possible size ) 01865 ParameterSize = offset; 01866 01867 // Call remote method 01868 status = m_TCPconnection->Call( RioClassSessionManager, 01869 RioMethodSessionManagerGetStorageNodeInfo, 01870 ParameterSize, 01871 Parameter, 01872 &ResultSize, 01873 &Result ); 01874 01875 // check if call failed 01876 if( FAILED( status ) ) 01877 { 01878 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01879 status = ERROR_RIOPROXY + ERROR_MEMORY; 01880 if( Result != NULL ) 01881 free( Result ); 01882 free( Parameter ); 01883 01884 return status; 01885 } 01886 01887 offset = 0; 01888 // Get results from result buffer 01889 // Get method return value 01890 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01891 { 01892 free( Parameter ); 01893 free( Result ); 01894 01895 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01896 } 01897 01898 // Get StorageNode Info 01899 char *str; 01900 01901 // Get Hostname 01902 if( !GetString( Result,ResultSize,&str,&offset ) ) 01903 { 01904 free( Parameter ); 01905 free( Result ); 01906 01907 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01908 } 01909 if( strlen( str ) <= 60 ) 01910 { 01911 strcpy( StorageNodeInfo->Hostname,str ); 01912 } 01913 else 01914 { 01915 strncpy ( StorageNodeInfo->Hostname,str,60 ); 01916 StorageNodeInfo->Hostname[59] = '\0'; 01917 } 01918 01919 short shortvalue; 01920 01921 // Get NumberOfDisks 01922 if( !GetShort( Result,ResultSize,&shortvalue,&offset ) ) 01923 { 01924 free( Parameter ); 01925 free( Result ); 01926 01927 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01928 } 01929 StorageNodeInfo->NumberOfDisks = shortvalue; 01930 int i; 01931 // for each disk get DiskName, Size, FreeBlocks 01932 for( i = 0; i < shortvalue ; i++ ) { 01933 // Get Hostname 01934 if( !GetString( Result,ResultSize,&str,&offset ) ) 01935 { 01936 free( Parameter ); 01937 free( Result ); 01938 01939 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01940 } 01941 if( strlen( str ) < MaxPathSize ) 01942 { 01943 strcpy( StorageNodeInfo->Disks[i].DiskName,str ); 01944 } 01945 else 01946 { 01947 strncpy ( StorageNodeInfo->Disks[i].DiskName,str, MaxPathSize-1 ); 01948 StorageNodeInfo->Disks[i].DiskName[ MaxPathSize-1 ] = '\0'; 01949 } 01950 // Get Disk Size 01951 unsigned int highpart; 01952 unsigned int lowpart; 01953 if( !GetULong( Result,ResultSize,&highpart,&offset ) ) 01954 { 01955 free( Parameter ); 01956 free( Result ); 01957 01958 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM; 01959 } 01960 if( !GetULong( Result,ResultSize,&lowpart,&offset ) ) 01961 { 01962 free( Parameter ); 01963 free( Result ); 01964 01965 return ERROR_CONNECTIONMANAGER + ERROR_INVALID_METHOD_PARAM; 01966 } 01967 StorageNodeInfo->Disks[i].Size = 01968 ( ( ( RioObjectSize ) highpart ) << 32 ) | lowpart; 01969 // Get NumberOfFreeBlocks 01970 if( !GetULong( Result,ResultSize, 01971 &StorageNodeInfo->Disks[i].NumberOfFreeBlocks,&offset ) ) 01972 { 01973 free( Parameter ); 01974 free( Result ); 01975 01976 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01977 } 01978 } 01979 01980 free( Parameter ); 01981 free( Result ); 01982 01983 return status; 01984 }
HRESULT CSessionManager::GetUserList | ( | vector< string > & | UserList | ) |
Nova funcao para obter a lista com todos os usuarios.
USerList | vetor de strings (STL) no qual a lista de usuarios sera armazenada. |
Definition at line 3095 of file interface/SessionManager.cpp.
03096 { 03097 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 03098 char *Result; 03099 unsigned int ParameterSize; 03100 unsigned int ResultSize; 03101 HRESULT status; 03102 unsigned int UserListSize; 03103 char *UserName; 03104 03105 // Limpa o vetor. 03106 UserList.clear(); 03107 03108 if( Parameter == NULL ) 03109 { 03110 RioErr << "malloc error ChangePassword:" << strerror(errno) << endl; 03111 free( Parameter ); 03112 03113 return ERROR_RIOPROXY + ERROR_MEMORY; 03114 } 03115 03116 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 03117 03118 ParameterSize = 0; 03119 // Check if Parameter buffer is large enough 03120 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 03121 { 03122 free( Parameter ); 03123 03124 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 03125 } 03126 03127 int offset = 0; 03128 03129 // Update Parameter size to actual size 03130 // ( previously was maximum possible size ) 03131 ParameterSize = offset; 03132 03133 // Call remote method 03134 status = m_TCPconnection->Call( RioClassUserManager, 03135 RioMethodUserManagerUserList, 03136 ParameterSize, 03137 Parameter, 03138 &ResultSize, 03139 &Result ); 03140 03141 // check if call failed 03142 if( FAILED( status ) ) 03143 { 03144 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 03145 status = ERROR_RIOPROXY + ERROR_MEMORY; 03146 if( Result != NULL ) 03147 free( Result ); 03148 free( Parameter ); 03149 03150 return status; 03151 } 03152 03153 offset = 0; 03154 // Get results from result buffer 03155 // Get method return value 03156 if( !GetLong( Result, ResultSize, &status, &offset ) ) 03157 { 03158 free( Parameter ); 03159 free( Result ); 03160 03161 03162 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 03163 } 03164 03165 // Se nao ocorreu um erro ao obter a lista, pega os nomes dos usuarios. 03166 if( !FAILED( status ) ) 03167 { 03168 // Obtem o numero de usuarios no sistema. 03169 if( !GetULong( Result, ResultSize, &UserListSize, &offset ) ) 03170 { 03171 free( Parameter ); 03172 free( Result ); 03173 03174 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 03175 } 03176 03177 #ifdef RIO_DEBUG2 03178 RioErr << "CSessionManager::GetUserList tamanho recebido na mensagem: " 03179 << UserListSize << endl; 03180 #endif 03181 03182 // Obtem cada um dos nomes dos usuarios, e os insere no vetor. 03183 for( unsigned int i = 0; i < UserListSize; i++ ) 03184 { 03185 if( !GetString( Result, ResultSize, &UserName, &offset ) ) 03186 { 03187 // Limpa o vetor. 03188 UserList.clear(); 03189 03190 free( Parameter ); 03191 free( Result ); 03192 03193 // Limpa o vetor. 03194 UserList.clear(); 03195 03196 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 03197 } 03198 03199 #ifdef RIO_DEBUG2 03200 RioErr << "CSessionManager::GetUserList Recebida a string " 03201 << UserName << endl; 03202 #endif 03203 03204 // Tenta adicionar o usuario a lista 03205 try 03206 { 03207 UserList.push_back( string( UserName ) ); 03208 } 03209 catch( bad_alloc &ba ) 03210 { 03211 free( Parameter ); 03212 free( Result ); 03213 03214 // Limpa o vetor. 03215 UserList.clear(); 03216 03217 return ERROR_RIOPROXY + ERROR_MEMORY; 03218 } 03219 } 03220 03221 #ifdef RIO_DEBUG2 03222 // Mostra a lista recebida 03223 RioErr << "CSessionManager::GetUserList lista de usuarios recebida, com " 03224 << UserList.size() << " usuarios: "; 03225 for( unsigned int i = 0; i < UserList.size(); i++ ) 03226 { 03227 RioErr << UserList[ i ]; 03228 if( i != ( UserList.size() - 1 ) ) 03229 RioErr << ","; 03230 } 03231 RioErr << endl; 03232 #endif 03233 03234 } 03235 03236 free( Parameter ); 03237 free( Result ); 03238 03239 return status; 03240 }
int CSessionManager::GetVideoDuration | ( | char * | VideoName | ) | [private] |
Le do arquivo cactimes que contem o tempo para tocar cada bloco do video.
Este arquivo (cactimes) deve estar no mesmo diretorio do video, porem copiado pelo sistema de arquivos do linux e nao do RIO. Nao esta sendo utilizado atualmente mas sera mantido pois pode ser util no futuro.
Definition at line 858 of file server/SessionManager.cpp.
00859 { 00860 int video_duration = 0; 00861 double aux_video_duration = 0; 00862 double sum = 0; 00863 00864 char *auxpath; 00865 auxpath = new char[255]; 00866 auxpath = strtok( VideoName, "." ); 00867 00868 char *path; 00869 path = new char[255]; 00870 00871 sprintf( path, "%s/%s.cactimes", m_FileRoot, auxpath ); 00872 00873 FILE *CACFile; 00874 00875 if( ( CACFile = fopen ( path, "r" ) ) == NULL ) 00876 { 00877 Rioperror( "fopen" ); 00878 } 00879 else 00880 { 00881 while( 1 ) 00882 { 00883 if( fscanf( CACFile, "%lf", &aux_video_duration ) != 1 ) 00884 { 00885 RioErr << "CSessionManager::GetVideoDuration: aviso - erro ao " 00886 << "ler o arquivo " << path << endl; 00887 } 00888 sum += aux_video_duration; 00889 00890 if( feof( CACFile ) ) 00891 break; 00892 } 00893 } 00894 00895 video_duration = ( int ) sum; 00896 00897 return( video_duration ); 00898 }
int CSessionManager::Initialize | ( | SessionManagerConfig * | Config | ) |
Definition at line 157 of file server/SessionManager.cpp.
00158 { 00159 pthread_attr_t attrib; 00160 00161 // Check if not initialized yet 00162 if( m_initialized ) 00163 { 00164 if( m_log.is_open() ) 00165 m_log << "Initialize(): Tried to initialize component " 00166 << " already initialized" << endl; 00167 00168 return ERROR_SESSIONMANAGER + ERROR_INITIALIZED; 00169 } 00170 00171 m_LogsDirectory = Config->LogsDirectory; 00172 00173 if( Config->GenerateLogs ) 00174 { 00175 // Variavel usada para compor o nome do arquivo com o log. 00176 char LogFileName[ MaxPathSize ]; 00177 // Compoe o nome do arquivo com o log. 00178 strcpy( LogFileName, m_LogsDirectory ); 00179 strcat( LogFileName, LOGFILE ); 00180 m_log.open( LogFileName ); 00181 // Check if log file was opened successfully 00182 if( !m_log.is_open() ) 00183 { 00184 return ERROR_SESSIONMANAGER + ERROR_LOGFILE ; 00185 } 00186 } 00187 00188 m_SystemManager = Config->SystemManager; 00189 m_StreamManager = Config->StreamManager; 00190 m_ObjectManager = Config->ObjectManager; 00191 m_UserManager = Config->UserManager; 00192 m_Router = Config->Router; 00193 m_DiskMgr = Config->diskMgr; 00194 m_NumberOfDisks = Config->NumberOfDisks; 00195 m_NumberOfStorageNodes = Config->NumberOfStorageNodes; 00196 // ------------------------------------------------------------------------ 00197 RioErr << "Config->FileRoot " << Config->FileRoot<< endl; 00198 m_FileRoot = new char[ strlen( Config->FileRoot ) + 1 ]; 00199 strcpy( m_FileRoot, Config->FileRoot ); 00200 RioErr << "m_FileRoot " << m_FileRoot << endl; 00201 00202 m_MaxSessions = Config->MaxSessions; 00203 m_BlockSize = Config->BlockSize; 00204 00205 // Alocate Session table 00206 m_SessionTable = new SessionEntry[Config->MaxSessions]; 00207 if( m_SessionTable == 0 ) 00208 { 00209 if( m_log.is_open() ) 00210 m_log << "Initialize(): Failed to allocate memory" << endl; 00211 00212 m_ObjectManager = 0; 00213 m_StreamManager = 0; 00214 return ERROR_SESSIONMANAGER + ERROR_MEMORY; 00215 } 00216 00217 // Initialize Session Table 00218 for( int i = 0; i < Config->MaxSessions; i++ ) 00219 { 00220 m_SessionTable[i].Session.Index = -1; 00221 m_SessionTable[i].Session.Version = 0; 00222 m_SessionTable[i].s_ptr = 0; 00223 } 00224 00225 m_used = 0; 00226 00227 // Inicializa o campo m_ServerAddressSize inicialmente com o numero de 00228 // Storage Servers. 00229 m_DiskMgr->GetNumberOfStorageNodes( &m_ServerAddressSize ); 00230 // Devemos considerar tambem o par IP, porta do Servidor RIO. 00231 m_ServerAddressSize = m_ServerAddressSize + 1; 00232 00233 // Aloca o vetor que armazenara os pares IP, porta do Servidor RIO e dos 00234 // Storage Servers. 00235 m_ServerAddress = new SOCKADDR_IN[ m_ServerAddressSize ]; 00236 if( m_ServerAddress == NULL ) 00237 { 00238 if( m_log.is_open() ) 00239 m_log << "Initialize(): Failed to allocate memory" << endl; 00240 return ERROR_SESSIONMANAGER + ERROR_MEMORY; 00241 } 00242 // Inicializa o vetor com os IPs e as portas das maquinas. 00243 // A primeira entrada e inicializada com o par IP, porta do Servidor RIO, 00244 // obtido a partir da classe (a porta sempre e dada pela constante 00245 // RIOSERVERUDPPORT. Devemos envia-la ao cliente para permitir que 00246 // este independa do modo como o servidor foi compilado). 00247 m_ServerAddress[ 0 ].sin_family = AF_INET; 00248 m_ServerAddress[ 0 ].sin_port = htons( RIOSERVERUDPPORT ); 00249 //m_ServerAddress[ 0 ].sin_addr.s_addr = m_StreamManager->GetNetMgrIPAddr(); 00250 m_ServerAddress[ 0 ].sin_addr.s_addr = m_StreamManager-> 00251 GetNetInterfaceIPAddr(); 00252 // Inicialia as outras entradas do vetor com o par IP, porta de cada um 00253 // dos Storage Servers a porta sempre e dada pela constante, usando 00254 // a funcao GetStorageServersAddress da classe DiskMgr. 00255 m_DiskMgr->GetStorageServersAddress( &m_ServerAddress[ 1 ] ); 00256 // Inicializa o novo campo usado para indicar o tempo maximo que o servidor 00257 // espera por uma requisicao de um cliente. Se a opcao nao for usada, ou se 00258 // o seu valor for 0, entao nao teremos um tempo maximo (como ocorria 00259 // antes). 00260 m_ClientsTimeOut = Config->ClientsTimeOut; 00261 00262 m_TCPconnection = new CRioTCP; 00263 00264 int hResult = m_TCPconnection->InitServer( RioTCPport ); 00265 if( FAILED( hResult) ) 00266 { 00267 if( m_log.is_open() ) 00268 m_log << "Initialize(): Failed to Initialize server TCP connection," 00269 << " rc: " << hResult << endl; 00270 CleanUp(); 00271 return hResult; 00272 } 00273 00274 pthread_attr_init( &attrib ); 00275 pthread_attr_setstacksize( &attrib, 2*PTHREAD_STACK_MIN ); 00276 00277 if( pthread_create( &m_ConnectionThreadId, &attrib, &ConnectionThread, 00278 this ) ) 00279 { 00280 if( m_log.is_open() ) 00281 { 00282 m_log << "Start(): Failed to create thread (connection thread)" 00283 << endl << " ERROR: " << strerror(errno) << endl; 00284 } 00285 CleanUp(); 00286 return ERROR_SESSIONMANAGER + ERROR_CREATE_THREAD; 00287 } 00288 00289 // Inicializa o ponteiro para o objeto da classe NetMgr (m_NetMgr) com o 00290 // objeto criado ao inicializarmos o objeto da classe CStreamManager. 00291 m_NetMgr = m_StreamManager->getNetMgr(); 00292 00293 // Inicializa o ponteiro para o objeto da classe CNetInterface 00294 // (m_NetInterface) com o objeto criado ao inicializarmos o objeto da classe 00295 // CStreamManager. 00296 m_NetInterface = m_StreamManager->getNetInterface(); 00297 00298 // Cria o objeto da classe CLogRotation, que ira armazenar os logs de acesso 00299 // dos clientes. 00300 // Cria o novo objeto da classe CLogRotation. 00301 m_LogRotation = new CLogRotation; 00302 if( m_LogRotation == NULL ) 00303 { 00304 if( m_log.is_open() ) 00305 m_log << "Initialize(): erro ao criar o objeto com os logs." 00306 << endl; 00307 CleanUp(); 00308 return ERROR_SESSIONMANAGER + ERROR_MEMORY; 00309 } 00310 else 00311 { 00312 // Define o nome para os prefixo dos logs. 00313 char LogFileNamePrefix[ MaxPathSize ]; 00314 strcpy( LogFileNamePrefix, Config->LogsDirectory ); 00315 strcat( LogFileNamePrefix, "ServerLog_" ); 00316 // Adiciona o IP do servidor (a porta nao sera necessaria, pois dois 00317 // servidores nao podem executar na mesma maquina). 00318 strcat( LogFileNamePrefix, inet_ntoa( m_ServerAddress[ 0 ].sin_addr ) ); 00319 00320 #ifdef RIO_DEBUG2 00321 RioErr << "CSessionManager::Initialize LogFileNamePrefix = " 00322 << LogFileNamePrefix << endl; 00323 #endif 00324 00325 if( m_LogRotation->Initialize( LogFileNamePrefix, 00326 Config->MaxLogFileSize, 00327 Config->MaxCombinedLogFilesSize, 00328 Config->SaveLogs ) != S_OK ) 00329 { 00330 if( m_log.is_open() ) 00331 m_log << "Initialize(): erro ao inicializar o objeto com os " 00332 << "logs." << endl; 00333 delete m_LogRotation; 00334 m_LogRotation = NULL; 00335 CleanUp(); 00336 return ERROR_SESSIONMANAGER + ERROR_INITIALIZE_LOGROTATION; 00337 } 00338 // Cria a nova classe para fazer buscas nos logs dos clientes. 00339 m_SearchLogs = new CSearchLogs; 00340 if( m_SearchLogs == NULL ) 00341 { 00342 // Devemos ou nao parar o servidor neste caso? 00343 if( m_log.is_open() ) 00344 m_log << "Initialize(): erro ao criar o objeto de busca nos " 00345 << "logs." 00346 << endl; 00347 delete m_LogRotation; 00348 m_LogRotation = NULL; 00349 CleanUp(); 00350 return ERROR_SESSIONMANAGER + ERROR_MEMORY; 00351 } 00352 if( m_SearchLogs->Initialize( m_LogRotation, m_NetMgr, m_LogsDirectory, 00353 "Server-", m_BlockSize, m_NetInterface ) 00354 != S_OK ) 00355 { 00356 // Devemos ou nao parar o servidor neste caso? 00357 if( m_log.is_open() ) 00358 m_log << "Initialize(): erro ao inicializar o objeto de busca " 00359 << "nos logs." 00360 << endl; 00361 delete m_LogRotation; 00362 m_LogRotation = NULL; 00363 delete m_SearchLogs; 00364 m_SearchLogs = NULL; 00365 CleanUp(); 00366 return ERROR_SESSIONMANAGER + ERROR_INITIALIZE_SEARCHLOGS; 00367 } 00368 } 00369 00370 m_initialized = true; 00371 00372 return S_OK; 00373 }
void CSessionManager::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 915 of file server/SessionManager.cpp.
00916 { 00917 NATData StorageNat; 00918 00919 // Obtem o acesso exclusivo a estrutura m_SessionTable. 00920 pthread_mutex_lock( &m_mutex ); 00921 // Varre as sessoes de todos os clientes conectados, invalidando os 00922 // mapeamentos do servidor de armazenamento passado como parametro. 00923 for( int i = 0; i < m_MaxSessions; i++ ) 00924 if( m_SessionTable[ i ].Session.Index != -1 ) 00925 { 00926 StorageNat = m_Router->GetNATMapping( 00927 m_SessionTable[ i ].s_ptr->s_ServerNat, 00928 StorageId ); 00929 00930 #ifdef RIO_DEBUG2 00931 in_addr ip; 00932 ip.s_addr = StorageNat.nat_addr; 00933 RioErr << "CSessionManager::InvalidateStorageNatMappings " 00934 << " alterando endereco do servidor com a Id " 00935 << StorageId << " do IP " << inet_ntoa( ip ) << " e a porta " 00936 << ntohs( StorageNat.nat_port ) << " para 0.0.0.0 e 0" 00937 << endl; 00938 #endif 00939 00940 // Altera o endereco para 255.255.255.255 (-1) e a porta para 0. 00941 StorageNat.nat_addr = -1; 00942 StorageNat.nat_port = 0; 00943 m_Router->SetNATMapping( m_SessionTable[ i ].s_ptr->s_ServerNat, 00944 StorageId, StorageNat ); 00945 // Somente para confirmar a alteracao (REMOVER DEPOIS) 00946 StorageNat = m_Router->GetNATMapping( 00947 m_SessionTable[ i ].s_ptr->s_ServerNat, 00948 StorageId ); 00949 00950 #ifdef RIO_DEBUG2 00951 ip.s_addr = StorageNat.nat_addr; 00952 RioErr << "CSessionManager::InvalidateStorageNatMappings " 00953 << " novo endereco para o servidor com a Id " 00954 << StorageId << ": IP " << inet_ntoa( ip ) << " e a porta " 00955 << ntohs( StorageNat.nat_port ) << endl; 00956 #endif 00957 00958 // Verifica se precisamos invalidar o mapeamento da nova 00959 // implementacao de rede. 00960 // 00961 // TODO: Remover todo o codigo dentro do if a seguir, incluindo o 00962 // comando if, quando a RioNeti e a NetMgr nao forem mais usadas. 00963 // 00964 if( m_Router->FindNATMapping( 00965 m_SessionTable[ i ].s_ptr->s_ServerNat, 00966 StorageId + m_NumberOfStorageNodes ) ) 00967 { 00968 StorageNat = m_Router->GetNATMapping( 00969 m_SessionTable[ i ].s_ptr->s_ServerNat, 00970 StorageId + m_NumberOfStorageNodes ); 00971 00972 #ifdef RIO_DEBUG2 00973 in_addr ip; 00974 ip.s_addr = StorageNat.nat_addr; 00975 RioErr << "CSessionManager::InvalidateStorageNatMappings " 00976 << " alterando endereco do servidor com a Id " 00977 << StorageId + m_NumberOfStorageNodes << " do IP " 00978 << inet_ntoa( ip ) << " e a porta " 00979 << ntohs( StorageNat.nat_port ) << " para 0.0.0.0 e 0" 00980 << endl; 00981 #endif 00982 00983 // Altera o endereco para 255.255.255.255 (-1) e a porta para 0. 00984 StorageNat.nat_addr = -1; 00985 StorageNat.nat_port = 0; 00986 m_Router->SetNATMapping( m_SessionTable[ i ].s_ptr->s_ServerNat, 00987 StorageId + m_NumberOfStorageNodes, 00988 StorageNat ); 00989 // Somente para confirmar a alteracao (REMOVER DEPOIS) 00990 StorageNat = m_Router->GetNATMapping( 00991 m_SessionTable[ i ].s_ptr->s_ServerNat, 00992 StorageId + m_NumberOfStorageNodes ); 00993 00994 #ifdef RIO_DEBUG2 00995 ip.s_addr = StorageNat.nat_addr; 00996 RioErr << "CSessionManager::InvalidateStorageNatMappings " 00997 << " novo endereco para o servidor com a Id " 00998 << StorageId + m_NumberOfStorageNodes << ": IP " 00999 << inet_ntoa( ip ) << " e a porta " 01000 << ntohs( StorageNat.nat_port ) << endl; 01001 #endif 01002 } 01003 01004 } 01005 // Libera o acesso exclusivo a estrutura m_SessionTable. 01006 pthread_mutex_unlock( &m_mutex ); 01007 }
void CSessionManager::KillConnectionThread | ( | ) | [private] |
Definition at line 395 of file server/SessionManager.cpp.
00396 { 00397 if( m_ConnectionThreadId != 0 ) 00398 { 00399 // Signal event for thread termination 00400 m_threadStopEvent = 1; 00401 00402 // make a connection to wake up the accept in RioTCP.WaitConnection 00403 char LocalName[256]; 00404 hostent* LocalAddress; 00405 struct in_addr LocalIPaddress; 00406 int x_sock; 00407 if( gethostname( LocalName, 256 ) != 0 ) 00408 { 00409 RioErr << "SessionManager.KillConnectionThread: gethostname failed " 00410 << strerror(errno) << endl; 00411 goto closeit; 00412 } 00413 00414 // Get host IP address 00415 LocalAddress = gethostbyname(LocalName); 00416 if( LocalAddress == 0 ) 00417 { 00418 RioErr << "SessionManager.KillConnectionThread: gethostbyname failed " 00419 << strerror(errno) << endl; 00420 goto closeit; 00421 } 00422 00423 memcpy( &LocalIPaddress, LocalAddress->h_addr, 00424 sizeof( LocalIPaddress ) ); 00425 00426 // For connection thread closing socket should make the 00427 // thread exit the accept() call 00428 // {no it doesn't appear to on Linux, so first 00429 // {make a connection to wake up accept. Since 00430 // {m_threadStopEvent is set, the connection thread will 00431 // {terminate once it wakes... 00432 00433 x_sock = socket( AF_INET, SOCK_STREAM, 0 ); 00434 SOCKADDR_IN xaddr; 00435 memset( &xaddr, 0, sizeof( xaddr )); 00436 xaddr.sin_family = AF_INET; 00437 xaddr.sin_addr.s_addr = LocalIPaddress.s_addr; 00438 xaddr.sin_port = htons(RioTCPport); 00439 00440 connect( x_sock, (SOCKADDR*) &xaddr, sizeof( xaddr )); 00441 00442 closeit: 00443 00444 // closing TCP connection should make the 00445 // thread exit the WaitConnection() call 00446 m_TCPconnection->CloseSocket(); 00447 00448 // wait for thread to exit 00449 pthread_join( m_ConnectionThreadId, NULL ); 00450 00451 m_ConnectionThreadId = 0; 00452 } 00453 }
HRESULT CSessionManager::Open | ( | const char * | Username, | |
const char * | Password, | |||
RioSessionId * | Session | |||
) |
Definition at line 64 of file interface/SessionManager.cpp.
00067 { 00068 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00069 char *Result; 00070 unsigned int ParameterSize; 00071 unsigned int ResultSize; 00072 HRESULT status; 00073 00074 if( Parameter == NULL ) 00075 { 00076 RioErr << "malloc error Open:" << strerror(errno) << endl; 00077 free( Parameter ); 00078 00079 return ERROR_RIOPROXY + ERROR_MEMORY; 00080 } 00081 00082 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00083 00084 #ifdef WINDOWS 00085 // Windows implementation 00086 struct _SYSTEMTIME RTT_aux; 00087 #else 00088 // Linux implementation 00089 struct timeval RTT_aux; 00090 #endif 00091 00092 ParameterSize = strlen( UserName ) + strlen( Password ) +2; 00093 // Check if Parameter buffer is large enough 00094 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00095 { 00096 free( Parameter ); 00097 00098 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00099 } 00100 00101 int offset = 0; 00102 00103 // Set parameters on asii buffer 00104 // Set User name 00105 SetString( Parameter,UserName,&offset ); 00106 // Set Password 00107 SetString( Parameter,Password,&offset ); 00108 00109 // Update Parameter size to actual size 00110 // ( previously was maximum possible size ) 00111 ParameterSize = offset; 00112 00113 // Call remote method 00114 // calculating RTT 00115 #ifdef WINDOWS 00116 // Windows implementation 00117 GetSystemTime( &m_RTT_openConnection ); 00118 #else 00119 // Linux implementation 00120 gettimeofday( &m_RTT_openConnection, 0 ); 00121 #endif 00122 00123 status = m_TCPconnection->Call( RioClassSessionManager, 00124 RioMethodSessionManagerOpen, 00125 ParameterSize, 00126 Parameter, 00127 &ResultSize, 00128 &Result ); 00129 00130 #ifdef WINDOWS 00131 // Windows implementation 00132 GetSystemTime( &RTT_aux ); 00133 m_RTT_openConnection.wSecond = RTT_aux.wSecond - m_RTT_openConnection.wSecond; 00134 m_RTT_openConnection.wMilliseconds = RTT_aux.wMilliseconds - m_RTT_openConnection.wMilliseconds; 00135 if( m_RTT_openConnection.wMilliseconds < 0 ) 00136 { 00137 m_RTT_openConnection.wSecond -= 1; 00138 m_RTT_openConnection.wMilliseconds = m_RTT_openConnection.wMilliseconds + 1000000; 00139 } 00140 #else 00141 // Linux implementation 00142 gettimeofday( &RTT_aux, 0 ); 00143 m_RTT_openConnection.tv_sec = RTT_aux.tv_sec - m_RTT_openConnection.tv_sec; 00144 m_RTT_openConnection.tv_usec = RTT_aux.tv_usec - m_RTT_openConnection.tv_usec; 00145 if( m_RTT_openConnection.tv_usec < 0 ) 00146 { 00147 m_RTT_openConnection.tv_sec -= 1; 00148 m_RTT_openConnection.tv_usec += 1000000; 00149 } 00150 #endif 00151 00152 // check if call failed 00153 if( FAILED( status ) ) 00154 { 00155 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00156 status = ERROR_RIOPROXY + ERROR_MEMORY; 00157 if( Result != NULL ) 00158 free( Result ); 00159 free( Parameter ); 00160 00161 return status; 00162 } 00163 00164 offset = 0; 00165 // Get results from result buffer 00166 // Get method return value 00167 if( !GetLong( Result, ResultSize, &status, &offset ) ) 00168 { 00169 free( Parameter ); 00170 free( Result ); 00171 00172 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00173 } 00174 00175 // Get Session Id 00176 if( !GetLong( Result, ResultSize, &( Session->Version ), &offset ) ) 00177 { 00178 free( Parameter ); 00179 free( Result ); 00180 00181 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00182 } 00183 00184 if( !GetLong( Result, ResultSize, &( Session->Index ), &offset ) ) 00185 { 00186 free( Parameter ); 00187 free( Result ); 00188 00189 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00190 } 00191 00192 if( FAILED( status ) ) 00193 { 00194 free( Parameter ); 00195 free( Result ); 00196 00197 return status; 00198 } 00199 else 00200 { 00201 unsigned int BlockSize; 00202 if( !GetULong( Result, ResultSize, &BlockSize, &offset ) ) 00203 { 00204 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00205 } 00206 00207 free( Parameter ); 00208 free( Result ); 00209 00210 return ( int ) BlockSize; 00211 } 00212 }
HRESULT CSessionManager::OpenStream | ( | const RioSessionId | Session, | |
const RioStreamTraffic * | Traffic, | |||
RioStreamId * | Stream, | |||
int * | MaxRequests | |||
) |
Definition at line 291 of file interface/SessionManager.cpp.
00295 { 00296 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00297 char *Result; 00298 unsigned int ParameterSize; 00299 unsigned int ResultSize; 00300 HRESULT status; 00301 00302 if( Parameter == NULL ) 00303 { 00304 RioErr << "malloc error OpenStream:" << strerror(errno) << endl; 00305 free( Parameter ); 00306 00307 return ERROR_RIOPROXY + ERROR_MEMORY; 00308 } 00309 00310 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00311 00312 #ifdef WINDOWS 00313 // Windows implementation 00314 _SYSTEMTIME RTT_aux; 00315 #else 00316 // Linux implementation 00317 struct timeval RTT_aux; 00318 #endif 00319 00320 if( Traffic->Type == RIO_TRAFFIC_CBR ) 00321 { 00322 ParameterSize = 2 * MAX_LONG_STRING_SIZE + 00323 2 * MAX_SHORT_STRING_SIZE + MAX_ULONG_STRING_SIZE + 00324 MAX_LONG_STRING_SIZE + MAX_DOUBLE_STRING_SIZE + 00325 MAX_SHORT_STRING_SIZE; 00326 } 00327 else 00328 { 00329 ParameterSize = 2 * MAX_LONG_STRING_SIZE + 00330 2 * MAX_SHORT_STRING_SIZE + MAX_ULONG_STRING_SIZE + 00331 MAX_LONG_STRING_SIZE + MAX_ULONG_STRING_SIZE + 00332 MAX_SHORT_STRING_SIZE; 00333 } 00334 // Check if Parameter buffer is large enough 00335 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00336 { 00337 free( Parameter ); 00338 00339 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00340 } 00341 00342 int offset = 0; 00343 00344 // Set parameters on asii buffer 00345 // Set Session Id 00346 SetLong( Parameter, Session.Version, &offset ); 00347 SetLong( Parameter, Session.Index, &offset ); 00348 // Set Traffic description 00349 SetShort( Parameter, Traffic->Type, &offset ); 00350 SetShort( Parameter, Traffic->Direction, &offset ); 00351 SetULong( Parameter, Traffic->LogicalBlockSize, &offset ); 00352 SetLong( Parameter, Traffic->MaxRequests, &offset ); 00353 00354 if( Traffic->Type == RIO_TRAFFIC_CBR ) 00355 { 00356 SetDouble( Parameter, Traffic->TrafficCBR.Rate, &offset ); 00357 } 00358 else if( Traffic->Type == RIO_TRAFFIC_VBR ) 00359 { 00360 SetDouble( Parameter, Traffic->TrafficVBR.Rate, &offset ); 00361 } 00362 else 00363 { 00364 SetULong( Parameter, Traffic->TrafficNRT.Reserved, &offset ); 00365 } 00366 00367 // Update Parameter size to actual size ( previously was maximum 00368 // possible size ) 00369 ParameterSize = offset; 00370 00371 // Call remote method 00372 // calculating RTT 00373 #ifdef WINDOWS 00374 // Windows implementation 00375 GetSystemTime( &m_RTT_openStream ); 00376 #else 00377 // Linux implementation 00378 gettimeofday( &m_RTT_openStream, 0 ); 00379 #endif 00380 00381 status = m_TCPconnection->Call( RioClassSessionManager, 00382 RioMethodSessionManagerOpenStream, 00383 ParameterSize, 00384 Parameter, 00385 &ResultSize, 00386 &Result ); 00387 00388 #ifdef WINDOWS 00389 // Windows implementation 00390 GetSystemTime( &RTT_aux ); 00391 m_RTT_openStream.wSecond = RTT_aux.wSecond - m_RTT_openStream.wSecond; 00392 m_RTT_openStream.wMilliseconds = RTT_aux.wMilliseconds - 00393 m_RTT_openStream.wMilliseconds; 00394 if( m_RTT_openStream.wMilliseconds < 0 ) 00395 { 00396 m_RTT_openStream.wSecond -= 1; 00397 m_RTT_openStream.wMilliseconds = m_RTT_openConnection.wMilliseconds + 00398 1000000; 00399 } 00400 #else 00401 // Linux implementation 00402 gettimeofday( &RTT_aux, 0 ); 00403 m_RTT_openStream.tv_sec = RTT_aux.tv_sec - m_RTT_openStream.tv_sec; 00404 m_RTT_openStream.tv_usec = RTT_aux.tv_usec - m_RTT_openStream.tv_usec; 00405 if( m_RTT_openStream.tv_usec < 0 ) 00406 { 00407 m_RTT_openStream.tv_sec -= 1; 00408 m_RTT_openStream.tv_usec += 1000000; 00409 } 00410 #endif 00411 00412 // check if call failed 00413 if( FAILED( status ) ) 00414 { 00415 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00416 status = ERROR_RIOPROXY + ERROR_MEMORY; 00417 if( Result != NULL ) 00418 free( Result ); 00419 free( Parameter ); 00420 00421 return status; 00422 } 00423 00424 offset = 0; 00425 // Get results from result buffer 00426 // Get method return value 00427 if( !GetLong( Result, ResultSize, &status, &offset ) ) 00428 { 00429 free( Parameter ); 00430 free( Result ); 00431 00432 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00433 } 00434 // Get Stream id 00435 if( !GetLong( Result, ResultSize, &( Stream->Version ), &offset ) ) 00436 { 00437 free( Parameter ); 00438 free( Result ); 00439 00440 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00441 } 00442 if( !GetLong( Result, ResultSize, &( Stream->Index ), &offset ) ) 00443 { 00444 free( Parameter ); 00445 free( Result ); 00446 00447 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00448 } 00449 00450 if( FAILED( status ) ) 00451 { 00452 free( Parameter ); 00453 free( Result ); 00454 00455 return status; 00456 } 00457 else 00458 { 00459 if( !GetLong( Result, ResultSize, MaxRequests, &offset ) ) 00460 { 00461 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00462 } 00463 00464 free( Parameter ); 00465 free( Result ); 00466 00467 return S_OK; 00468 } 00469 }
void CSessionManager::PostITEvent | ( | MonitorEvent * | event | ) | [private] |
Definition at line 853 of file server/SessionManager.cpp.
00854 { 00855 m_SystemManager->PostITEvent( event ); 00856 }
HRESULT CSessionManager::RemoveResultFile | ( | int | ServerIP, | |
int | ServerPort, | |||
unsigned long long int | ResultFileId | |||
) |
Nova funcao para informar ao servidor que o arquivo com o resultado da busca pode ser removido.
ServerIp | endereco IP do servidor. | |
ServerPort | porta (a UDP) usada por este servidor. | |
ResultFileId | valor usado para identificar o arquivo com o resultado da busca no servidor, retornado quando recebemos a informacao de que a busca foi feita com sucesso. |
Definition at line 2781 of file interface/SessionManager.cpp.
02783 { 02784 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02785 char *Result; 02786 unsigned int ParameterSize; 02787 unsigned int ResultSize; 02788 HRESULT status; 02789 int offset; 02790 02791 if( Parameter == NULL ) 02792 { 02793 #ifdef RIO_DEBUG1 02794 RioErr << "malloc error ResultFileBlockRequest:" << strerror(errno) 02795 << endl; 02796 #endif 02797 free( Parameter ); 02798 02799 return ERROR_RIOPROXY + ERROR_MEMORY; 02800 } 02801 02802 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02803 02804 ParameterSize = 2 * MAX_ULONG_STRING_SIZE + MAX_LONG_STRING_SIZE + 02805 MAX_SHORT_STRING_SIZE; 02806 // Check if Parameter buffer is large enough 02807 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02808 { 02809 free( Parameter ); 02810 02811 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02812 } 02813 02814 offset = 0; 02815 02816 // Armazena o IP do servidor. 02817 SetLong( Parameter, ServerIP, &offset ); 02818 // Armazena a porta do servidor. 02819 SetShort( Parameter, ServerPort, &offset ); 02820 // Armazena a parte inferior do identificador do arquivo. 02821 SetULong( Parameter, ( unsigned int ) ( ResultFileId & 0xFFFFFFFF ), 02822 &offset ); 02823 // Armazena a parte superior do identificador do arquivo. 02824 SetULong( Parameter, ( unsigned int ) ( ResultFileId >> 32 ), &offset ); 02825 02826 // Update Parameter size to actual size 02827 // ( previously was maximum possible size ) 02828 ParameterSize = offset; 02829 02830 // Faz a chamada remota a uma funcao do Servidor RIO para inicializar a 02831 // solicitacao de busca. 02832 status = m_TCPconnection->Call( RioClassRouter, 02833 RioMethodRouterRemoveSearchResultFile, 02834 ParameterSize, 02835 Parameter, 02836 &ResultSize, 02837 &Result ); 02838 02839 // check if call failed 02840 if( FAILED( status ) ) 02841 { 02842 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02843 status = ERROR_RIOPROXY + ERROR_MEMORY; 02844 } 02845 else 02846 { 02847 offset = 0; 02848 // Get results from result buffer 02849 // Get method return value 02850 if( Result == NULL ) 02851 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02852 02853 02854 if( !GetLong( Result,ResultSize,&status,&offset ) ) 02855 { 02856 free( Parameter ); 02857 free( Result ); 02858 02859 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02860 } 02861 } 02862 02863 free( Result ); 02864 02865 return status; 02866 }
HRESULT CSessionManager::RemoveUser | ( | char * | UserName | ) |
Nova funcao para remover a senha do usuario.
Obs: devido ao servidor nao fazrer uma remocao do diretorio se ele nao estiver vazio, o diretorio do usuario nao sera removido.
UserName | ponteiro para a string com o nome do usuario. |
Definition at line 2945 of file interface/SessionManager.cpp.
02946 { 02947 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02948 char *Result; 02949 unsigned int ParameterSize; 02950 unsigned int ResultSize; 02951 HRESULT status; 02952 02953 if( Parameter == NULL ) 02954 { 02955 RioErr << "malloc error RemoveUser:" << strerror(errno) << endl; 02956 free( Parameter ); 02957 02958 return ERROR_RIOPROXY + ERROR_MEMORY; 02959 } 02960 02961 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02962 02963 ParameterSize = strlen( UserName ) + 1; 02964 // Check if Parameter buffer is large enough 02965 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02966 { 02967 free( Parameter ); 02968 02969 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02970 } 02971 02972 int offset = 0; 02973 02974 // Set UserName 02975 SetString( Parameter, UserName, &offset ); 02976 02977 // Update Parameter size to actual size 02978 // ( previously was maximum possible size ) 02979 ParameterSize = offset; 02980 02981 // Call remote method 02982 status = m_TCPconnection->Call( RioClassUserManager, 02983 RioMethodUserManagerRemoveUser, 02984 ParameterSize, 02985 Parameter, 02986 &ResultSize, 02987 &Result ); 02988 02989 // check if call failed 02990 if( FAILED( status ) ) 02991 { 02992 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02993 status = ERROR_RIOPROXY + ERROR_MEMORY; 02994 if( Result != NULL ) 02995 free( Result ); 02996 free( Parameter ); 02997 02998 return status; 02999 } 03000 03001 offset = 0; 03002 // Get results from result buffer 03003 // Get method return value 03004 if( !GetLong( Result, ResultSize, &status, &offset ) ) 03005 { 03006 free( Parameter ); 03007 free( Result ); 03008 03009 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 03010 } 03011 03012 free( Parameter ); 03013 free( Result ); 03014 03015 return status; 03016 }
HRESULT CSessionManager::RenameObject | ( | const RioSessionId | Session, | |
const char * | CurrentName, | |||
const char * | NewName | |||
) |
Definition at line 639 of file interface/SessionManager.cpp.
00642 { 00643 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 00644 char *Result; 00645 unsigned int ParameterSize; 00646 unsigned int ResultSize; 00647 HRESULT status; 00648 00649 if( Parameter == NULL ) 00650 { 00651 RioErr << "malloc error RenameObject:" << strerror(errno) << endl; 00652 free( Parameter ); 00653 00654 return ERROR_RIOPROXY + ERROR_MEMORY; 00655 } 00656 00657 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 00658 00659 ParameterSize = 2 * MAX_LONG_STRING_SIZE + 00660 strlen( CurrentName )+1 + 00661 strlen( NewName )+1; 00662 // Check if Parameter buffer is large enough 00663 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 00664 { 00665 free( Parameter ); 00666 00667 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 00668 } 00669 00670 int offset = 0; 00671 00672 // Set parameters on asii buffer 00673 // Set Session Id 00674 SetLong( Parameter,Session.Version,&offset ); 00675 SetLong( Parameter,Session.Index,&offset ); 00676 00677 // Set Object Current Name 00678 SetString( Parameter,CurrentName,&offset ); 00679 00680 // Set Object New Name 00681 SetString( Parameter,NewName,&offset ); 00682 00683 // Update Parameter size to actual size 00684 // ( previously was maximum possible size ) 00685 ParameterSize = offset; 00686 00687 // Call remote method 00688 status = m_TCPconnection->Call( RioClassSessionManager, 00689 RioMethodSessionManagerRenameObject, 00690 ParameterSize, 00691 Parameter, 00692 &ResultSize, 00693 &Result ); 00694 00695 // check if call failed 00696 if( FAILED( status ) ) 00697 { 00698 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 00699 status = ERROR_RIOPROXY + ERROR_MEMORY; 00700 if( Result != NULL ) 00701 free( Result ); 00702 free( Parameter ); 00703 00704 return status; 00705 } 00706 00707 offset = 0; 00708 // Get results from result buffer 00709 // Get method return value 00710 if( !GetLong( Result,ResultSize,&status,&offset ) ) 00711 { 00712 free( Parameter ); 00713 free( Result ); 00714 00715 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 00716 } 00717 00718 free( Parameter ); 00719 free( Result ); 00720 00721 return status; 00722 }
HRESULT CSessionManager::ResultFileBlockRequest | ( | int | ServerIP, | |
int | ServerPort, | |||
int | ClientIP, | |||
int | ClientPort, | |||
unsigned long long int | ResultFileId, | |||
unsigned int | Block, | |||
int | ReqId | |||
) |
Nova funcao para ler um bloco do arquivo com os resultados da busca.
ServerIp | endereco IP do servidor. | |
ServerPort | porta (a UDP) usada por este servidor. | |
ClientIp | endereco IP do cliente. | |
ClientPort | porta (a UDP) usada por este cliente. | |
ResultFileId | valor usado para identificar o arquivo com o resultado da busca no servidor, retornado quando recebemos a informacao de que a busca foi feita com sucesso. | |
Block | numero do bloco que desejamos obter. | |
ReqId | identificador que deve ser usado pelo servidor ao enviar o bloco do arquivo ao cliente. |
Definition at line 2679 of file interface/SessionManager.cpp.
02683 { 02684 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02685 char *Result; 02686 unsigned int ParameterSize; 02687 unsigned int ResultSize; 02688 HRESULT status; 02689 int offset; 02690 02691 if( Parameter == NULL ) 02692 { 02693 #ifdef RIO_DEBUG1 02694 RioErr << "malloc error ResultFileBlockRequest:" << strerror(errno) 02695 << endl; 02696 #endif 02697 free( Parameter ); 02698 02699 return ERROR_RIOPROXY + ERROR_MEMORY; 02700 } 02701 02702 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02703 02704 ParameterSize = 3 * MAX_ULONG_STRING_SIZE + 3 * MAX_LONG_STRING_SIZE + 02705 2 * MAX_SHORT_STRING_SIZE; 02706 // Check if Parameter buffer is large enough 02707 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02708 { 02709 free( Parameter ); 02710 02711 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02712 } 02713 02714 offset = 0; 02715 02716 // Armazena o IP do servidor. 02717 SetLong( Parameter, ServerIP, &offset ); 02718 // Armazena a porta do servidor. 02719 SetShort( Parameter, ServerPort, &offset ); 02720 // Armazena o IP do cliente. 02721 SetLong( Parameter, ClientIP, &offset ); 02722 // Armazena a porta do cliente. 02723 SetShort( Parameter, ClientPort, &offset ); 02724 // Armazena a parte inferior do identificador do arquivo. 02725 SetULong( Parameter, ( unsigned int ) ( ResultFileId & 0xFFFFFFFF ), 02726 &offset ); 02727 // Armazena a parte superior do identificador do arquivo. 02728 SetULong( Parameter, ( unsigned int ) ( ResultFileId >> 32 ), &offset ); 02729 // Armazena o numero do bloco a ser requisitado. 02730 SetLong( Parameter, Block, &offset ); 02731 // Armazena o identificador para a resposta da solicitacao de busca. 02732 SetLong( Parameter, ReqId, &offset ); 02733 02734 // Update Parameter size to actual size 02735 // ( previously was maximum possible size ) 02736 ParameterSize = offset; 02737 02738 // Faz a chamada remota a uma funcao do Servidor RIO para inicializar a 02739 // solicitacao de busca. 02740 status = m_TCPconnection->Call( RioClassRouter, 02741 RioMethodRouterSearchResultDataRequest, 02742 ParameterSize, 02743 Parameter, 02744 &ResultSize, 02745 &Result ); 02746 02747 02748 free( Parameter ); 02749 02750 // check if call failed 02751 if( FAILED( status ) ) 02752 { 02753 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02754 status = ERROR_RIOPROXY + ERROR_MEMORY; 02755 } 02756 else 02757 { 02758 offset = 0; 02759 // Get results from result buffer 02760 // Get method return value 02761 if( Result == NULL ) 02762 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02763 02764 02765 if( !GetLong( Result,ResultSize,&status,&offset ) ) 02766 { 02767 free( Parameter ); 02768 free( Result ); 02769 02770 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02771 } 02772 } 02773 02774 free( Result ); 02775 02776 return status; 02777 }
int CSessionManager::SaveMeasures | ( | ) |
Definition at line 836 of file server/SessionManager.cpp.
00837 { 00838 int result1; 00839 00840 result1 = m_StreamManager->SaveMeasures(); 00841 00842 return result1; 00843 }
HRESULT CSessionManager::SaveMeasures | ( | const RioSessionId | Session | ) |
Definition at line 1747 of file interface/SessionManager.cpp.
01748 { 01749 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01750 char *Result; 01751 unsigned int ParameterSize; 01752 unsigned int ResultSize; 01753 HRESULT status; 01754 01755 if( Parameter == NULL ) 01756 { 01757 RioErr << "malloc error SaveMeasures:" << strerror(errno) << endl; 01758 free( Parameter ); 01759 01760 return ERROR_RIOPROXY + ERROR_MEMORY; 01761 } 01762 01763 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 01764 01765 ParameterSize = 2 * MAX_LONG_STRING_SIZE; 01766 // Check if Parameter buffer is large enough 01767 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 01768 { 01769 free( Parameter ); 01770 01771 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 01772 } 01773 01774 int offset = 0; 01775 01776 // Set parameters on asii buffer 01777 // Set Session Id 01778 SetLong( Parameter,Session.Version,&offset ); 01779 SetLong( Parameter,Session.Index,&offset ); 01780 01781 // Update Parameter size to actual size 01782 // ( previously was maximum possible size ) 01783 ParameterSize = offset; 01784 01785 // Call remote method 01786 status = m_TCPconnection->Call( RioClassSessionManager, 01787 RioMethodSessionManagerSaveMeasures, 01788 ParameterSize, 01789 Parameter, 01790 &ResultSize, 01791 &Result ); 01792 01793 // check if call failed 01794 if( FAILED( status ) ) 01795 { 01796 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 01797 status = ERROR_RIOPROXY + ERROR_MEMORY; 01798 if( Result != NULL ) 01799 free( Result ); 01800 free( Parameter ); 01801 01802 return status; 01803 } 01804 01805 offset = 0; 01806 // Get results from result buffer 01807 // Get method return value 01808 if( !GetLong( Result,ResultSize,&status,&offset ) ) 01809 { 01810 free( Parameter ); 01811 free( Result ); 01812 01813 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 01814 } 01815 01816 free( Parameter ); 01817 free( Result ); 01818 01819 return status; 01820 }
HRESULT CSessionManager::SearchLogsRequest | ( | unsigned int | SearchType, | |
time_t | StartTime, | |||
time_t | EndTime, | |||
int | ServerIP, | |||
int | ServerPort, | |||
int | ClientIP, | |||
int | ClientPort, | |||
int | ReqId | |||
) |
Nova funcao para solicitar uma busca em um conjunto de logs de um dos servidores.
SearchType | tipo da busca, que por enquanto, pode ser SEARCHINTRAFFICLOGS para fazer busca nos logs com os trafegos de um dos servidores de armazenamento, ou SEARCHINCLIENTSLOGS para fazer uma busca nos logs com os comportamentos dos clientes do servidor de despacho. | |
StartTime | Tempo inicial da busca (baseado no mesmo principio da funcao time da biblioteca do C, isto e, o tempo em segundos desde a Epoch (00:00:00 UTC, Janeiro 1 de 1970). | |
EndTime | Tempo Final da busca (o mesmo princio do tempo inicial dado acima). | |
ServerIp | endereco IP do servidor. | |
ServerPort | porta (a UDP) usada por este servidor. | |
ClientIp | endereco IP do cliente. | |
ClientPort | porta (a UDP) usada por este cliente. | |
ReqId | identificador que deve ser usado pelo servidor ao enviar o resultado da busca. |
Definition at line 2578 of file interface/SessionManager.cpp.
02583 { 02584 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 02585 char *Result; 02586 unsigned int ParameterSize; 02587 unsigned int ResultSize; 02588 HRESULT status; 02589 int offset; 02590 02591 if( Parameter == NULL ) 02592 { 02593 #ifdef RIO_DEBUG1 02594 RioErr << "malloc error SearchLogsRequest:" << strerror(errno) 02595 << endl; 02596 #endif 02597 free( Parameter ); 02598 02599 return ERROR_RIOPROXY + ERROR_MEMORY; 02600 } 02601 02602 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02603 02604 ParameterSize = 3 * MAX_LONG_STRING_SIZE + 3 * MAX_ULONG_STRING_SIZE + 02605 2 * MAX_SHORT_STRING_SIZE; 02606 // Check if Parameter buffer is large enough 02607 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02608 { 02609 free( Parameter ); 02610 02611 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02612 } 02613 02614 offset = 0; 02615 02616 // Armazena o tipo da busca na mensagem. 02617 SetULong( Parameter, SearchType, &offset ); 02618 // Armazena o tempo inicial da busca na mensagem. 02619 SetULong( Parameter, ( unsigned int ) StartTime, &offset ); 02620 // Armazena o tempo Final na mensagem. 02621 SetULong( Parameter, ( unsigned int ) EndTime, &offset ); 02622 // Armazena o IP do servidor. 02623 SetLong( Parameter, ServerIP, &offset ); 02624 // Armazena a porta do servidor. 02625 SetShort( Parameter, ServerPort, &offset ); 02626 // Armazena o IP do cliente. 02627 SetLong( Parameter, ClientIP, &offset ); 02628 // Armazena a porta do cliente. 02629 SetShort( Parameter, ClientPort, &offset ); 02630 // Armazena o identificador para a resposta da solicitacao de busca. 02631 SetLong( Parameter, ReqId, &offset ); 02632 02633 // Update Parameter size to actual size 02634 // ( previously was maximum possible size ) 02635 ParameterSize = offset; 02636 02637 // Faz a chamada remota a uma funcao do Servidor RIO para inicializar a 02638 // solicitacao de busca. 02639 status = m_TCPconnection->Call( RioClassRouter, 02640 RioMethodRouterSearchLogsRequest, 02641 ParameterSize, 02642 Parameter, 02643 &ResultSize, 02644 &Result ); 02645 02646 02647 free( Parameter ); 02648 02649 // check if call failed 02650 if( FAILED( status ) ) 02651 { 02652 if( ( unsigned int ) status == ( ERROR_RIOTCP + ERROR_MEMORY ) ) 02653 status = ERROR_RIOPROXY + ERROR_MEMORY; 02654 } 02655 else 02656 { 02657 offset = 0; 02658 // Get results from result buffer 02659 // Get method return value 02660 if( Result == NULL ) 02661 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02662 02663 02664 if( !GetLong( Result,ResultSize,&status,&offset ) ) 02665 { 02666 free( Parameter ); 02667 free( Result ); 02668 02669 return ERROR_RIOPROXY + ERROR_MESSAGE_DATA_FORMAT; 02670 } 02671 } 02672 02673 free( Result ); 02674 02675 return status; 02676 }
HRESULT CSessionManager::SendNATMappings | ( | int * | addrs, | |
int * | ports, | |||
unsigned int | size | |||
) |
Definition at line 1989 of file interface/SessionManager.cpp.
01992 { 01993 char *Parameter = (char*) malloc( MaxTCPDataSize*sizeof(char) ); 01994 char *Result; 01995 unsigned int ParameterSize; 01996 unsigned int ResultSize; 01997 HRESULT status; 01998 01999 if( Parameter == NULL ) 02000 { 02001 RioErr << "malloc error GetStorageNodeInfo:" << strerror(errno) << endl; 02002 free( Parameter ); 02003 02004 return ERROR_RIOPROXY + ERROR_MEMORY; 02005 } 02006 02007 memset( Parameter, 0, MaxTCPDataSize*sizeof( char ) ); 02008 02009 ParameterSize = 2 * size * MAX_LONG_STRING_SIZE; 02010 // Check if Parameter buffer is large enough 02011 if( ParameterSize > ( unsigned int ) MaxTCPDataSize ) 02012 { 02013 free( Parameter ); 02014 02015 return ERROR_RIOPROXY + ERROR_CALL_MESSAGE_OVERFLOW; 02016 } 02017 02018 int offset = 0; 02019 02020 #ifdef RIO_DEBUG2 02021 RioErr << "[CSessionManager] Sending mappings to server" << endl; 02022 #endif 02023 // Set parameters on asii buffer 02024 for( unsigned int i = 0; i < size; i++ ) 02025 { 02026 #ifdef RIO_DEBUG2 02027 struct in_addr ip; 02028 ip.s_addr = addrs[i]; 02029 RioErr << "[CSessionManager] Mapping #" << i << ": " 02030 << inet_ntoa(ip) << ", " << htons(ports[i]) << endl; 02031 #endif 02032 // Set IP 02033 SetLong( Parameter, addrs[i], &offset ); 02034 // Set Port 02035 SetLong( Parameter, ports[i], &offset ); 02036 } 02037 02038 // Update Parameter size to actual size 02039 // ( previously was maximum possible size ) 02040 ParameterSize = offset; 02041 02042 // Call remote method 02043 status = m_TCPconnection->Call( RioClassRouter, 02044 RioMethodRouterSetNATMappings, 02045 ParameterSize, 02046 Parameter, 02047 &ResultSize, 02048 &Result ); 02049 02050 // check if call failed 02051 if( FAILED( status ) ) 02052 { 02053 // Se ocorreu algum erro, ou o metodo nao existe, ou ocorreu algum 02054 // erro ao executar o metodo. 02055 return status; 02056 } 02057 02058 free( Parameter ); 02059 free( Result ); 02060 02061 return status; 02062 }
SetNATMapping informa ao Router o mapeamento NAT de um cliente com um storage.
Sao enviados o mapeamento NAT do cliente com o servidor, o id do storage e o mapeamento NAT do cliente com o storage considerado.
server_map | estrutura identificando o mapeamento do servidor de gerenciamento. | |
stor_id | identificador do servidor de armazenamento. | |
stor_map | estrutura identificando o mapeamento do servidor de armazenamento com o identificador stor_id. |
Definition at line 903 of file server/SessionManager.cpp.
00905 { 00906 m_Router->SetNATMapping( server_map, stor_id, stor_map ); 00907 }
void CSessionManager::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 1012 of file server/SessionManager.cpp.
01013 { 01014 m_NumberOfDisks = NumberOfDisks; 01015 }
friend class RioSession [friend] |
Definition at line 478 of file server/SessionManager.h.
unsigned int CSessionManager::m_BlockSize [private] |
Definition at line 396 of file server/SessionManager.h.
int CSessionManager::m_ClientsTimeOut [private] |
Definition at line 436 of file server/SessionManager.h.
pthread_t CSessionManager::m_ConnectionThreadId [private] |
Definition at line 424 of file server/SessionManager.h.
DiskMgr* CSessionManager::m_DiskMgr [private] |
Definition at line 401 of file server/SessionManager.h.
char* CSessionManager::m_FileRoot [private] |
Definition at line 404 of file server/SessionManager.h.
bool CSessionManager::m_initialized [private] |
Definition at line 421 of file server/SessionManager.h.
ofstream CSessionManager::m_log [private] |
Definition at line 422 of file server/SessionManager.h.
CLogRotation* CSessionManager::m_LogRotation [private] |
Definition at line 440 of file server/SessionManager.h.
char* CSessionManager::m_LogsDirectory [private] |
Definition at line 444 of file server/SessionManager.h.
int CSessionManager::m_MaxSessions [private] |
Definition at line 407 of file server/SessionManager.h.
pthread_mutex_t CSessionManager::m_mutex [private] |
Definition at line 420 of file server/SessionManager.h.
CNetInterface* CSessionManager::m_NetInterface [private] |
Definition at line 416 of file server/SessionManager.h.
NetMgr* CSessionManager::m_NetMgr [private] |
Definition at line 415 of file server/SessionManager.h.
unsigned int CSessionManager::m_NumberOfDisks [private] |
Definition at line 399 of file server/SessionManager.h.
unsigned int CSessionManager::m_NumberOfStorageNodes [private] |
Definition at line 400 of file server/SessionManager.h.
CObjectManager* CSessionManager::m_ObjectManager [private] |
Definition at line 411 of file server/SessionManager.h.
CRouter* CSessionManager::m_Router [private] |
Definition at line 413 of file server/SessionManager.h.
struct timeval m_RTT_openConnection CSessionManager::m_RTT_openStream [private] |
Definition at line 239 of file interface/SessionManager.h.
CSearchLogs* CSessionManager::m_SearchLogs [private] |
Definition at line 448 of file server/SessionManager.h.
SOCKADDR_IN* CSessionManager::m_ServerAddress [private] |
Definition at line 426 of file server/SessionManager.h.
unsigned int CSessionManager::m_ServerAddressSize [private] |
Definition at line 431 of file server/SessionManager.h.
SessionEntry* CSessionManager::m_SessionTable [private] |
Definition at line 419 of file server/SessionManager.h.
CStreamManager* CSessionManager::m_StreamManager [private] |
Definition at line 410 of file server/SessionManager.h.
CSystemManager* CSessionManager::m_SystemManager [private] |
Definition at line 409 of file server/SessionManager.h.
CRioTCP * CSessionManager::m_TCPconnection [private] |
Definition at line 235 of file interface/SessionManager.h.
bool CSessionManager::m_threadStopEvent [private] |
Definition at line 425 of file server/SessionManager.h.
int CSessionManager::m_used [private] |
Definition at line 418 of file server/SessionManager.h.
CUserManager* CSessionManager::m_UserManager [private] |
Definition at line 412 of file server/SessionManager.h.