You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by mx...@apache.org on 2017/11/28 15:31:29 UTC

[1/3] incubator-ariatosca git commit: changed the update mechanism in all events to be more generic

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/generic_storage_update_serialization_logger_handler [created] 9dcb4af5a


changed the update mechanism in all events to be more generic


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/b12bfd21
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/b12bfd21
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/b12bfd21

Branch: refs/heads/generic_storage_update_serialization_logger_handler
Commit: b12bfd211aa242cc009b0d7b5b33e52fc1fa1896
Parents: e71ddc9
Author: max-orlov <ma...@gigaspaces.com>
Authored: Tue Nov 28 17:19:48 2017 +0200
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Tue Nov 28 17:19:48 2017 +0200

----------------------------------------------------------------------
 .../workflows/core/events_handler.py            | 64 +++++++++++---------
 aria/orchestrator/workflows/executor/base.py    |  5 +-
 2 files changed, 40 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b12bfd21/aria/orchestrator/workflows/core/events_handler.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/events_handler.py b/aria/orchestrator/workflows/core/events_handler.py
index 473475e..6da59ba 100644
--- a/aria/orchestrator/workflows/core/events_handler.py
+++ b/aria/orchestrator/workflows/core/events_handler.py
@@ -28,16 +28,20 @@ from ... import exceptions
 
 @events.sent_task_signal.connect
 def _task_sent(ctx, *args, **kwargs):
-    with ctx.persist_changes:
-        ctx.task.status = ctx.task.SENT
+    # with ctx.persist_changes:
+    task = ctx.task
+    task.status = ctx.task.SENT
+    ctx.model.task.update(task)
 
 
 @events.start_task_signal.connect
 def _task_started(ctx, *args, **kwargs):
-    with ctx.persist_changes:
-        ctx.task.started_at = datetime.utcnow()
-        ctx.task.status = ctx.task.STARTED
-        _update_node_state_if_necessary(ctx, is_transitional=True)
+    # with ctx.persist_changes:
+    task = ctx.task
+    ctx.task.started_at = datetime.utcnow()
+    ctx.task.status = ctx.task.STARTED
+    _update_node_state_if_necessary(ctx, is_transitional=True)
+    ctx.model.task.update(task)
 
 
 @events.on_failure_task_signal.connect
@@ -68,40 +72,46 @@ def _task_failed(ctx, exception, *args, **kwargs):
 
 @events.on_success_task_signal.connect
 def _task_succeeded(ctx, *args, **kwargs):
-    with ctx.persist_changes:
-        ctx.task.ended_at = datetime.utcnow()
-        ctx.task.status = ctx.task.SUCCESS
-        ctx.task.attempts_count += 1
+    # with ctx.persist_changes:
 
-        _update_node_state_if_necessary(ctx)
+    task = ctx.task
+    ctx.task.ended_at = datetime.utcnow()
+    ctx.task.status = ctx.task.SUCCESS
+    ctx.task.attempts_count += 1
+
+    _update_node_state_if_necessary(ctx)
+    ctx.model.task.update(task)
 
 
 @events.start_workflow_signal.connect
 def _workflow_started(workflow_context, *args, **kwargs):
-    with workflow_context.persist_changes:
-        execution = workflow_context.execution
-        # the execution may already be in the process of cancelling
-        if execution.status in (execution.CANCELLING, execution.CANCELLED):
-            return
-        execution.status = execution.STARTED
-        execution.started_at = datetime.utcnow()
+    # with workflow_context.persist_changes:
+    execution = workflow_context.execution
+    # the execution may already be in the process of cancelling
+    if execution.status in (execution.CANCELLING, execution.CANCELLED):
+        return
+    execution.status = execution.STARTED
+    execution.started_at = datetime.utcnow()
+    workflow_context.model.execution.update(execution)
 
 
 @events.on_failure_workflow_signal.connect
 def _workflow_failed(workflow_context, exception, *args, **kwargs):
