summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-09 19:24:02 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-10 16:53:57 +0900
commit335b2fdd56802e26f127703964846d5593eca6a3 (patch)
tree079d13b2d121eead6998c67ec8a725d6538df880
parent742908ea79abf0a6ff00a522e12fa32ba4a0aa7c (diff)
downloadbuildstream-335b2fdd56802e26f127703964846d5593eca6a3.tar.gz
element.py: Remove _get_artifact_cache() accessor.
The artifact cache is anyway a singleton, the Element itself has an internal handle on the artifact cache because it is needed very frequently; but an artifact cache is not element specific and should not be looked up by surrounding code on a per element basis. Updated _scheduler/queues/queue.py, _scheduler/queues/buildqueue.py and _scheduler/jobs/elementjob.py to get the artifact cache directly from the Platform
-rw-r--r--buildstream/_scheduler/jobs/elementjob.py8
-rw-r--r--buildstream/_scheduler/queues/buildqueue.py9
-rw-r--r--buildstream/_scheduler/queues/queue.py5
-rw-r--r--buildstream/element.py10
4 files changed, 16 insertions, 16 deletions
diff --git a/buildstream/_scheduler/jobs/elementjob.py b/buildstream/_scheduler/jobs/elementjob.py
index b3318302a..a010a6684 100644
--- a/buildstream/_scheduler/jobs/elementjob.py
+++ b/buildstream/_scheduler/jobs/elementjob.py
@@ -18,6 +18,7 @@
#
from ruamel import yaml
+from ..._platform import Platform
from ..._message import Message, MessageType
from .job import Job
@@ -72,6 +73,10 @@ class ElementJob(Job):
self._action_cb = action_cb # The action callable function
self._complete_cb = complete_cb # The complete callable function
+ # Hold on to the artifact cache
+ platform = Platform.get_platform()
+ self._artifacts = platform.artifactcache
+
# Set the task wide ID for logging purposes
self.set_task_id(element._get_unique_id())
@@ -109,8 +114,7 @@ class ElementJob(Job):
data = {}
workspace = self._element._get_workspace()
- artifacts = self._element._get_artifact_cache()
- cache_size = artifacts.compute_cache_size()
+ cache_size = self._artifacts.compute_cache_size()
if workspace is not None:
data['workspace'] = workspace.to_dict()
diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py
index 8f593fea7..8902d9adf 100644
--- a/buildstream/_scheduler/queues/buildqueue.py
+++ b/buildstream/_scheduler/queues/buildqueue.py
@@ -24,6 +24,7 @@ from . import Queue, QueueStatus
from ..jobs import ElementJob
from ..resources import ResourceType
from ..._message import MessageType
+from ..._platform import Platform
# A queue which assembles elements
@@ -92,13 +93,15 @@ class BuildQueue(Queue):
# as returned from Element._assemble() to the estimated
# artifact cache size
#
- cache = element._get_artifact_cache()
- cache.add_artifact_size(artifact_size)
+ platform = Platform.get_platform()
+ artifacts = platform.artifactcache
+
+ artifacts.add_artifact_size(artifact_size)
# If the estimated size outgrows the quota, ask the scheduler
# to queue a job to actually check the real cache size.
#
- if cache.get_approximate_cache_size() > cache.cache_quota:
+ if artifacts.get_approximate_cache_size() > artifacts.cache_quota:
self._scheduler.check_cache_size()
def done(self, job, element, result, success):
diff --git a/buildstream/_scheduler/queues/queue.py b/buildstream/_scheduler/queues/queue.py
index 28da17711..37602fb09 100644
--- a/buildstream/_scheduler/queues/queue.py
+++ b/buildstream/_scheduler/queues/queue.py
@@ -31,6 +31,7 @@ from ..resources import ResourceType
# BuildStream toplevel imports
from ..._exceptions import BstError, set_last_task_error
from ..._message import Message, MessageType
+from ..._platform import Platform
# Queue status for a given element
@@ -302,7 +303,9 @@ class Queue():
# before calling any queue implementation
self._update_workspaces(element, job)
if job.child_data:
- element._get_artifact_cache().cache_size = job.child_data.get('cache_size')
+ platform = Platform.get_platform()
+ artifacts = platform.artifactcache
+ artifacts.cache_size = job.child_data.get('cache_size')
# Give the result of the job to the Queue implementor,
# and determine if it should be considered as processed
diff --git a/buildstream/element.py b/buildstream/element.py
index 7ba680aac..6c01c0dd4 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1912,16 +1912,6 @@ class Element(Plugin):
workspaces = self._get_context().get_workspaces()
return workspaces.get_workspace(self._get_full_name())
- # _get_artifact_cache()
- #
- # Accessor for the artifact cache
- #
- # Returns:
- # (ArtifactCache): The artifact cache
- #
- def _get_artifact_cache(self):
- return self.__artifacts
-
# _write_script():
#
# Writes a script to the given directory.