Skip to content

Commit

Permalink
Update worker hash ring (#58)
Browse files Browse the repository at this point in the history
Update ETCD and static worker hash ring to match AOS 309 hash ring changes
  • Loading branch information
LuQQiu authored Feb 21, 2024
1 parent 51c4ca3 commit 6c76b86
Show file tree
Hide file tree
Showing 10 changed files with 2,073 additions and 164 deletions.
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:
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)
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(
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

0 comments on commit 6c76b86

Please sign in to comment.