Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityProxy.invoke should check that the task context matches target entity #1370

Open
sjcorbett opened this issue May 7, 2014 · 1 comment

Comments

@sjcorbett
Copy link
Member

.. and should log a warning or throw an error if it does not.

This came from this scenario:

  • A Group entity invokes a method x on its SoftwareProcess members
  • Method x calls restart on the entity
  • The restart calls SoftwareProcessDriverLifecycleEffectorTasks.restart(), which gets the SoftwareProcessImpl entity by calling: (SoftwareProcessImpl) (EntityInternal) BrooklynTaskTags.getTargetOrContextEntity(Tasks.current())
  • This throws a ClassCastException because the current task context is the Group, not the SoftwareProcess.

Which is a confusing error.

Issue prompted by this conversation on IRC:

[12:19:21]  <samc_>  alexheneveld: a question on task queuing contexts for you. I have a Group that invokes a method X on its members. X restarts the member. the restart eventually defers to SoftwareProcessDriverLifecycleEffectorTasks.restart(), which calls entity(), which is defined as:
[12:19:21]  <samc_>  (EntityInternal) BrooklynTaskTags.getTargetOrContextEntity(Tasks.current())
[12:19:36]  <samc_>  but in this case the current task is the Group, not the entity
[12:20:32]  <samc_>  should the method X set the task queueing context before running the restart?
[12:21:01]  <samc_>  at the moment it throws a ClassCastException: Group cannot be cast to SoftwareProcessImpl
[12:21:57]  <alexheneveld>   samc_ - direct cross-entity method calls are dangerous as they will break if the entity is remoted
[12:22:17]  <samc_>  so I should invoke an effector instead?
[12:22:19]  <alexheneveld>   consider them supported only for effectors
[12:22:43]  <alexheneveld>   if you make X an effector then the Proxy behaviour should automatically set up a task when you invoke method X
[12:25:26]  <alexheneveld>   we should have a check in EntityProxy.invoke that checks if there is a Tasks.current() with an entity context set, that that entity context matches the target entity and logs warning (or throws) if not, citing the reason above.
@sjcorbett
Copy link
Member Author

@aledsage Do you agree with the comments above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant