Previous | Contents | Index |
rtr_status_t GetMessageType(rtr_msg_type_t& mtMessageType);
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion |
RTR_STS_NOMESSAGE | The data object does not contain a message |
mtMessageType
An RTR message.
Retrieve the RTR message associated with the data in this RTRMessage object.
sStatus = ((RTRMessage*)pResult)->GetMessageType(mtMessageType); print_status_on_failure(sStatus);
rtr_reason_t GetReason();
rtr_status_t This function either returns RTR_NO_REASON or the value specified by the participants in the transaction. If different participants provide different reason codes, RTR ORs them.
None
Retrieve the reason associated with the accepting or rejection of the transaction.
void OnAccepted(RTRMessage* pRTRData, RTRClientTransactionController* pController) { rtr_status_t sStatus = pRTRData->GetSecondaryStatus(); rtr_reason_t rcReasonCode = pRTRData->GetReason(); m_bAcceptReceived = true; };
rtr_status_t GetSecondaryStatus();
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion |
RTR_STS_NOMESSAGE | The data object does not contain a message. |
None
Retrieve the secondary status associated with the accepting or rejection of the transaction.
void OnAccepted(RTRMessage* pRTRData, RTRClientTransactionController* pController) { rtr_status_t sStatus = pRTRData->GetSecondaryStatus(); rtr_reason_t rcReasonCode = pRTRData->GetReason(); m_bAcceptReceived = true; };
3.18 RTRStream Class
The RTRStream class derives from RTRData and extends the RTRData class
by allowing RTR applications to issue multiple read and write requests
to the buffer (managed by RTRData) without needing to maintain Pointer
to the end of the buffer.
An RTRStream object automatically handles the details of maintaining the offset within the buffer when the application wants to read and write multiple times to a buffer.
When reading from and writing to a stream, a copy of the data is performed.
Construction
Method | Description |
---|---|
RTRStream() | Default constructor |
~RTRStream | Default destructor |
Operations
Method | Description |
---|---|
ReadFromStream(rtr _msgbuf_t, rtr_msglen_t, rtr_msglen_t); | Copy the data from the buffer managed by RTRData to the buffer specified. |
ReadFromStream(rtr_sgn_32_t); | Copy the signed integer from the buffer managed by RTRData to uiNumber. |
ReadFromStream(char, size_t); | Copy the data from the buffer managed by RTRData to pString. |
ReadFromStream(rtr_uns_32_t); | Copy the unsigned integer from the buffer managed by RTRData to uiNumber. |
WriteToStream(rtr _msgbuf_t,
rtr_msglen_t); |
Copy data to the end of the buffer managed by RTRData. |
WriteToStream(const char); | Copy string to the end of the buffer managed by RTRData. |
WriteToStream(rtr_sgn_32_t); | Copy the signed integer to the end of the buffer managed by RTRData. |
WriteToStream(rtr_uns_32_t); | Copy the unsigned integer to the end of the buffer managed by RTRData. |
Operators
Operator | Description |
---|---|
RTRStream& operator>> (char) | ReadFromStream operator |
RTRStream& operator>>
(rtr_sgn_32_t) |
ReadFromStream operator |
RTRStream& operator>>
(rtr_uns_32_t) |
ReadFromStream operator |
RTRStream& operator<<
(const char) |
WriteToStream operator |
RTRStream& operator<<
(rtr_sgn_32_t) |
WriteToStream operator |
RTRStream& operator<<
(rtr_uns_32_t) |
WriteToStream operator |
RTRStream& operator>> (char *pString) { ReadFromStream(pString); return *this; } RTRStream& operator>> (rtr_sgn_32_t &iNumber) { ReadFromStream(iNumber); return *this; } RTRStream& operator>> (rtr_uns_32_t &uiNumber) { ReadFromStream(uiNumber); return *this; }
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion |
RTR_STS_INVARGPTR |
pString
Pointer to a character string.iNumber
A signed integer.uiNumber
An unsigned integer.
>> denotes the ReadFromStream operators. These member functions extract data from a buffer by calling ReadFromStream to read the data and return *this. The three types of stream data are string, signed, and unsigned.
// Populate this object with the data *this >> m_uiPrice >> m_uiISBN >> m_szTitle >> m_szAuthor; // The 1 line call above is equivilant to the 4 lines below. // ReadFromStream(m_uiISBN); // ReadFromStream(m_uiPrice); // ReadFromStream(m_szTitle); // ReadFromStream(m_szAuthor);
RTRStream& operator<< (char *pString) { WriteToStream(pString); return *this; } RTRStream& operator<< (rtr_sgn_32_t &iNumber) { WriteToStream(iNumber); return *this; } RTRStream& operator<< (rtr_uns_32_t &uiNumber) { WriteToStream(uiNumber); return *this; }
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion |
RTR_STS_INVSTRINGPTRARG | The string pointer argument is invalid - string too long. |
pString
Pointer to a character string.iNumber
A signed integer.uiNumber
An unsigned integer.
<< denotes the WriteToStream operators. These member functions write data to a buffer by calling WriteToStream to write the data and return *this. The three types of stream data are string, signed, and unsigned.
// Save the type of object we are. This is used by the class factory // on the server side to determine which type of class to allocate. *this << ABC_BOOK; *this << m_uiPrice << m_uiISBN << m_szTitle << m_szAuthor; // The 1 line call above is equivalent to the 4 lines below. We // can use the << and >> operators because we know that the data // which we store is not > the current RTR maximum = 65535 bytes. // WriteToStream(m_uiISBN); // WriteToStream(m_uiPrice); // WriteToStream(m_szTitle); // WriteToStream(m_szAuthor);
rtr_status_t ReadFromStream(rtr_msgbuf_t pvBuffer, rtr_msglen_t &uiBufferSize rtr_msglen_t &uiSizeCopied); rtr_status_t ReadFromStream(char *pString, size_t uiStringSize); rtr_status_t ReadFromStream(rtr_sgn_32_t &iNumber); rtr_status_t ReadFromStream(rtr_uns_32_t &uiNumber);
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion. |
RTR_STS_APPBUFFTOOSMALL | The application buffer is too small. |
RTR_STS_ENDOFSTREAM | The end-of-stream has been reached. |
uiBufferSize
An unsigned integer for length of the buffer.pvBuffer
A void pointer to a buffer.uiNumber
An unsigned integer.pString
Pointer to a character string.iNumber
A signed integer
Reads the first instance of a data type from a buffer as specified in the ReadFromStream methods. Note that the string buffer is assumed to be large enough (RTR_MAX_MSGLEN).
RTRStream::ReadFromStream(pString);
RTRStream();
None
None
Constructor method for the RTRStream class.
RTRStream::RTRStream();
rtr_status_t WriteToStream(rtr_const_msgbuf_t pvBuffer, rtr_msglen_t uiBufferLength); rtr_status_t WriteToStream(const char *pString); rtr_status_t WriteToStream(rtr_sgn_32_t iNumber); rtr_status_t WriteToStream(rtr_uns_32_t uiNumber);
rtr_status_t Interpret value for the success or failure of this call.
Status | Message |
---|---|
RTR_STS_OK | Normal successful completion. |
RTR_STS_ENDOFSTREAM | The end-of-stream has been reached. |
uiBufferLength
An unsigned integer for length of the buffer.pvBuffer
A void pointer to a buffer.uiNumber
An unsigned integer.iNumber
A signed integer.pString
Pointer to a character string.
Write to a data buffer, specifying the data with either buffer and buffer length, as unsigned integer, or string.
RTRStream::WriteToStream(uiNumber);
Management classes are offered for both new and existing RTR applications. The types of management classes include:
4.1 RTR
The RTR class is a setup class, for RTR system management operations,
designed for starting and stopping RTR, and creating and deleting RTR
journals.
Construction
Method | Description |
---|---|
RTR() | Constructor |
~RTR() | Destructor |
Operations
Method | Description |
---|---|
CreateJournal(bool) | Create a journal for RTR. |
DeleteJournal() | Delete the journal for RTR. |
GetErrorText(rtr_status_t) | Get the error text associated with the rtr_status_t return value. |
IsRunning() | Determine if RTR is running. |
Start() | Start RTR. |
StartWebServer(bool, bool) | Start RTR on a web server. |
Stop() | Stop RTR. |
StopWebServer() | Stop RTR on a web server. |
rtr_status_t CreateJournal( bool bSupersede = false);
rtr_status_t Interpret value for the success or failure of this call.
Status Message RTR_STS_OK Normal successful completion RTR_STS_ ILLDEVTYP RTR can only create its journal files on directory structured devices.
bSupersede
A boolean attribute that specifies how to handle cases where a journal already exists. Set bSupersede to true to overwrite an existing journal. If set to false, a journal is created only if no journal previously existed.
Call this method to create an RTR journal file. A journal is required for all facility members with a backend role, and any frontends that participate in nested transactions.For more information on RTR journals, see the RTR Application Design Guide and the RTR System Manager's Manual .
// Declare an RTR object. RTR *myRTR = new RTR(); rtr_status_t sStatus; bool bSupersede = false; // false -> no supersede sStatus = myRTR->CreateJournal(bSupersede);
rtr_status_t DeleteJournal();
rtr_status_t The RTR status message return value. RTR_STS_OK is the normal successful completion.
None
Call this method for deleting a journal.For more information on RTR journals, see the RTR System Manager's Manual .
// declare an RTR object RTR *myRTR = new RTR(); rtr_status_t sStatus; sStatus = myRTR->DeleteJournal();
static const char *GetErrorText(rtr_status_t sStatus);
Returns a pointer to the error message text associated with a known RTR message.
rtr_status_t
The RTR status message return value. RTR_STS_OK is the normal successful completion.
Call this method to retrieve the error message text associated with an RTR status.
// start rtr RTRmyRTR; sStatus = myRTR.Start(); cout << myRTR.GetErrorText(sStatus) << endl; // create journal sStatus = myRTR.CreateJournal(true); cout << myRTR.GetErrorText(sStatus) << endl;
//An example from the Sample application in the Examples directory inline void print_status_on_failure(rtr_status_t sStatus) { switch (sStatus) { case ABCSuccess : case ABCOrderSucceeded : case ABCOrderFailed :{ break; } default: { cout << RTR::GetErrorText(sStatus); break; }; } return; }
bool IsRunning();
Status | Message |
---|---|
TRUE | RTR is running. |
FALSE | RTR is not running. |
None
Call this method to find out if RTR is running on this node. If RTR is running, it will return a true, otherwise an error code.
RTR *myRTR = new RTR(); rtr_status_t sStatus; sStatus = myRTR->IsRunning();
Previous | Next | Contents | Index |