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

Added basic migration capability to org.apache.brooklyn.entity.webapp.* #924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adriannieto
Copy link
Contributor

This PR adds an Effector migrate(locationSpec) to Entities that override JavaWebAppSoftwareProcess. This Effector moves the Entity to a new location. Currently it doesn't support nested entities to be migrated.

This is a work in progress feature, my plan is to extend this support to non-clustered databases in the future.

@asfbot
Copy link

asfbot commented Sep 28, 2015

incubator-brooklyn-pull-requests #1868 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Sep 28, 2015

incubator-brooklyn-pull-requests #1867 SUCCESS
This pull request looks good

@asfbot
Copy link

asfbot commented Sep 28, 2015

incubator-brooklyn-pull-requests #1869 SUCCESS
This pull request looks good

@Override
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception {
app.stop();
Copy link
Contributor

Choose a reason for hiding this comment

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

The call to Entities.destroyAll in the superclass method will take care of this for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I will remove it then.

@sjcorbett
Copy link
Contributor

@adriannieto thanks for your contribution.

I've made a few comments on and asked a few questions about the implementation as it is.

It's interesting to see that nothing in the implementation of JavaWebAppSoftwareProcessImpl.migrate is specific to the webapp entity. A cleaner approach would be to create an entity initializer that adds the migrate effector and implementation to an entity dynamically. This way entity writers can choose when and where it is available. In fact you might not even need to write the initialiser - org.apache.brooklyn.core.effector.AddEffector looks like a useful starting point, though you may need to extend it to allow the effector body to be specified.

You can refer to vanilla-bash-netcat-w-client.yaml for an example of how initialisers are used from Yaml.

@adriannieto
Copy link
Contributor Author

@sjcorbett thank you very much for the review, I was reading further about how to initialise the effectors and I will modify everything according to your suggestions.

Example YAML:

name: My Migrable WebApp
location: aws-ireland
services:
- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
  name: AppServer HelloWorld 
  brooklyn.config:
    wars.root: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
  brooklyn.initializers:
  - type: org.apache.brooklyn.entity.webapp.JavaWebAppMigrateEffector

@adriannieto
Copy link
Contributor Author

@sjcorbett Hello, Jenkins is complaining because it can't merge automatically, but this branch builds on my machine. Should I rebase to the master before continuing the review? I wasn't sure that a push force to my branch were a good idea.

@sjcorbett
Copy link
Contributor

Yes please, rebase on master. Force pushing your branch is absolutely fine.

@sjcorbett
Copy link
Contributor

@adriannieto My apologies for leaving this for an entire month. I've had a quick scan of the updated changes and things look good. I have a few more comments to make that I'll leave shortly.

Your branch conflicts with master but it only involves a couple of imports in JavaWebAppSshDriver so will be easy to resolve.

@adriannieto
Copy link
Contributor Author

@sjcorbett thank you, I will rebase it ASAP. Just one question, are the package locations fine? For example I added AllowsMigration definition to base package, do you want any modification on this?

public Object[][] webAppEntities() {
Object[][] dataProviderResult;

Reflections reflections = new Reflections("org.apache.brooklyn.entity.webapp");
Copy link
Contributor

Choose a reason for hiding this comment

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

This and getEntitiesFromClasses is quite cute but it would be much (much!) clearer to just return a reference to the classes explicitly. i.e. new Object[][]{TomcatServer.class}, {Jboss7Server.class}, ...}

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake, should return an array of the specs. But I think you get my point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I was considering this just to be "future-proof" just in case you add a new webapp entity. But as you're moving to YAML based entities maybe this test will not be necessary anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I appreciate the sentiment. In truth things change rarely enough that it is fine to list items.

This effector is pluggable via brooklyn.initializers,

Example YAML:

```
name: My Migrable WebApp
location: aws-ireland
services:
- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
  name: AppServer HelloWorld
  brooklyn.config:
    wars.root: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
  brooklyn.initializers:
  - type: org.apache.brooklyn.entity.webapp.JavaWebAppMigrateEffector
```
// The entity is sensors should rewired automatically on stop() + restart()
} else {
// Restart the entity to fetch again all the dependencies (ie. attributeWhenReady ones)
((Startable) applicationChild).restart();
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to self/other reviewers since GitHub has decoupled conversation from code - see #924 (comment) for discussion on this loop before merging.

@mogul
Copy link

mogul commented May 26, 2016

Migration in Brooklyn has been a great mystery to me, and this PR is the only relevant one I saw mentioned in the mailing list when I went searching. I'm excited to see it as it answers some questions for me, but I'm having trouble following what happened/should have happened with PRs like this as of Brooklyn's graduation from incubation... Did this PR and discussion continue elsewhere, or did it just happen to land at a natural stopping point just prior to the graduation?

@bostko
Copy link
Contributor

bostko commented May 26, 2016

Hi @mogul Glad to hear that you are excited about Apache Brooklyn!
Indeed the project is moved to another repo because the project graduated from Incubator. The github repo is now located at http://github.com/apache/brooklyn . Please check http://brooklyn.apache.org/community/mailing-lists.html for mailing lists information.
@adriannieto can you please open Pull Request with the changes against brooklyn-server and brooklyn-library.

@adriannieto
Copy link
Contributor Author

Yes, no problem but I'm not sure about if I will be able to work on this
topic right now.

However you could use it as an starting point.
El 26 may. 2016 2:28 p. m., "Вальо" [email protected] escribió:

Hi @mogul https://github.com/mogul Glad to hear that you are excited
about Apache Brooklyn!
Indeed the project is moved to another repo because the project graduated
from Incubator. The github repo is now located at
http://github.com/apache/brooklyn https://github.com/apache/brooklyn .
Please check http://brooklyn.apache.org/community/mailing-lists.html for
mailing lists information
@adriannieto https://github.com/adriannieto can you please open Pull
Request with the changes against brooklyn-server
https://github.com/apache/brooklyn-server and brooklyn-library
https://github.com/apache/brooklyn-library.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#924 (comment)

@sjcorbett
Copy link
Contributor

@mogul This PR reached a natural stopping point. I don't think it would take much more work to get it merged. We'd be happy to answer any questions you have on the mailing list.

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

Successfully merging this pull request may close these issues.

5 participants