Make connections and command queues internal to Backends
The SERVER_REF and DCB members of the Backend class are now private. Access to the stored SERVER_REF is provided with the backend() function. No accompanying setter function is provided as the backend server should not change during the lifetime of the session. The creation of the internal DCB is hidden behind the connect() function. It simplifies the process of connecting to a server by removing the need to manually do the bookkeeping of the server reference connection counts. Access to the DCB is provided by the dcb() function. The closing of the backend is done with the close() function which contains the code that was previously in closeSession. If the backend isn't closed when the destructor is called, it will be done automatically. This should prevent connection leakage. The pending command queues and the methods used to write them are now also internal to the backends. They are simple wrappers around dcb->func.write and the interfaces provided by the Buffer class. The mapping command queue is still public. It needs to be combined with the generic command queue.
This commit is contained in:
@ -130,14 +130,25 @@ public:
|
||||
bool execute_sescmd();
|
||||
void clear_state(enum bref_state state);
|
||||
void set_state(enum bref_state state);
|
||||
SERVER_REF* backend() const;
|
||||
bool connect(MXS_SESSION*);
|
||||
void close();
|
||||
DCB* dcb() const;
|
||||
bool write(GWBUF* buffer);
|
||||
void store_command(GWBUF* buffer);
|
||||
bool write_stored_command();
|
||||
|
||||
private:
|
||||
bool m_closed; /**< True if a connection has been opened and closed */
|
||||
SERVER_REF* m_backend; /**< Backend server */
|
||||
DCB* m_dcb; /**< Backend DCB */
|
||||
|
||||
public:
|
||||
GWBUF* m_map_queue;
|
||||
bool m_mapped; /**< Whether the backend has been mapped */
|
||||
int m_num_mapping_eof;
|
||||
int m_num_result_wait; /**< Number of not yet received results */
|
||||
GWBUF* m_pending_cmd; /**< Pending commands */
|
||||
Buffer m_pending_cmd; /**< Pending commands */
|
||||
int m_state; /**< State of the backend */
|
||||
SessionCommandList m_session_commands; /**< List of session commands that are
|
||||
* to be executed on this backend server */
|
||||
|
Reference in New Issue
Block a user