brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorbett <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Added basic migration capability ...
Date Wed, 14 Oct 2015 21:20:54 GMT
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/924#discussion_r42054990
  
    --- 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");
    +        }
    +
    +        /*
    +         *   BUG: Currently the status is not propagated to the parent it should retrieve
it from the children,
    +         *   but it seems that the descendant children status is not propagated properly
    +         */
    +        LOG.info("Migration process of " + this.getId() + " started.");
    +
    +        // When we have the new location, we free the resources of the current instance
    +        stop();
    +
    +        // Clearing old locations to remove the relationship with the previous instance
    +        clearLocations();
    +        addLocations(Lists.newArrayList(newLocation));
    +
    +        // Starting the new instance
    +        start(getLocations());
    +
    +        // Refresh all the dependant entities
    +        refreshDependantEntities();
    +
    +        LOG.info("Migration process of " + this.getId() + " finished.");
    +
    +    }
    +
    +    /*
    +     * TODO: Find a better way to refresh the application configuration.
    +     */
    +    private void refreshDependantEntities() {
    --- End diff --
    
    `Dependent`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message