-    with workflow_context.persist_changes:
-        execution = workflow_context.execution
-        execution.error = str(exception)
-        execution.status = execution.FAILED
-        execution.ended_at = datetime.utcnow()
+    # with workflow_context.persist_changes:
+    execution = workflow_context.execution
+    execution.error = str(exception)
+    execution.status = execution.FAILED
+    execution.ended_at = datetime.utcnow()
+    workflow_context.model.execution.update(execution)
 
 
 @events.on_success_workflow_signal.connect
 def _workflow_succeeded(workflow_context, *args, **kwargs):
-    with workflow_context.persist_changes:
-        execution = workflow_context.execution
-        execution.status = execution.SUCCEEDED
-        execution.ended_at = datetime.utcnow()
+    # with workflow_context.persist_changes:
+    execution = workflow_context.execution
+    execution.status = execution.SUCCEEDED
+    execution.ended_at = datetime.utcnow()
+    workflow_context.model.execution.update(execution)
 
 
 @events.on_cancelled_workflow_signal.connect

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b12bfd21/aria/orchestrator/workflows/executor/base.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/base.py b/aria/orchestrator/workflows/executor/base.py
index e7d03ea..d550b53 100644
--- a/aria/orchestrator/workflows/executor/base.py
+++ b/aria/orchestrator/workflows/executor/base.py
@@ -71,5 +71,6 @@ class BaseExecutor(logger.LoggerMixin):
 
 class StubTaskExecutor(BaseExecutor):                                                               # pylint: disable=abstract-method
     def execute(self, ctx, *args, **kwargs):
-        with ctx.persist_changes:
-            ctx.task.status = ctx.task.SUCCESS
+        task = ctx.task
+        task.status = ctx.task.SUCCESS
+        ctx.model.task.update(task)


[2/3] incubator-ariatosca git commit: handler configuration is more explicit

Posted by mx...@apache.org.
handler configuration is more explicit


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/4196a87e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/4196a87e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/4196a87e

Branch: refs/heads/generic_storage_update_serialization_logger_handler
Commit: 4196a87e1b74c95aff52f98ac91519ce53f8715f
Parents: b12bfd2
Author: max-orlov <ma...@gigaspaces.com>
Authored: Tue Nov 28 17:20:12 2017 +0200
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Tue Nov 28 17:20:12 2017 +0200

----------------------------------------------------------------------
 aria/orchestrator/context/common.py | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4196a87e/aria/orchestrator/context/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py
index 3c5f618..87444a9 100644
--- a/aria/orchestrator/context/common.py
+++ b/aria/orchestrator/context/common.py
@@ -115,14 +115,19 @@ class BaseContext(object):
 
     @contextmanager
     def logging_handlers(self, handlers=None):
+        original_handlers = self.logger.handlers
         handlers = handlers or []
         try:
             for handler in handlers:
                 self.logger.addHandler(handler)
+            for handler in original_handlers:
+                self.logger.removeHandler(handler)
             yield self.logger
         finally:
             for handler in handlers:
                 self.logger.removeHandler(handler)
+            for handler in original_handlers:
+                self.logger.addHandler(handler)
 
     @property
     def model(self):


[3/3] incubator-ariatosca git commit: a more generic support to json encoding

Posted by mx...@apache.org.
a more generic support to json encoding


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9dcb4af5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9dcb4af5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9dcb4af5

Branch: refs/heads/generic_storage_update_serialization_logger_handler
Commit: 9dcb4af5a214c3ce935cb5a7d4d1e661617152ca
Parents: 4196a87
Author: max-orlov <ma...@gigaspaces.com>
Authored: Tue Nov 28 17:24:31 2017 +0200
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Tue Nov 28 17:30:02 2017 +0200

----------------------------------------------------------------------
 aria/modeling/utils.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9dcb4af5/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 6e851f2..72fd51f 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -36,14 +36,13 @@ class ModelJSONEncoder(JSONEncoder):
         super(ModelJSONEncoder, self).__init__(*args, **kwargs)
 
     def default(self, o):  # pylint: disable=method-hidden
-        from .mixins import ModelMixin
-        if isinstance(o, ModelMixin):
+        try:
             if hasattr(o, 'value'):
                 dict_to_return = o.to_dict(fields=('value',))
                 return dict_to_return['value']
             else:
                 return o.to_dict()
-        else:
+        except:
             return JSONEncoder.default(self, o)