You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2014/10/22 10:53:10 UTC

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

GitHub user neykov opened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/266

    BrooklynNode cluster + upgrade effector

    Also effectors to:
      * select master in the cluster
      * set HA priority
      * set HA state

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/neykov/incubator-brooklyn feature/upgrade-effectors

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/266.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #266
    
----
commit f0d40eac3828bf0c36557d459974edd44371d463
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-10-22T08:51:19Z

    BrooklynNode cluster + upgrade effector
    
    Also effectors to:
      * select master in the cluster
      * set HA priority
      * set HA state

----


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#issuecomment-60059922
  
    Includes changes from Alex's https://github.com/ahgittin/incubator-brooklyn/commit/8d82f41f0a065fffa05ea63baf288d3c1466d9be


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#issuecomment-60462491
  
    superseded by #272 


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#issuecomment-60716216
  
    Closed in favor of #272


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by neykov <gi...@git.apache.org>.
Github user neykov closed the pull request at:

    https://github.com/apache/incubator-brooklyn/pull/266


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#discussion_r19369789
  
    --- Diff: software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynClusterImpl.java ---
    @@ -0,0 +1,110 @@
    +/*
    + * 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;
    +
    +import java.util.Collection;
    +import java.util.concurrent.Callable;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.EntityPredicates;
    +import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
    +import brooklyn.entity.brooklynnode.effector.SelectMasterEffectorBody;
    +import brooklyn.entity.brooklynnode.effector.UpgradeClusterEffectorBody;
    +import brooklyn.entity.group.DynamicClusterImpl;
    +import brooklyn.event.feed.function.FunctionFeed;
    +import brooklyn.event.feed.function.FunctionPollConfig;
    +import brooklyn.management.ha.ManagementNodeState;
    +import brooklyn.util.time.Duration;
    +
    +import com.google.common.collect.FluentIterable;
    +import com.google.common.collect.Iterables;
    +
    +public class BrooklynClusterImpl extends DynamicClusterImpl implements BrooklynCluster {
    +
    +    private static final String MSG_NO_MASTER = "No master node in cluster";
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(BrooklynClusterImpl.class);
    +
    +    //TODO set MEMBER_SPEC
    +
    +    private FunctionFeed scanMaster;
    +
    +    @Override
    +    public void init() {
    +        super.init();
    +        getMutableEntityType().addEffector(SelectMasterEffectorBody.SELECT_MASTER);
    +        getMutableEntityType().addEffector(UpgradeClusterEffectorBody.UPGRADE_CLUSTER);
    +
    +        ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +        scanMaster = FunctionFeed.builder()
    +                .entity(this)
    +                .poll(new FunctionPollConfig<Object, BrooklynNode>(MASTER_NODE)
    +                        .period(Duration.ONE_SECOND)
    +                        .callable(new Callable<BrooklynNode>() {
    +                                @Override
    +                                public BrooklynNode call() throws Exception {
    +                                    return findMasterChild();
    +                                }
    +                            }))
    +                .build();
    +    }
    +
    +    private BrooklynNode findMasterChild() {
    +        Collection<Entity> masters = FluentIterable.from(getMembers())
    +                .filter(EntityPredicates.attributeEqualTo(BrooklynNode.MANAGEMENT_NODE_STATE, ManagementNodeState.MASTER))
    +                .toList();
    +
    +        if (masters.size() == 0) {
    +            ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +            return null;
    +        } else if (masters.size() == 1) {
    +            ServiceNotUpLogic.clearNotUpIndicator(this, MASTER_NODE);
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    +        } else if (masters.size() == 2) {
    +            //Probably hit a window where we have a new master
    +            //its BrooklynNode picked it up, but the BrooklynNode
    +            //for the old master hasn't refreshed its state yet.
    +            //Just pick one of them, should sort itself out in next update.
    +            LOG.warn("Two masters detected, probably a handover just occured: " + masters);
    +
    +            //Don't clearNotUpIndicator - if there were no masters previously
    +            //why have two now.
    +
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    +        } else {
    +            //Set on fire?
    +            String msg = "Multiple (>=3) master nodes in cluster: " + masters;
    +            LOG.error(msg);
    +            throw new IllegalStateException(msg);
    +        }
    +    }
    +
    +    @Override
    +    public void stop() {
    +        super.stop();
    +
    +        if (scanMaster != null && scanMaster.isActivated()) {
    --- End diff --
    
    we now stop all feeds on unmanage, so the whole override of `stop` can be removed


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#issuecomment-60381571
  
    note this now causes compilation errors against master as `HttpClient` now supports `delete`, the test impl here fails.
    
    but i've merged it with my work and fixed the issues (not an entirely trivial process) so rather than update this PR @neykov do you mind if i open a new one combining your work and mine?


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#discussion_r19275393
  
    --- Diff: software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynClusterImpl.java ---
    @@ -0,0 +1,110 @@
    +/*
    + * 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;
    +
    +import java.util.Collection;
    +import java.util.concurrent.Callable;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.EntityPredicates;
    +import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
    +import brooklyn.entity.brooklynnode.effector.SelectMasterEffectorBody;
    +import brooklyn.entity.brooklynnode.effector.UpgradeClusterEffectorBody;
    +import brooklyn.entity.group.DynamicClusterImpl;
    +import brooklyn.event.feed.function.FunctionFeed;
    +import brooklyn.event.feed.function.FunctionPollConfig;
    +import brooklyn.management.ha.ManagementNodeState;
    +import brooklyn.util.time.Duration;
    +
    +import com.google.common.collect.FluentIterable;
    +import com.google.common.collect.Iterables;
    +
    +public class BrooklynClusterImpl extends DynamicClusterImpl implements BrooklynCluster {
    +
    +    private static final String MSG_NO_MASTER = "No master node in cluster";
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(BrooklynClusterImpl.class);
    +
    +    //TODO set MEMBER_SPEC
    +
    +    private FunctionFeed scanMaster;
    +
    +    @Override
    +    public void init() {
    +        super.init();
    +        getMutableEntityType().addEffector(SelectMasterEffectorBody.SELECT_MASTER);
    +        getMutableEntityType().addEffector(UpgradeClusterEffectorBody.UPGRADE_CLUSTER);
    +
    +        ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +        scanMaster = FunctionFeed.builder()
    +                .entity(this)
    +                .poll(new FunctionPollConfig<Object, BrooklynNode>(MASTER_NODE)
    +                        .period(Duration.ONE_SECOND)
    +                        .callable(new Callable<BrooklynNode>() {
    +                                @Override
    +                                public BrooklynNode call() throws Exception {
    +                                    return findMasterChild();
    +                                }
    +                            }))
    +                .build();
    +    }
    +
    +    private BrooklynNode findMasterChild() {
    +        Collection<Entity> masters = FluentIterable.from(getMembers())
    +                .filter(EntityPredicates.attributeEqualTo(BrooklynNode.MANAGEMENT_NODE_STATE, ManagementNodeState.MASTER))
    +                .toList();
    +
    +        if (masters.size() == 0) {
    +            ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +            return null;
    +        } else if (masters.size() == 1) {
    +            ServiceNotUpLogic.clearNotUpIndicator(this, MASTER_NODE);
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    +        } else if (masters.size() == 2) {
    +            //Probably hit a window where we have a new master
    +            //its BrooklynNode picked it up, but the BrooklynNode
    +            //for the old master hasn't refreshed its state yet.
    +            //Just pick one of them, should sort itself out in next update.
    +            LOG.warn("Two masters detected, probably a handover just occured: " + masters);
    +
    +            //Don't clearNotUpIndicator - if there were no masters previously
    +            //why have two now.
    +
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    --- End diff --
    
    The call to `getOnlyElement` will fail because `masters` has size 2.


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#discussion_r19369344
  
    --- Diff: core/src/main/java/brooklyn/entity/basic/EntityPredicates.java ---
    @@ -90,6 +90,15 @@ public boolean apply(@Nullable Entity input) {
             };
         }
         
    +    public static <T> Predicate<Entity> attributeNotEqualTo(final AttributeSensor<T> attribute, final T val) {
    +        return new SerializablePredicate<Entity>() {
    --- End diff --
    
    i've done this for the whole class, in the new PR i'm submitting


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

[GitHub] incubator-brooklyn pull request: BrooklynNode cluster + upgrade ef...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/266#discussion_r19369724
  
    --- Diff: software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynClusterImpl.java ---
    @@ -0,0 +1,110 @@
    +/*
    + * 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;
    +
    +import java.util.Collection;
    +import java.util.concurrent.Callable;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.EntityPredicates;
    +import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
    +import brooklyn.entity.brooklynnode.effector.SelectMasterEffectorBody;
    +import brooklyn.entity.brooklynnode.effector.UpgradeClusterEffectorBody;
    +import brooklyn.entity.group.DynamicClusterImpl;
    +import brooklyn.event.feed.function.FunctionFeed;
    +import brooklyn.event.feed.function.FunctionPollConfig;
    +import brooklyn.management.ha.ManagementNodeState;
    +import brooklyn.util.time.Duration;
    +
    +import com.google.common.collect.FluentIterable;
    +import com.google.common.collect.Iterables;
    +
    +public class BrooklynClusterImpl extends DynamicClusterImpl implements BrooklynCluster {
    +
    +    private static final String MSG_NO_MASTER = "No master node in cluster";
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(BrooklynClusterImpl.class);
    +
    +    //TODO set MEMBER_SPEC
    +
    +    private FunctionFeed scanMaster;
    +
    +    @Override
    +    public void init() {
    +        super.init();
    +        getMutableEntityType().addEffector(SelectMasterEffectorBody.SELECT_MASTER);
    +        getMutableEntityType().addEffector(UpgradeClusterEffectorBody.UPGRADE_CLUSTER);
    +
    +        ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +        scanMaster = FunctionFeed.builder()
    +                .entity(this)
    +                .poll(new FunctionPollConfig<Object, BrooklynNode>(MASTER_NODE)
    +                        .period(Duration.ONE_SECOND)
    +                        .callable(new Callable<BrooklynNode>() {
    +                                @Override
    +                                public BrooklynNode call() throws Exception {
    +                                    return findMasterChild();
    +                                }
    +                            }))
    +                .build();
    +    }
    +
    +    private BrooklynNode findMasterChild() {
    +        Collection<Entity> masters = FluentIterable.from(getMembers())
    +                .filter(EntityPredicates.attributeEqualTo(BrooklynNode.MANAGEMENT_NODE_STATE, ManagementNodeState.MASTER))
    +                .toList();
    +
    +        if (masters.size() == 0) {
    +            ServiceNotUpLogic.updateNotUpIndicator(this, MASTER_NODE, MSG_NO_MASTER);
    +            return null;
    +        } else if (masters.size() == 1) {
    +            ServiceNotUpLogic.clearNotUpIndicator(this, MASTER_NODE);
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    +        } else if (masters.size() == 2) {
    +            //Probably hit a window where we have a new master
    +            //its BrooklynNode picked it up, but the BrooklynNode
    +            //for the old master hasn't refreshed its state yet.
    +            //Just pick one of them, should sort itself out in next update.
    +            LOG.warn("Two masters detected, probably a handover just occured: " + masters);
    +
    +            //Don't clearNotUpIndicator - if there were no masters previously
    +            //why have two now.
    +
    +            return (BrooklynNode)Iterables.getOnlyElement(masters);
    +        } else {
    +            //Set on fire?
    --- End diff --
    
    also note we should use `ServiceProblemsIndicator` rather than `ServiceNotUpIndicator` for situations like this (i'm changing it)


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