brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Brooklyn node and cluster upgrade
Date Mon, 27 Oct 2014 17:34:04 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/272#discussion_r19421807
  
    --- Diff: software/base/src/main/java/brooklyn/entity/brooklynnode/effector/BrooklynClusterUpgradeEffectorBody.java
---
    @@ -0,0 +1,211 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package brooklyn.entity.brooklynnode.effector;
    +
    +import java.io.File;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.atomic.AtomicBoolean;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.config.ConfigKey;
    +import brooklyn.entity.Effector;
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.Group;
    +import brooklyn.entity.basic.Attributes;
    +import brooklyn.entity.basic.EntityPredicates;
    +import brooklyn.entity.basic.EntityTasks;
    +import brooklyn.entity.basic.Lifecycle;
    +import brooklyn.entity.brooklynnode.BrooklynCluster;
    +import brooklyn.entity.brooklynnode.BrooklynCluster.SelectMasterEffector;
    +import brooklyn.entity.brooklynnode.BrooklynCluster.UpgradeClusterEffector;
    +import brooklyn.entity.brooklynnode.BrooklynNode;
    +import brooklyn.entity.brooklynnode.BrooklynNode.SetHighAvailabilityModeEffector;
    +import brooklyn.entity.effector.EffectorBody;
    +import brooklyn.entity.effector.Effectors;
    +import brooklyn.entity.group.DynamicCluster;
    +import brooklyn.entity.proxying.EntitySpec;
    +import brooklyn.management.TaskAdaptable;
    +import brooklyn.management.ha.HighAvailabilityMode;
    +import brooklyn.management.ha.ManagementNodeState;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.config.ConfigBag;
    +import brooklyn.util.exceptions.Exceptions;
    +import brooklyn.util.net.Urls;
    +import brooklyn.util.task.DynamicTasks;
    +import brooklyn.util.task.Tasks;
    +import brooklyn.util.time.Duration;
    +
    +import com.google.api.client.util.Preconditions;
    +import com.google.common.base.Predicates;
    +import com.google.common.collect.Collections2;
    +import com.google.common.collect.Iterables;
    +
    +public class BrooklynClusterUpgradeEffectorBody extends EffectorBody<Void> implements
UpgradeClusterEffector {
    +    
    +    private static final Logger log = LoggerFactory.getLogger(BrooklynClusterUpgradeEffectorBody.class);
    +    
    +    public static final Effector<Void> UPGRADE_CLUSTER = Effectors.effector(UpgradeClusterEffector.UPGRADE_CLUSTER)
    +        .impl(new BrooklynClusterUpgradeEffectorBody()).build();
    +
    +    private AtomicBoolean upgradeInProgress = new AtomicBoolean();
    +
    +    @Override
    +    public Void call(ConfigBag parameters) {
    +        if (!upgradeInProgress.compareAndSet(false, true)) {
    +            throw new IllegalStateException("An upgrade is already in progress.");
    +        }
    +
    +        EntitySpec<?> memberSpec = entity().getConfig(BrooklynCluster.MEMBER_SPEC);
    --- End diff --
    
    We should put this in the try-block as well, to guarantee that we unset `upgradeInProgress`,
even if there `checkNotNull` below fails.


---
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