Skip to content
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

Update worker hash ring #58

Merged
merged 22 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions alluxio/alluxio_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import requests
from requests.adapters import HTTPAdapter

from .const import ALLUXIO_HASH_NODE_PER_WORKER_DEFAULT_VALUE
from .const import ALLUXIO_HASH_NODE_PER_WORKER_KEY
from .const import ALLUXIO_PAGE_SIZE_DEFAULT_VALUE
from .const import ALLUXIO_PAGE_SIZE_KEY
from .const import ALLUXIO_SUCCESS_IDENTIFIER
Expand Down Expand Up @@ -141,20 +143,32 @@ def __init__(
"Supply either 'etcd_hosts' or 'worker_hosts', not both"
)
self.logger = logger or logging.getLogger("AlluxioFileSystem")
if etcd_hosts and not worker_hosts:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Union type in python to indicate OR semantic

self.logger.warning(
"Does not supply 'etcd_hosts'. An etcd cluster is required for dynamic cluster changes."
)
self.session = self._create_session(concurrency)

# parse options
page_size = ALLUXIO_PAGE_SIZE_DEFAULT_VALUE
hash_node_per_worker = int(ALLUXIO_HASH_NODE_PER_WORKER_DEFAULT_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we put default value as string and convert here? We can just define as int at the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChunxuTang previously put Alluxio related key=value string pair into the const file, we can discuss about what are the best way for dealing with property key and values

if options:
if ALLUXIO_PAGE_SIZE_KEY in options:
page_size = options[ALLUXIO_PAGE_SIZE_KEY]
self.logger.debug(f"Page size is set to {page_size}")
if ALLUXIO_HASH_NODE_PER_WORKER_KEY in options:
hash_node_per_worker = int(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The const is all string format, the const file is kind of Alluxio property key files now

options[ALLUXIO_HASH_NODE_PER_WORKER_KEY]
)
self.logger.debug(
f"Hash node per worker is set to {hash_node_per_worker}"
)

self.page_size = humanfriendly.parse_size(page_size, binary=True)
self.hash_provider = ConsistentHashProvider(
etcd_hosts=etcd_hosts,
etcd_port=int(etcd_port),
worker_hosts=worker_hosts,
worker_http_port=http_port,
hash_node_per_worker=hash_node_per_worker,
options=options,
logger=self.logger,
etcd_refresh_workers_interval=etcd_refresh_workers_interval,
Expand Down
4 changes: 4 additions & 0 deletions alluxio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
ALLUXIO_ETCD_PASSWORD_KEY = "alluxio.etcd.password"
ALLUXIO_PAGE_SIZE_KEY = "alluxio.worker.page.store.page.size"
ALLUXIO_PAGE_SIZE_DEFAULT_VALUE = "1MB"
ALLUXIO_HASH_NODE_PER_WORKER_KEY = (
"alluxio.user.consistent.hash.virtual.node.count.per.worker"
)
ALLUXIO_HASH_NODE_PER_WORKER_DEFAULT_VALUE = "5"
ALLUXIO_SUCCESS_IDENTIFIER = "success"
LIST_URL_FORMAT = "http://{worker_host}:{http_port}/v1/files"
FULL_PAGE_URL_FORMAT = (
Expand Down
Loading
Loading