-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
comment the graph::session module (Part 1) #3878
Merged
critical27
merged 9 commits into
vesoft-inc:master
from
zhaohaifei:modify_and_comment_session
Feb 14, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e0313e3
comment GraphSessionManager
zhaohaifei cf4d8e0
comment ClientSession
zhaohaifei 06c8785
modify_and_comment_session
zhaohaifei 54ba295
comment
zhaohaifei 6bed5a4
add more comment
zhaohaifei 51cd2aa
fix comment
zhaohaifei 59f20c9
fix comment
zhaohaifei 0f1554f
fix comment
zhaohaifei 84cdd71
Merge branch 'master' into modify_and_comment_session
zhaohaifei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
// Copyright (c) 2020 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#ifndef GRAPH_SESSION_CLIENTSESSION_H_ | ||
#define GRAPH_SESSION_CLIENTSESSION_H_ | ||
|
||
|
@@ -23,8 +23,15 @@ struct SpaceInfo { | |
meta::cpp2::SpaceDesc spaceDesc; | ||
}; | ||
|
||
// ClientSession saves those information, including who created it, executed queries, | ||
// space role, etc. The information of session will be persisted in meta server. | ||
// One user corresponds to one ClientSession. | ||
class ClientSession final { | ||
public: | ||
// Creates a new ClientSession. | ||
// session: session obj used in RPC. | ||
// metaClient: used to communicate with meta server. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
// return: ClientSession which will be created. | ||
static std::shared_ptr<ClientSession> create(meta::cpp2::Session&& session, | ||
meta::MetaClient* metaClient); | ||
|
||
|
@@ -61,6 +68,7 @@ class ClientSession final { | |
return roles_; | ||
} | ||
|
||
// Gets the role information of the user on a specific space. | ||
StatusOr<meta::cpp2::RoleType> roleWithSpace(GraphSpaceID space) const { | ||
folly::RWSpinLock::ReadHolder rHolder(rwSpinLock_); | ||
auto ret = roles_.find(space); | ||
|
@@ -70,6 +78,8 @@ class ClientSession final { | |
return ret->second; | ||
} | ||
|
||
// Whether the user corresponding to the session is a GOD user. | ||
// As long as a user has the GOD role in any space, the user must be a GOD user. | ||
bool isGod() const { | ||
folly::RWSpinLock::ReadHolder rHolder(rwSpinLock_); | ||
// Cloud may have multiple God accounts | ||
|
@@ -86,8 +96,10 @@ class ClientSession final { | |
roles_.emplace(space, role); | ||
} | ||
|
||
// The idle time of the session. Unit: second. | ||
uint64_t idleSeconds(); | ||
|
||
// Resets the idle time of the session. | ||
void charge(); | ||
|
||
int32_t getTimezone() const { | ||
|
@@ -129,14 +141,23 @@ class ClientSession final { | |
session_.space_name_ref() = spaceName; | ||
} | ||
|
||
// Binds a query to the session. | ||
// qctx: represents a query. | ||
void addQuery(QueryContext* qctx); | ||
|
||
// Deletes a query from the session. | ||
// qctx: represents a query. | ||
void deleteQuery(QueryContext* qctx); | ||
|
||
// Finds a query within the session. | ||
// epId: represents a query. | ||
bool findQuery(nebula::ExecutionPlanID epId) const; | ||
|
||
// Marks a query as killed. | ||
// epId: represents a query. | ||
void markQueryKilled(nebula::ExecutionPlanID epId); | ||
|
||
// Marks all queries as killed. | ||
void markAllQueryKilled(); | ||
|
||
private: | ||
|
@@ -145,17 +166,20 @@ class ClientSession final { | |
explicit ClientSession(meta::cpp2::Session&& session, meta::MetaClient* metaClient); | ||
|
||
private: | ||
SpaceInfo space_; | ||
SpaceInfo space_; // The space that the session is using. | ||
// When the idle time exceeds FLAGS_session_idle_timeout_secs, | ||
// the session will expire and then be reclaimed. | ||
time::Duration idleDuration_; | ||
meta::cpp2::Session session_; | ||
meta::MetaClient* metaClient_{nullptr}; | ||
meta::cpp2::Session session_; // The session object used in RPC. | ||
meta::MetaClient* metaClient_{nullptr}; // The client of the meta server. | ||
mutable folly::RWSpinLock rwSpinLock_; | ||
/* | ||
* map<spaceId, role> | ||
* One user can have roles in multiple spaces | ||
* But a user has only one role in one space | ||
*/ | ||
|
||
// map<spaceId, role> | ||
// One user can have roles in multiple spaces | ||
// But a user has only one role in one space | ||
std::unordered_map<GraphSpaceID, meta::cpp2::RoleType> roles_; | ||
// An ExecutionPlanID represents a query. | ||
// A QueryContext also represents a query. | ||
std::unordered_map<ExecutionPlanID, QueryContext*> contexts_; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change the comment format? This changes maybe invalidate the license checker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new comment requirement:
https://confluence.nebula-graph.io/pages/viewpage.action?pageId=35293986
The license check looks fine, it can pass.