diff --git a/server/modules/routing/schemarouter/schemaroutersession.cc b/server/modules/routing/schemarouter/schemaroutersession.cc index cfe14c5ef..d20ab64dc 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.cc +++ b/server/modules/routing/schemarouter/schemaroutersession.cc @@ -274,7 +274,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) if (m_shard.empty()) { /* Generate database list */ - gen_databaselist(); + query_databases(); } int ret = 0; @@ -328,7 +328,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) /** Create the response to the SHOW DATABASES from the mapped databases */ if (qc_query_is_type(type, QUERY_TYPE_SHOW_DATABASES)) { - if (send_database_list()) + if (send_databases()) { ret = 1; } @@ -338,7 +338,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) } else if (detect_show_shards(pPacket)) { - if (process_show_shards()) + if (send_shards()) { ret = 1; } @@ -452,11 +452,11 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) } void SchemaRouterSession::handle_mapping_reply(SBackend& bref, GWBUF** pPacket) { - int rc = inspect_backend_mapping_states(bref, pPacket); + int rc = inspect_mapping_states(bref, pPacket); if (rc == 1) { - synchronize_shard_map(); + synchronize_shards(); m_state &= ~INIT_MAPPING; /* Check if the session is reconnecting with a database name @@ -484,7 +484,7 @@ void SchemaRouterSession::handle_mapping_reply(SBackend& bref, GWBUF** pPacket) } } -void SchemaRouterSession::process_response(SBackend& bref, GWBUF** ppPacket) +void SchemaRouterSession::process_sescmd_response(SBackend& bref, GWBUF** ppPacket) { if (bref->session_command_count()) { @@ -563,7 +563,7 @@ void SchemaRouterSession::clientReply(GWBUF* pPacket, DCB* pDcb) } else { - process_response(bref, &pPacket); + process_sescmd_response(bref, &pPacket); if (pPacket) { @@ -646,7 +646,7 @@ void SchemaRouterSession::handleError(GWBUF* pMessage, * is discarded and the router's shard map is used. * @param client Router session */ -void SchemaRouterSession::synchronize_shard_map() +void SchemaRouterSession::synchronize_shards() { m_router->m_stats.shmap_cache_miss++; m_router->m_shard_manager.update_shard(m_shard, m_client->user); @@ -892,7 +892,7 @@ RESULT_ROW* shard_list_cb(struct resultset* rset, void* data) * @param rses Router client session * @return 0 on success, -1 on error */ -bool SchemaRouterSession::process_show_shards() +bool SchemaRouterSession::send_shards() { bool rval = false; @@ -1022,8 +1022,8 @@ void SchemaRouterSession::route_queued_query() * @param router_cli_ses Router client session * @return 1 if mapping is done, 0 if it is still ongoing and -1 on error */ -int SchemaRouterSession::inspect_backend_mapping_states(SBackend& bref, - GWBUF** wbuf) +int SchemaRouterSession::inspect_mapping_states(SBackend& bref, + GWBUF** wbuf) { bool mapped = true; GWBUF* writebuf = *wbuf; @@ -1032,7 +1032,7 @@ int SchemaRouterSession::inspect_backend_mapping_states(SBackend& bref, { if (bref->dcb() == (*it)->dcb() && !(*it)->is_mapped()) { - enum showdb_response rc = parse_showdb_response(*it, &writebuf); + enum showdb_response rc = parse_mapping_response(*it, &writebuf); if (rc == SHOWDB_FULL_RESPONSE) { @@ -1262,7 +1262,7 @@ bool SchemaRouterSession::ignore_duplicate_database(const char* data) * @return 1 if a complete response was received, 0 if a partial response was received * and -1 if a database was found on more than one server. */ -enum showdb_response SchemaRouterSession::parse_showdb_response(SBackend& bref, GWBUF** buffer) +enum showdb_response SchemaRouterSession::parse_mapping_response(SBackend& bref, GWBUF** buffer) { unsigned char* ptr; SERVER* target = bref->backend()->server; @@ -1378,7 +1378,7 @@ enum showdb_response SchemaRouterSession::parse_showdb_response(SBackend& bref, * @param session Router client session * @return 1 if all writes to backends were succesful and 0 if one or more errors occurred */ -void SchemaRouterSession::gen_databaselist() +void SchemaRouterSession::query_databases() { for (BackendList::iterator it = m_backends.begin(); it != m_backends.end(); it++) @@ -1645,7 +1645,7 @@ RESULT_ROW *result_set_cb(struct resultset * rset, void *data) * @param client Router client session * @return True if the sending of the database list was successful, otherwise false */ -bool SchemaRouterSession::send_database_list() +bool SchemaRouterSession::send_databases() { bool rval = false; diff --git a/server/modules/routing/schemarouter/schemaroutersession.hh b/server/modules/routing/schemarouter/schemaroutersession.hh index dd47b4ee2..8bfb7803f 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.hh +++ b/server/modules/routing/schemarouter/schemaroutersession.hh @@ -122,25 +122,33 @@ public: mxs_error_action_t action, bool* pSuccess); private: - /** Internal functions */ - SERVER* get_shard_target(GWBUF* buffer, uint32_t qtype); + /** + * Internal functions + */ + + /** Helper functions */ + SERVER* get_shard_target(GWBUF* buffer, uint32_t qtype); SBackend get_bref_from_dcb(DCB* dcb); - bool get_shard_dcb(DCB** dcb, char* name); - bool handle_default_db(); - bool have_servers(); - bool route_session_write(GWBUF* querybuf, uint8_t command); - bool send_database_list(); - void gen_databaselist(); - int inspect_backend_mapping_states(SBackend& bref, GWBUF** wbuf); - bool process_show_shards(); - enum showdb_response parse_showdb_response(SBackend& bref, GWBUF** buffer); - void route_queued_query(); - void synchronize_shard_map(); - void handle_mapping_reply(SBackend& bref, GWBUF** pPacket); - void process_response(SBackend& bref, GWBUF** ppPacket); + bool get_shard_dcb(DCB** dcb, char* name); + bool have_servers(); + bool handle_default_db(); + bool ignore_duplicate_database(const char* data); + + /** Routing functions */ + bool route_session_write(GWBUF* querybuf, uint8_t command); + void process_sescmd_response(SBackend& bref, GWBUF** ppPacket); SERVER* resolve_query_target(GWBUF* pPacket, uint32_t type, uint8_t command, enum route_target& route_target); - bool ignore_duplicate_database(const char* data); + + /** Shard mapping functions */ + bool send_databases(); + bool send_shards(); + void query_databases(); + int inspect_mapping_states(SBackend& bref, GWBUF** wbuf); + enum showdb_response parse_mapping_response(SBackend& bref, GWBUF** buffer); + void route_queued_query(); + void synchronize_shards(); + void handle_mapping_reply(SBackend& bref, GWBUF** pPacket); /** Member variables */ bool m_closed; /**< True if session closed */