version 1.11, 2002/06/01 00:57:36
|
version 1.12, 2002/06/04 01:42:40
|
|
|
#include <Pegasus/Common/CIMMessage.h> | #include <Pegasus/Common/CIMMessage.h> |
#include <Pegasus/Common/MessageQueueService.h> | #include <Pegasus/Common/MessageQueueService.h> |
#include <Pegasus/Common/IPC.h> | #include <Pegasus/Common/IPC.h> |
#include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/Tracer.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
|
|
*/ | */ |
void ShutdownService::shutdown(Boolean force, Uint32 timeout) | void ShutdownService::shutdown(Boolean force, Uint32 timeout) |
{ | { |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "ShutdownService::shutdown"); |
|
|
// | // |
// Initialize variables | // Initialize variables |
// | // |
Boolean timeoutExpired = false; | Boolean timeoutExpired = false; |
Boolean noMoreRequests = false; | Boolean noMoreRequests = false; |
| |
|
_shutdownTimeout = timeout; |
|
|
try | try |
{ | { |
// | // |
|
|
_cimserver->stopClientConnection(); | _cimserver->stopClientConnection(); |
| |
// | // |
// get shutdown timeout values |
|
// |
|
_initTimeoutValues(timeout); |
|
|
|
// |
|
// Determine if there are any outstanding CIM operation requests | // Determine if there are any outstanding CIM operation requests |
// (take into account that one of the request is the shutdown request). | // (take into account that one of the request is the shutdown request). |
// | // |
|
|
} | } |
catch(CIMException & e) | catch(CIMException & e) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"Error occured during CIMServer shutdown: $0.", |
"Error occurred during CIMServer shutdown: " + e.getMessage()); |
e.getMessage()); |
|
} | } |
catch(Exception & e) | catch(Exception & e) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"Error occured during CIMServer shutdown: $0.", |
"Error occurred during CIMServer shutdown: " + e.getMessage()); |
e.getMessage()); |
|
} | } |
| |
catch(...) | catch(...) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"Unexpected error occured during CIMServer shutdown. "); | "Unexpected error occured during CIMServer shutdown. "); |
} | } |
| |
|
|
// | // |
// All done | // All done |
// | // |
|
PEG_METHOD_EXIT(); |
return; | return; |
} | } |
| |
|
|
/* private methods */ | /* private methods */ |
/**********************************************************/ | /**********************************************************/ |
| |
void ShutdownService::_initTimeoutValues(Uint32 timeout) |
|
{ |
|
// |
|
// get an instance of the ConfigManager |
|
// |
|
ConfigManager* configManager; |
|
configManager = ConfigManager::getInstance(); |
|
|
|
// |
|
// if timeout was not specified, get timeout value from ConfigManager |
|
// |
|
if (timeout > 0) |
|
{ |
|
_shutdownTimeout = timeout; |
|
} |
|
else |
|
{ |
|
String configTimeout = |
|
configManager->getCurrentValue(SHUTDOWN_TIMEOUT_PROPERTY); |
|
ArrayDestroyer<char> timeoutCString(configTimeout.allocateCString()); |
|
_shutdownTimeout = strtol(timeoutCString.getPointer(), (char **)0,10); |
|
} |
|
|
|
return; |
|
} |
|
|
|
void ShutdownService::_shutdownCIMServer() | void ShutdownService::_shutdownCIMServer() |
{ | { |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "ShutdownService::_shutdownCIMServer"); |
|
|
// | // |
// Shutdown the providers | // Shutdown the providers |
// | // |
|
|
// | // |
_cimserver->shutdown(); | _cimserver->shutdown(); |
| |
|
PEG_METHOD_EXIT(); |
return; | return; |
} | } |
| |
void ShutdownService::_shutdownCimomServices() | void ShutdownService::_shutdownCimomServices() |
{ | { |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "ShutdownService::_shutdownCimomServices"); |
|
|
// | // |
// Shutdown the Indication Service | // Shutdown the Indication Service |
// | // |
|
|
// | // |
_sendShutdownRequestToService(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER); | _sendShutdownRequestToService(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER); |
| |
|
PEG_METHOD_EXIT(); |
return; | return; |
} | } |
| |
|
|
_queueId, | _queueId, |
stopRequest); | stopRequest); |
| |
// JYU |
|
//delete stopRequest; | //delete stopRequest; |
| |
// ATTN-YZ-P2-05032002: Temporarily removed, until asyn_callback fixed |
|
/* |
|
// |
|
// create callback data structure |
|
// |
|
callback_data *cb_data = new callback_data(this); |
|
|
|
// |
|
// Now send Stop request to service |
|
// |
|
if (false == _controller->ClientSendAsync(*_client_handle, |
|
0, |
|
_queueId, |
|
stopRequest, |
|
ShutdownService::async_callback, |
|
(void *)cb_data) ) |
|
{ |
|
delete cb_data; |
|
throw CIMException(CIM_ERR_NOT_FOUND); |
|
} |
|
|
|
cb_data->client_sem.wait(); |
|
AsyncReply * asyncReply = static_cast<AsyncReply *>(cb_data->get_reply()) ; |
|
|
|
// |
|
// check result |
|
// |
|
if (asyncReply != NULL) |
|
{ |
|
if (asyncReply->result == async_results::CIM_STOPPED) |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
|
"Service $0 $1", serviceName, "stopped."); |
|
} |
|
else |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
|
"Failed to stop service $0.", serviceName); |
|
} |
|
} |
|
|
|
delete stopRequest; |
|
delete asyncReply; |
|
delete cb_data; |
|
*/ |
|
|
|
return; | return; |
} | } |
| |
void ShutdownService::_shutdownProviders() | void ShutdownService::_shutdownProviders() |
{ | { |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "ShutdownService::_shutdownProviders"); |
|
|
// | // |
// get provider manager service | // get provider manager service |
// | // |
|
|
MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); | MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); |
| |
if (queue == 0) | if (queue == 0) |
|
{ |
|
PEG_METHOD_EXIT(); |
return; | return; |
|
} |
| |
MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue); | MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue); |
Uint32 _queueId = _service->getQueueId(); | Uint32 _queueId = _service->getQueueId(); |
|
|
delete asyncRequest; | delete asyncRequest; |
delete asyncReply; | delete asyncReply; |
delete response; | delete response; |
|
PEG_METHOD_EXIT(); |
throw (e); | throw (e); |
} | } |
| |
|
|
delete asyncReply; | delete asyncReply; |
delete response; | delete response; |
| |
// ATTN-JY-P2-05162002: Comment out, until asyn_callback is fixed |
PEG_METHOD_EXIT(); |
/* |
|
// |
|
// create callback data structure |
|
// |
|
callback_data *cb_data = new callback_data(this); |
|
|
|
if (false == _controller->ClientSendAsync(*_client_handle, |
|
0, |
|
_queueId, |
|
asyncRequest, |
|
ShutdownService::async_callback, |
|
(void *)cb_data) ) |
|
{ |
|
delete stopRequest; |
|
delete asyncRequest; |
|
delete cb_data; |
|
throw CIMException(CIM_ERR_NOT_FOUND); |
|
} |
|
|
|
cb_data->client_sem.wait(); |
|
AsyncReply * asyncReply = static_cast<AsyncReply *>(cb_data->get_reply()) ; |
|
|
|
// |
|
// check result |
|
// |
|
if (asyncReply != NULL) |
|
{ |
|
if (asyncReply->result == async_results::OK) |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
|
"Providers terminated successfully."); |
|
} |
|
else |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
|
"Error occured while terminating providers."); |
|
} |
|
|
|
} |
|
|
|
//delete stopRequest; |
|
delete asyncRequest; |
|
delete asyncReply; |
|
delete cb_data; |
|
*/ |
|
|
|
return; | return; |
} | } |
| |