mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Refactor object store cache parsing for de-duplication.
This commit is contained in:
@@ -30,6 +30,7 @@ from . import ConcreteObjectStore
|
||||
from .caching import (
|
||||
CacheTarget,
|
||||
InProcessCacheMonitor,
|
||||
parse_caching_config_dict_from_xml,
|
||||
)
|
||||
|
||||
NO_BLOBSERVICE_ERROR_MESSAGE = (
|
||||
@@ -51,18 +52,7 @@ def parse_config_xml(config_xml):
|
||||
container_name = container_xml.get("name")
|
||||
max_chunk_size = int(container_xml.get("max_chunk_size", 250)) # currently unused
|
||||
|
||||
cache_els = config_xml.findall("cache")
|
||||
if len(cache_els) > 0:
|
||||
c_xml = config_xml.findall("cache")[0]
|
||||
cache_size = float(c_xml.get("size", -1))
|
||||
staging_path = c_xml.get("path", None)
|
||||
|
||||
cache_dict = {
|
||||
"size": cache_size,
|
||||
"path": staging_path,
|
||||
}
|
||||
else:
|
||||
cache_dict = {}
|
||||
cache_dict = parse_caching_config_dict_from_xml(config_xml)
|
||||
|
||||
tag, attrs = "extra_dir", ("type", "path")
|
||||
extra_dirs = config_xml.findall(tag)
|
||||
|
||||
@@ -98,6 +98,23 @@ def _get_cache_size_files(cache_path) -> Tuple[int, FileListT]:
|
||||
return cache_size, file_list
|
||||
|
||||
|
||||
def parse_caching_config_dict_from_xml(config_xml):
|
||||
cache_els = config_xml.findall("cache")
|
||||
if len(cache_els) > 0:
|
||||
c_xml = config_xml.findall("cache")[0]
|
||||
cache_size = float(c_xml.get("size", -1))
|
||||
|
||||
staging_path = c_xml.get("path", None)
|
||||
|
||||
cache_dict = {
|
||||
"size": cache_size,
|
||||
"path": staging_path,
|
||||
}
|
||||
else:
|
||||
cache_dict = {}
|
||||
return cache_dict
|
||||
|
||||
|
||||
class InProcessCacheMonitor:
|
||||
def __init__(self, cache_target: CacheTarget, interval: int = 30, initial_sleep: Optional[int] = 2):
|
||||
# This Event object is initialized to False
|
||||
|
||||
@@ -35,6 +35,7 @@ from . import ConcreteObjectStore
|
||||
from .caching import (
|
||||
CacheTarget,
|
||||
InProcessCacheMonitor,
|
||||
parse_caching_config_dict_from_xml,
|
||||
)
|
||||
from .s3_multipart_upload import multipart_upload
|
||||
|
||||
@@ -70,19 +71,7 @@ def parse_config_xml(config_xml):
|
||||
is_secure = string_as_bool(cn_xml.get("is_secure", "True"))
|
||||
conn_path = cn_xml.get("conn_path", "/")
|
||||
|
||||
cache_els = config_xml.findall("cache")
|
||||
if len(cache_els) > 0:
|
||||
c_xml = config_xml.findall("cache")[0]
|
||||
cache_size = float(c_xml.get("size", -1))
|
||||
|
||||
staging_path = c_xml.get("path", None)
|
||||
|
||||
cache_dict = {
|
||||
"size": cache_size,
|
||||
"path": staging_path,
|
||||
}
|
||||
else:
|
||||
cache_dict = {}
|
||||
cache_dict = parse_caching_config_dict_from_xml(config_xml)
|
||||
|
||||
tag, attrs = "extra_dir", ("type", "path")
|
||||
extra_dirs = config_xml.findall(tag)
|
||||
|
||||
Reference in New Issue
Block a user