| 2107 | } |
| 2108 | |
| 2109 | Status ImpalaServer::GetSessionState(const TUniqueId& session_id, const SecretArg& secret, |
| 2110 | shared_ptr<SessionState>* session_state, bool mark_active) { |
| 2111 | lock_guard<mutex> l(session_state_map_lock_); |
| 2112 | SessionStateMap::iterator i = session_state_map_.find(session_id); |
| 2113 | // TODO: consider factoring out the lookup and secret validation into a separate method. |
| 2114 | // This would require rethinking the locking protocol for 'session_state_map_lock_' - |
| 2115 | // it probably doesn't not need to be held for the full duration of this function. |
| 2116 | if (i == session_state_map_.end() || !secret.Validate(i->second->secret)) { |
| 2117 | if (i != session_state_map_.end()) { |
| 2118 | // Log invalid attempts to connect. Be careful not to log secret. |
| 2119 | VLOG(1) << "Client tried to connect to session " << PrintId(session_id) |
| 2120 | << " with invalid " |
| 2121 | << (secret.is_session_secret() ? "session" : "operation") << " secret."; |
| 2122 | } |
| 2123 | *session_state = shared_ptr<SessionState>(); |
| 2124 | string err_msg = secret.is_session_secret() ? |
| 2125 | Substitute("Invalid session id: $0", PrintId(session_id)) : |
| 2126 | Substitute(LEGACY_INVALID_QUERY_HANDLE_TEMPLATE, PrintId(secret.query_id())); |
| 2127 | VLOG(1) << "GetSessionState(): " << err_msg; |
| 2128 | return Status::Expected(err_msg); |
| 2129 | } else { |
| 2130 | if (mark_active) { |
| 2131 | lock_guard<mutex> session_lock(i->second->lock); |
| 2132 | if (i->second->expired) { |
| 2133 | stringstream ss; |
| 2134 | ss << "Client session expired due to more than " << i->second->session_timeout |
| 2135 | << "s of inactivity (last activity was at: " |
| 2136 | << ToStringFromUnixMillis(i->second->last_accessed_ms) << ")."; |
| 2137 | return Status::Expected(ss.str()); |
| 2138 | } |
| 2139 | if (i->second->closed) { |
| 2140 | VLOG(1) << "GetSessionState(): session " << PrintId(session_id) << " is closed."; |
| 2141 | return Status::Expected("Session is closed"); |
| 2142 | } |
| 2143 | ++i->second->ref_count; |
| 2144 | } |
| 2145 | *session_state = i->second; |
| 2146 | return Status::OK(); |
| 2147 | } |
| 2148 | } |
| 2149 | |
| 2150 | void ImpalaServer::InitializeConfigVariables() { |
| 2151 | // Set idle_session_timeout here to let the SET command return the value of |
no test coverage detected