void Connection::maybe_set_keyspace(ResponseMessage* response) { if (response->opcode() == CQL_OPCODE_RESULT) { ResultResponse* result = static_cast<ResultResponse*>(response->response_body().get()); if (result->kind() == CASS_RESULT_KIND_SET_KEYSPACE) { keyspace_ = result->keyspace().to_string(); } } }
void Connection::StartupHandler::on_result_response(ResponseMessage* response) { ResultResponse* result = static_cast<ResultResponse*>(response->response_body().get()); switch (result->kind()) { case CASS_RESULT_KIND_SET_KEYSPACE: connection_->on_set_keyspace(); break; default: connection_->notify_error("Invalid result response. Expected set keyspace."); break; } }
void SetKeyspaceHandler::on_result_response(ResponseMessage* response) { ResultResponse* result = static_cast<ResultResponse*>(response->response_body().get()); if (result->kind() == CASS_RESULT_KIND_SET_KEYSPACE) { if (!connection_->write(request_handler_.get())) { // Try on the same host but a different connection request_handler_->retry(RETRY_WITH_CURRENT_HOST); } } else { connection_->defunct(); request_handler_->on_error(CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE, "Unable to set keyspace"); } }
void PrepareHandler::on_set(ResponseMessage* response) { switch (response->opcode()) { case CQL_OPCODE_RESULT: { ResultResponse* result = static_cast<ResultResponse*>(response->response_body().get()); if (result->kind() == CASS_RESULT_KIND_PREPARED) { request_handler_->retry(); } else { request_handler_->next_host(); request_handler_->retry(); } } break; case CQL_OPCODE_ERROR: request_handler_->next_host(); request_handler_->retry(); break; default: break; } }
void RequestHandler::on_result_response(ResponseMessage* response) { ResultResponse* result = static_cast<ResultResponse*>(response->response_body().get()); switch (result->kind()) { case CASS_RESULT_KIND_ROWS: // Execute statements with no metadata get their metadata from // result_metadata() returned when the statement was prepared. if (request_->opcode() == CQL_OPCODE_EXECUTE && result->no_metadata()) { const ExecuteRequest* execute = static_cast<const ExecuteRequest*>(request_.get()); if (!execute->skip_metadata()) { // Caused by a race condition in C* 2.1.0 on_error(CASS_ERROR_LIB_UNEXPECTED_RESPONSE, "Expected metadata but no metadata in response (see CASSANDRA-8054)"); return; } result->set_metadata(execute->prepared()->result()->result_metadata().get()); } set_response(response->response_body()); break; case CASS_RESULT_KIND_SCHEMA_CHANGE: { SharedRefPtr<SchemaChangeHandler> schema_change_handler( new SchemaChangeHandler(connection_, this, response->response_body())); schema_change_handler->execute(); break; } case CASS_RESULT_KIND_SET_KEYSPACE: io_worker_->broadcast_keyspace_change(result->keyspace().to_string()); set_response(response->response_body()); break; default: set_response(response->response_body()); break; } }