Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohaifei committed Feb 14, 2022
1 parent 51cd2aa commit 59f20c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/graph/service/GraphService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ folly::Future<AuthResponse> GraphService::future_authenticate(const std::string&
return future;
}

if (!sessionManager_->isWithinConnections()) {
if (!sessionManager_->isOutOfConnections()) {
ctx->resp().errorCode = ErrorCode::E_TOO_MANY_CONNECTIONS;
ctx->resp().errorMsg.reset(new std::string("Too many connections in the cluster"));
ctx->finish();
Expand Down
1 change: 1 addition & 0 deletions src/graph/session/ClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ClientSession final {
// Creates a new ClientSession.
// session: session obj used in RPC.
// metaClient: used to communicate with meta server.
// return: ClientSession which will be created.
static std::shared_ptr<ClientSession> create(meta::cpp2::Session&& session,
meta::MetaClient* metaClient);

Expand Down
12 changes: 9 additions & 3 deletions src/graph/session/GraphSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ class GraphSessionManager final : public SessionManager<ClientSession> {
// userName: The name of the user who requesting to create the session.
// clientIp: The address of the client which sends the request.
// runner: Ensure that the corresponding callback function is executed on the runner.
// return: ClientSession which will be created.
folly::Future<StatusOr<std::shared_ptr<ClientSession>>> createSession(
const std::string userName, const std::string clientIp, folly::Executor* runner) override;

// Whether not exceeds the max allowed connections.
bool isWithinConnections() {
bool isOutOfConnections() {
if (activeSessions_.size() >= static_cast<uint64_t>(FLAGS_max_allowed_connections)) {
LOG(INFO) << "The sessions of the cluster has more than "
"max_allowed_connections: "
Expand All @@ -63,22 +64,26 @@ class GraphSessionManager final : public SessionManager<ClientSession> {
void removeSession(SessionID id) override;

// Finds an existing session. If it is not found locally, it will be searched from the meta
// server. id: The id of the session which will be found. runner: Ensure that the corresponding
// callback function is executed on the runner.
// server. id: The id of the session which will be found.
// runner: Ensure that the corresponding callback function is executed on the runner.
// return: ClientSession which will be found.
folly::Future<StatusOr<std::shared_ptr<ClientSession>>> findSession(
SessionID id, folly::Executor* runner) override;

// Finds an existing session only from local cache.
// id: The id of the session which will be found.
// return: ClientSession which will be found.
std::shared_ptr<ClientSession> findSessionFromCache(SessionID id);

// Gets all seesions from the local cache.
// return: All sessions of the local cache.
std::vector<meta::cpp2::Session> getSessionFromLocalCache() const;

private:
// Finds an existing session only from the meta server.
// id: The id of the session which will be found.
// runner: Ensure that the corresponding callback function is executed on the runner.
// return: ClientSession which will be found.
folly::Future<StatusOr<std::shared_ptr<ClientSession>>> findSessionFromMetad(
SessionID id, folly::Executor* runner);

Expand All @@ -94,6 +99,7 @@ class GraphSessionManager final : public SessionManager<ClientSession> {
void updateSessionsToMeta();

// Updates session info locally.
// session: ClientSession which will be updated.
void updateSessionInfo(ClientSession* session);
};

Expand Down

0 comments on commit 59f20c9

Please sign in to comment.