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

Add helper method to create nesting relationship between workflows #41

Merged
merged 5 commits into from
Aug 10, 2018

Conversation

haouech
Copy link

@haouech haouech commented Jul 28, 2018

No description provided.

Copy link
Member

@stain stain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some comments below - testing should be improved a bit.

@@ -752,6 +753,30 @@ public Activity createActivityFromProcessor(Processor processor,
return activity;
}

public Configuration createNestedRelationship(Processor processor, Workflow childWorkflow, Profile profile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about relationship here.. Should we call this method setAsNestedWorkflow() or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the name isn't very good. I changed it.

tools.createNestedRelationship(processor, child, profile);
Workflow nested = tools.nestedWorkflowForProcessor(processor, profile);

assertEquals(child, nested);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this test also verify that the corresponding Activity and Configuration have been added with the correct workflow name and i/o ports?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add a patch where I check that the activity and configuration has been added to the workflow. But I'm not sure if it's what you asked for. Correct me please if you have something else in mind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, safely you should pick the correct activity based on the ProcessorBinding rather than picking blindly the first one with NESTED_WORKFLOW in it - although that will be the case for this particular test case profile as there should be no other activites.

So perhaps improve it to look up the ProcessorBinding for the processor and from there find the activity and its configuration? Sorry it's a bit cumbersome..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't happy with that way either. I used the ProcessorBinding as you suggested and it's much better. Thank you for your comments !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

throw new IllegalStateException(
"Processor " + processor + " and workflow " + childWorkflow + " are not in the same Workflow bundle");
}
if(nestedWorkflowForProcessor(processor, profile) != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are good guards, but they should also be verified by separate @Tests.

nestedWorkflowForProcessor() will detect if it's already a nested workflow, but not if there's another activity on the processor. Although SCUFL2 allows multiple activities on the same processor (e.g. for Failover) this has in practice not been used, so perhaps this test can check instead for any existing activity on the processor, regardless of activity type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. I took advantage of the already thrown exceptions by the 'getActivity' method of Processor. Now we make sure that the processor has no activity bound to it before nesting the workflows.

@haouech
Copy link
Author

haouech commented Aug 6, 2018

Thank you so much for you comments! I replied to them and added a patch.

@@ -764,6 +764,12 @@ public Configuration createNestedRelationship(Processor processor, Workflow chil
if(nestedWorkflowForProcessor(processor, profile) != null) {
throw new IllegalStateException("Processor " + processor + " already has a nested workflow");
}
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, I see what you mean.. it's not good to have logic by exception catching, is it..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a better way to test if a processor already has a bound activity. You were right about the exception catching logic. Thanks

- Check if nesting processor doesn't already have a bound activity
@@ -51,6 +51,7 @@
import org.apache.taverna.scufl2.api.profiles.Profile;
import org.junit.Before;
import org.junit.Test;
import sun.security.krb5.Config;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need sun.security.krb5.Config (or that it's even legal to import)

boolean found = false;
ProcessorBinding binding = processor.getBinding(profile);
Activity activity = binding.getBoundActivity();
Configuration configuration = activity.getConfiguration();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for inconsistent indentation this looks much better!

@asfgit asfgit merged commit 0ca7ac2 into apache:master Aug 10, 2018
asfgit pushed a commit that referenced this pull request Aug 10, 2018
Contributed by Majdi Haouech (ICLA on file)
@haouech

See #41

Signed-off-by: Stian Soiland-Reyes <stain@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants