version 1.75.2.1, 2006/06/29 17:33:12
|
version 1.89, 2007/06/06 05:24:49
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Mike Day (mdday@us.ibm.com) |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Arthur Pichlkostner (via Markus: sedgewick_de@yahoo.de) |
|
// Willis White (whiwill@us.ibm.com) PEP 127 and 128 |
|
// Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1 |
|
// Amit K Arora, IBM (amita@in.ibm.com) for Bug#1090 |
|
// John Alex, IBM (johnalex@us.ibm.com) - Bug#2290 |
|
// |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#ifndef Pegasus_Message_h | #ifndef Pegasus_Message_h |
|
|
#include <iostream> | #include <iostream> |
#include <cstring> | #include <cstring> |
#include <Pegasus/Common/InternalException.h> | #include <Pegasus/Common/InternalException.h> |
#include <Pegasus/Common/IPC.h> |
|
#include <Pegasus/Common/StatisticalData.h> |
|
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
#include <Pegasus/Common/TimeValue.h> | #include <Pegasus/Common/TimeValue.h> |
#include <Pegasus/Common/CIMOperationType.h> | #include <Pegasus/Common/CIMOperationType.h> |
|
#include <Pegasus/Common/Threads.h> |
#include <Pegasus/Common/Linkable.h> | #include <Pegasus/Common/Linkable.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
// REVIEW: could class be renamed to MessageMask (coding standard) |
class PEGASUS_COMMON_LINKAGE MessageMask |
|
|
class PEGASUS_COMMON_LINKAGE message_mask |
|
{ | { |
public: | public: |
|
// Message handling is indicated by the high order 12 bits. For example: |
static Uint32 type_legacy; |
// Uint32 messageHandling = flags & 0xfff00000; |
static Uint32 type_CIMOperation; |
|
static Uint32 type_CIMAsyncOperation; |
|
static Uint32 type_export; |
|
static Uint32 type_lifetime; |
|
static Uint32 type_socket; |
|
static Uint32 type_connection; |
|
static Uint32 type_http; |
|
static Uint32 type_http_error; |
|
static Uint32 type_cimom; |
|
static Uint32 type_control; |
|
static Uint32 type_service; |
|
static Uint32 type_broadcast; |
|
static Uint32 type_client_exception; |
|
|
|
static Uint32 ha_no_delete; |
|
static Uint32 ha_request; | static Uint32 ha_request; |
static Uint32 ha_reply; | static Uint32 ha_reply; |
static Uint32 ha_synchronous; |
|
static Uint32 ha_async; | static Uint32 ha_async; |
static Uint32 ha_wait; |
|
|
|
|
|
// more for documentation than for use |
|
|
|
inline Uint32 get_type(Uint32 flags) |
|
{ |
|
return (flags & 0x000fffff); |
|
} |
|
|
|
inline Uint32 get_handling(Uint32 flags) |
|
{ |
|
return( flags & 0xfff00000); |
|
} |
|
}; | }; |
| |
class cimom; |
|
class MessageQueue; |
|
class MessageQueueService; |
|
class AsyncLegacyOperationStart; |
|
class AsyncLegacyOperationResult; |
|
|
|
enum HttpMethod | enum HttpMethod |
{ | { |
HTTP_METHOD__POST, | HTTP_METHOD__POST, |
|
|
/** The Message class and derived classes are used to pass messages between | /** The Message class and derived classes are used to pass messages between |
modules. Messages are passed between modules using the message queues | modules. Messages are passed between modules using the message queues |
(see MessageQueue class). Derived classes may add their own fields. | (see MessageQueue class). Derived classes may add their own fields. |
This base class defines two common fields: type, which is the type of |
This base class defines a common type field, which is the type of |
the message, and key which is a key value whose meaning is defined by |
the message. |
the derived class. The MessageQueue class provides methods for finding |
|
messages by both type and key. |
|
|
|
The Message class also provides previous and next pointers which are |
|
used to place the messages on a queue by the MessageQueue class. |
|
*/ | */ |
class PEGASUS_COMMON_LINKAGE Message : public Linkable | class PEGASUS_COMMON_LINKAGE Message : public Linkable |
{ | { |
|
|
Message( | Message( |
Uint32 type, | Uint32 type, |
Uint32 destination = 0, | Uint32 destination = 0, |
Uint32 key = getNextKey(), |
Uint32 mask = 0) |
Uint32 routing_code = 0, |
|
Uint32 mask = message_mask::type_legacy) |
|
: | : |
_type(type), | _type(type), |
_key(key), |
|
_routing_code(routing_code), |
|
_mask(mask), | _mask(mask), |
_httpMethod (HTTP_METHOD__POST), | _httpMethod (HTTP_METHOD__POST), |
|
#ifndef PEGASUS_DISABLE_PERFINST |
|
_serverStartTimeMicroseconds(0), |
|
_providerTimeMicroseconds(0), |
|
_totalServerTimeMicroseconds(0), |
|
#endif |
_close_connect(false), | _close_connect(false), |
_last_thread_id(pegasus_thread_self()), |
_last_thread_id(Threads::self()), |
_next(0), |
|
_prev(0), |
|
_async(0), | _async(0), |
dest(destination), | dest(destination), |
_isComplete(true), | _isComplete(true), |
_index(0) | _index(0) |
{ | { |
|
|
} | } |
| |
Message & operator = ( const Message & msg) |
virtual ~Message(); |
{ |
|
if (this != &msg) |
|
{ |
|
_type = msg._type; |
|
_key = msg._key; |
|
_routing_code = msg._routing_code; |
|
_mask = msg._mask; |
|
_last_thread_id = msg._last_thread_id; |
|
_next = _prev = _async = 0; |
|
dest = msg.dest; |
|
_httpMethod = msg._httpMethod; |
|
_index = msg._index; |
|
_isComplete = msg._isComplete; |
|
|
|
} |
|
return *this; |
|
} |
|
| |
|
// NOTE: The compiler default implementation of the copy constructor |
|
// is used for this class. |
| |
virtual ~Message(); |
|
Boolean getCloseConnect() const { return _close_connect; } | Boolean getCloseConnect() const { return _close_connect; } |
void setCloseConnect(Boolean close_connect) | void setCloseConnect(Boolean close_connect) |
{ | { |
|
|
| |
void setType(Uint32 type) { _type = type; } | void setType(Uint32 type) { _type = type; } |
| |
Uint32 getKey() const { return _key; } |
|
|
|
void setKey(Uint32 key) { _key = key; } |
|
|
|
Uint32 getRouting() const { return _routing_code; } |
|
void setRouting(Uint32 routing) { _routing_code = routing; } |
|
|
|
Uint32 getMask() const { return _mask; } | Uint32 getMask() const { return _mask; } |
| |
void setMask(Uint32 mask) { _mask = mask; } | void setMask(Uint32 mask) { _mask = mask; } |
|
|
| |
void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;} | void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;} |
| |
|
|
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
// | // |
// Needed for performance measurement | // Needed for performance measurement |
// | // |
| |
void startServer(); |
Uint64 getServerStartTime() const |
|
|
void endServer(); |
|
|
|
void startProvider(); |
|
|
|
void endProvider(); |
|
|
|
TimeValue getStartServerTime() const { return _timeServerStart; } |
|
|
|
void setStartServerTime(TimeValue timeServerStart) |
|
{ | { |
_timeServerStart = timeServerStart; |
return _serverStartTimeMicroseconds; |
} | } |
| |
TimeValue getStartProviderTime() const { return _timeProviderStart; } |
void setServerStartTime(Uint64 serverStartTimeMicroseconds) |
|
|
void setStartProviderTime(TimeValue timeProviderStart) |
|
{ | { |
_timeProviderStart = timeProviderStart; |
_serverStartTimeMicroseconds = serverStartTimeMicroseconds; |
} | } |
| |
TimeValue getEndServerTime() const { return _timeServerEnd; } |
void endServer(); |
| |
void setEndServerTime (TimeValue timeServerEnd) |
Uint64 getProviderTime() const |
{ | { |
_timeServerEnd = timeServerEnd; |
return _providerTimeMicroseconds; |
} | } |
| |
TimeValue getEndProviderTime() const { return _timeProviderEnd; } |
void setProviderTime(Uint64 providerTimeMicroseconds) |
|
|
void setEndProviderTime(TimeValue timeProviderEnd) |
|
{ | { |
_timeProviderEnd = timeProviderEnd; |
_providerTimeMicroseconds = providerTimeMicroseconds; |
} | } |
| |
TimeValue getServerTime() { return _serverTime; } |
Uint64 getTotalServerTime() const |
// |
{ |
#endif |
return _totalServerTimeMicroseconds; |
|
} |
Message* getNext() { return _next; } |
|
|
|
const Message* getNext() const { return _next; } |
|
|
|
Message* getPrevious() { return _prev; } |
|
|
|
const Message* getPrevious() const { return _prev; } |
|
| |
static Uint32 getNextKey() |
void setTotalServerTime(Uint64 totalServerTimeMicroseconds) |
{ | { |
AutoMutex autoMut(_mut); |
_totalServerTimeMicroseconds = totalServerTimeMicroseconds; |
Uint32 ret = _nextKey++; |
|
return ret; |
|
} | } |
| |
|
#endif |
|
|
static CIMOperationType convertMessageTypetoCIMOpType(Uint32 type); | static CIMOperationType convertMessageTypetoCIMOpType(Uint32 type); |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
|
|
Boolean printHeader = true) const; | Boolean printHeader = true) const; |
#endif | #endif |
| |
Boolean operator == (const void *msg ) |
Message* get_async() |
{ |
|
if (reinterpret_cast<void *>(this) == msg ) |
|
return true; |
|
return false; |
|
} |
|
|
|
Message *get_async(void) |
|
{ | { |
Message *ret = _async; | Message *ret = _async; |
_async = 0; | _async = 0; |
return ret; | return ret; |
|
|
} | } |
| |
void put_async(Message * msg) | void put_async(Message * msg) |
|
|
} | } |
| |
// << Tue Jul 1 11:02:49 2003 mdd >> pep_88 and helper for i18n and l10n | // << Tue Jul 1 11:02:49 2003 mdd >> pep_88 and helper for i18n and l10n |
Boolean thread_changed(void) |
Boolean thread_changed() |
{ | { |
if(_last_thread_id != pegasus_thread_self()) |
if (!Threads::equal(_last_thread_id, Threads::self())) |
{ | { |
_last_thread_id = pegasus_thread_self(); |
_last_thread_id = Threads::self(); |
return true; | return true; |
} | } |
| |
return false; | return false; |
} | } |
| |
// << Tue Jul 1 13:41:02 2003 mdd >> pep_88 - |
|
// assist in synchronizing responses with requests |
|
|
|
void synch_response(Message *req) |
|
{ |
|
_key = req->_key; |
|
_routing_code = req->_routing_code; |
|
} |
|
|
|
// set the message index indicating what piece (or sequence) this is | // set the message index indicating what piece (or sequence) this is |
// message indexes start at zero | // message indexes start at zero |
void setIndex(Uint32 index) { _index = index; } | void setIndex(Uint32 index) { _index = index; } |
|
|
// set the complete flag indicating if this message piece is the | // set the complete flag indicating if this message piece is the |
// last or not | // last or not |
void setComplete(Boolean isComplete) | void setComplete(Boolean isComplete) |
{ _isComplete = isComplete ? true:false; } |
{ |
|
_isComplete = isComplete ? true:false; |
|
} |
| |
// get the message index (or sequence number) | // get the message index (or sequence number) |
Uint32 getIndex() const { return _index; } | Uint32 getIndex() const { return _index; } |
|
|
| |
private: | private: |
Uint32 _type; | Uint32 _type; |
Uint32 _key; |
|
Uint32 _routing_code; |
|
Uint32 _mask; | Uint32 _mask; |
HttpMethod _httpMethod; | HttpMethod _httpMethod; |
|
|
|
#ifndef PEGASUS_DISABLE_PERFINST |
// Needed for performance measurement | // Needed for performance measurement |
TimeValue _timeServerStart; |
Uint64 _serverStartTimeMicroseconds; |
TimeValue _timeServerEnd; |
Uint64 _providerTimeMicroseconds; |
TimeValue _timeProviderStart; |
Uint64 _totalServerTimeMicroseconds; |
TimeValue _timeProviderEnd; |
#endif |
TimeValue _serverTime; |
|
Boolean _close_connect; | Boolean _close_connect; |
| |
// |
|
|
|
// << Tue Jul 1 11:02:35 2003 mdd >> pep_88 and helper for i18n and l10n | // << Tue Jul 1 11:02:35 2003 mdd >> pep_88 and helper for i18n and l10n |
PEGASUS_THREAD_TYPE _last_thread_id; |
ThreadType _last_thread_id; |
|
|
Message* _next; |
|
Message* _prev; |
|
|
|
protected: |
|
| |
public: | public: |
Message *_async; | Message *_async; |
Uint32 dest; | Uint32 dest; |
//needed for PEP 128 - transmitting Server Response Time to Client |
|
Uint64 totServerTime; |
|
| |
private: | private: |
MessageQueue* _owner; |
Message& operator=(const Message& msg); |
|
|
Boolean _isComplete; | Boolean _isComplete; |
Uint32 _index; | Uint32 _index; |
static Uint32 _nextKey; |
|
static Mutex _mut; |
|
|
|
|
|
|
|
friend class cimom; |
|
friend class MessageQueue; |
|
friend class MessageQueueService; |
|
friend class AsyncLegacyOperationStart; |
|
friend class AsyncLegacyOperationResult; |
|
|
|
}; | }; |
| |
| |
|
|
| |
QueueIdStack(const QueueIdStack& x); | QueueIdStack(const QueueIdStack& x); |
| |
PEGASUS_EXPLICIT QueueIdStack(Uint32 x); |
explicit QueueIdStack(Uint32 x); |
| |
PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2); |
explicit QueueIdStack(Uint32 x1, Uint32 x2); |
| |
~QueueIdStack() | ~QueueIdStack() |
{ | { |