forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Head HA #499
Open
weiquanlee
wants to merge
5
commits into
main
Choose a base branch
from
head_ha
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Head HA #499
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ray.ha.leader_selector import HeadNodeLeaderSelector | ||
from ray.ha.leader_selector import HeadNodeLeaderSelectorConfig | ||
from ray.ha.redis_leader_selector import RedisBasedLeaderSelector | ||
from ray.ha.redis_leader_selector import is_service_available | ||
from ray.ha.redis_leader_selector import waiting_for_server_stopped | ||
|
||
__all__ = [ | ||
"RedisBasedLeaderSelector", | ||
"HeadNodeLeaderSelector", | ||
"HeadNodeLeaderSelectorConfig", | ||
"is_service_available", | ||
"waiting_for_server_stopped", | ||
] |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import logging | ||
import os | ||
import ray._private.ray_constants as ray_constants | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HeadNodeLeaderSelectorConfig: | ||
# Will exit after N consecutive failures | ||
max_failure_count = None | ||
# The interval time for selecting the leader or expire leader | ||
check_interval_s = None | ||
# The expiration time of the leader key | ||
key_expire_time_ms = None | ||
# The time to wait after becoming the active allows the gcs client to | ||
# have enough time to find out that the gcs address has changed. | ||
wait_time_after_be_active_s = None | ||
# Maximum time to wait pre gcs stop serving | ||
wait_pre_gcs_stop_max_time_s = None | ||
# Redis/socket connect time out(s) | ||
connect_timeout_s = None | ||
|
||
def __init__(self): | ||
self.max_failure_count = int( | ||
os.environ.get("RAY_HA_CHECK_MAX_FAILURE_COUNT", "5") | ||
) | ||
# Default 3s | ||
self.check_interval_s = ( | ||
int(os.environ.get("RAY_HA_CHECK_INTERVAL_MS", "3000")) / 1000 | ||
) | ||
# Default 60s | ||
self.key_expire_time_ms = int( | ||
os.environ.get("RAY_HA_KEY_EXPIRE_TIME_MS", "60000") | ||
) | ||
# Default 2s | ||
self.wait_time_after_be_active_s = ( | ||
int(os.environ.get("RAY_HA_WAIT_TIME_AFTER_BE_ACTIVE_MS", "2000")) / 1000 | ||
) | ||
# Default 3 day (1000 * 60 * 60 * 24 * 3). | ||
self.wait_pre_gcs_stop_max_time_s = ( | ||
int(os.environ.get("RAY_HA_WAIT_PRE_GCS_STOP_MAX_TIME_MS", "259200000")) | ||
/ 1000 | ||
) | ||
# Default redis/socket connect time out is 5s. | ||
self.connect_timeout_s = ( | ||
int(os.environ.get("RAY_HA_CONNECT_TIMEOUT_MS", "5000")) / 1000 | ||
) | ||
|
||
def __repr__(self) -> str: | ||
return ( | ||
f"HeadNodeLeaderSelectorConfig[" | ||
f"max_failure_count={self.max_failure_count}," | ||
f"check_interval_s={self.check_interval_s}," | ||
f"key_expire_time_ms={self.key_expire_time_ms}," | ||
f"wait_time_after_be_active_s={self.wait_time_after_be_active_s}," | ||
f"wait_pre_gcs_stop_max_time_s=" | ||
f"{self.wait_pre_gcs_stop_max_time_s}," | ||
f"connect_timeout_s={self.connect_timeout_s}]" | ||
) | ||
|
||
|
||
class HeadNodeLeaderSelector: | ||
_role_type = ray_constants.HEAD_ROLE_STANDBY | ||
_config = None | ||
_is_running = False | ||
|
||
def __init__(self): | ||
self._config = HeadNodeLeaderSelectorConfig() | ||
|
||
def start(self): | ||
pass | ||
|
||
def stop(self): | ||
pass | ||
|
||
def set_role_type(self, role_type): | ||
if role_type != self._role_type: | ||
logger.info( | ||
"This head node changed from %s to %s.", self._role_type, role_type | ||
) | ||
self._role_type = role_type | ||
|
||
def get_role_type(self): | ||
return self._role_type | ||
|
||
def is_leader(self): | ||
return self.get_role_type() == ray_constants.HEAD_ROLE_ACTIVE | ||
|
||
def do_action_after_be_active(self): | ||
pass | ||
|
||
def is_running(self): | ||
return self._is_running |
Oops, something went wrong.
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 not use
RAY_