Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/924#discussion_r42055614
--- Diff:
software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java
---
@@ -202,4 +208,75 @@ public String getHttpsSslKeystorePassword() {
return (config == null) ? "" : config.getKeystorePassword();
}
+ @Override
+ public void migrate(@EffectorParam(name = "locationSpec", description
= "Location Spec", nullable = false) String locationSpec) {
+
+ if (ServiceStateLogic.getExpectedState(this) != Lifecycle.RUNNING)
{
+ // Is it necessary to check if the whole application is
healthy?
+ throw new RuntimeException("The entity needs to be healthy
before the migration starts");
+ }
+
+ if (getParent() != null && !getParent().equals(getApplication())) {
+ /*
+ * TODO: Allow nested entites to be migrated
+ * If the entity has a parent different to the application
root the migration cannot be done right now,
+ * as it could lead into problems to deal with hierarchies
like SameServerEntity -> Entity
+ */
+
+ throw new RuntimeException("Nested entities cannot be migrated
right now");
+ }
+
+ // Retrieving the location from the catalog.
+ Location newLocation =
getManagementContext().getLocationRegistry().resolve(locationSpec);
+
+ // TODO: Find a better way to check if you're migrating an entity
to the exactly same VM. This not always works.
+ for(Location oldLocation : getLocations()){
+ if(oldLocation.containsLocation(newLocation))
+ throw new RuntimeException("You cannot migrate an entity
to the same location");
--- End diff --
Simpler than throwing an exception would be to log and return immediately.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---