You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2017/05/22 19:34:42 UTC
incubator-ariatosca git commit: fix1 [Forced Update!]
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-185-NullPool-logging-messages-appear-during-execution 1f093d06f -> 95cc3d100 (forced update)
fix1
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/95cc3d10
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/95cc3d10
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/95cc3d10
Branch: refs/heads/ARIA-185-NullPool-logging-messages-appear-during-execution
Commit: 95cc3d1002889e2b83a19fc6b620bdf9d77245b0
Parents: 57555fe
Author: max-orlov <ma...@gigaspaces.com>
Authored: Mon May 22 19:07:37 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Mon May 22 22:34:36 2017 +0300
----------------------------------------------------------------------
aria/orchestrator/context/common.py | 4 ----
aria/orchestrator/context/operation.py | 17 ++++++++++++++---
.../execution_plugin/ctx_proxy/server.py | 2 +-
aria/orchestrator/workflows/executor/process.py | 3 +--
.../execution_plugin/test_ctx_proxy_server.py | 3 ++-
tests/orchestrator/workflows/executor/__init__.py | 6 +++++-
6 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/aria/orchestrator/context/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py
index 3918408..c98e026 100644
--- a/aria/orchestrator/context/common.py
+++ b/aria/orchestrator/context/common.py
@@ -194,7 +194,3 @@ class BaseContext(object):
variables.setdefault('ctx', self)
resource_template = jinja2.Template(resource_content)
return resource_template.render(variables)
-
- def _teardown_db_resources(self):
- self.model.log._session.remove()
- self.model.log._engine.dispose()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/aria/orchestrator/context/operation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/operation.py b/aria/orchestrator/context/operation.py
index 68a02aa..e0eb927 100644
--- a/aria/orchestrator/context/operation.py
+++ b/aria/orchestrator/context/operation.py
@@ -29,10 +29,11 @@ class BaseOperationContext(BaseContext):
Context object used during operation creation and execution
"""
- def __init__(self, task_id, actor_id, **kwargs):
+ def __init__(self, task_id, actor_id, instantiated_from_dict=False, **kwargs):
self._task_id = task_id
self._actor_id = actor_id
self._thread_local = threading.local()
+ self._instantiated_from_dict = instantiated_from_dict
logger_level = kwargs.pop('logger_level', None)
super(BaseOperationContext, self).__init__(**kwargs)
self._register_logger(task_id=self.task.id, level=logger_level)
@@ -90,14 +91,24 @@ class BaseOperationContext(BaseContext):
}
@classmethod
- def deserialize_from_dict(cls, model_storage=None, resource_storage=None, **kwargs):
+ def instantiate_from_dict(cls, model_storage=None, resource_storage=None, **kwargs):
if model_storage:
model_storage = aria.application_model_storage(**model_storage)
if resource_storage:
resource_storage = aria.application_resource_storage(**resource_storage)
- return cls(model_storage=model_storage, resource_storage=resource_storage, **kwargs)
+ return cls(model_storage=model_storage,
+ resource_storage=resource_storage,
+ instantiated_from_dict=True,
+ **kwargs)
+ def __del__(self):
+ self.close()
+
+ def close(self):
+ if self._instantiated_from_dict:
+ self.model.log._session.remove()
+ self.model.log._engine.dispose()
class NodeOperationContext(BaseOperationContext):
"""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/aria/orchestrator/execution_plugin/ctx_proxy/server.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/ctx_proxy/server.py b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
index ef25491..e3496b9 100644
--- a/aria/orchestrator/execution_plugin/ctx_proxy/server.py
+++ b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
@@ -128,7 +128,7 @@ class CtxProxy(object):
finally:
# Since this runs in a daemon thread, we need to close the session each time we process
# a request (a new session would be supplied by SQLAlchemy scoped_session).
- # log mapi is chosen randomly.
+ # log mapi is chosen arbitrarily.
self.ctx.model.log._session.remove()
return result
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index 1060aed..da6bbb2 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -373,7 +373,7 @@ def _main():
# See docstring of `remove_mutable_association_listener` for further details
modeling_types.remove_mutable_association_listener()
try:
- ctx = context_dict['context_cls'].deserialize_from_dict(**context_dict['context'])
+ ctx = context_dict['context_cls'].instantiate_from_dict(**context_dict['context'])
except BaseException as e:
messenger.failed(exception=e, tracked_changes=None, new_instances=None)
return
@@ -395,7 +395,6 @@ def _main():
new_instances=instrument.new_instances)
finally:
instrument.expunge_session()
- ctx._teardown_db_resources()
if __name__ == '__main__':
_main()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/tests/orchestrator/execution_plugin/test_ctx_proxy_server.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_ctx_proxy_server.py b/tests/orchestrator/execution_plugin/test_ctx_proxy_server.py
index 98ceff9..a41f9f0 100644
--- a/tests/orchestrator/execution_plugin/test_ctx_proxy_server.py
+++ b/tests/orchestrator/execution_plugin/test_ctx_proxy_server.py
@@ -136,7 +136,7 @@ class TestCtxProxy(object):
kwargs=kwargs)
@pytest.fixture
- def ctx(self):
+ def ctx(self, mocker):
class MockCtx(object):
pass
ctx = MockCtx()
@@ -160,6 +160,7 @@ class TestCtxProxy(object):
ctx.stub_args = self.stub_args
ctx.stub_attr = self.StubAttribute()
ctx.node = self.NodeAttribute(properties)
+ ctx.model = mocker.MagicMock()
return ctx
@pytest.fixture
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/95cc3d10/tests/orchestrator/workflows/executor/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/__init__.py b/tests/orchestrator/workflows/executor/__init__.py
index 8ad8edb..41c4b2e 100644
--- a/tests/orchestrator/workflows/executor/__init__.py
+++ b/tests/orchestrator/workflows/executor/__init__.py
@@ -69,8 +69,12 @@ class MockContext(object):
return None
@classmethod
- def deserialize_from_dict(cls, **kwargs):
+ def instantiate_from_dict(cls, **kwargs):
if kwargs:
return cls(storage=aria.application_model_storage(**kwargs))
else:
return cls()
+
+ @staticmethod
+ def close():
+ pass