You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by ahgittin <gi...@git.apache.org> on 2016/08/25 15:43:35 UTC

[GitHub] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

GitHub user ahgittin opened a pull request:

    https://github.com/apache/brooklyn-server/pull/308

    Invoke on sensor and ssh to multiple

    These fixes make https://github.com/brooklyncentral/brooklyn-dns work neatly.

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

    $ git pull https://github.com/ahgittin/brooklyn-server invoke-on-sensor-and-ssh-to-multiple

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

    https://github.com/apache/brooklyn-server/pull/308.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 #308
    
----
commit 8ff627cbbfb104c4dc60341a95e256909439dd57
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Date:   2016-08-25T15:07:57Z

    subscriptions should base on sensor name, not the object

commit 2ab4e5c10a6df18353cee5e3c4b51a6ddec76c0f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Date:   2016-08-25T15:16:23Z

    add InvokeEffectorOnSensorChange and let SSH run over members
    
    helps w DNS, likely many others

----


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76400099
  
    --- Diff: core/src/main/java/org/apache/brooklyn/policy/InvokeEffectorOnSensorChange.java ---
    @@ -0,0 +1,71 @@
    +/*
    + * 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 org.apache.brooklyn.policy;
    +
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.sensor.SensorEvent;
    +import org.apache.brooklyn.api.sensor.SensorEventListener;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.policy.AbstractPolicy;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Invokes the given effector when the policy changes.
    + * 
    + * TODO
    + * * support parameters
    + * * support conditions
    + * * allow to be triggered by sensors on members
    + */
    +public class InvokeEffectorOnSensorChange extends AbstractPolicy implements SensorEventListener<Object> {
    +    
    +    private static final Logger LOG = LoggerFactory.getLogger(InvokeEffectorOnSensorChange.class);
    +
    +    public static final ConfigKey<Object> SENSOR = ConfigKeys.newConfigKey(Object.class, 
    --- End diff --
    
    happy for that to be added, along with a debounce, but then we'll also want a way to pass the sensor and originator as parameters to the effector ... so i've started simple
    
    feel free to add when needed
    
    i like having both `sensor` and `sensorsToTrack` and they are additive



---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76400107
  
    --- Diff: core/src/main/java/org/apache/brooklyn/policy/InvokeEffectorOnSensorChange.java ---
    @@ -0,0 +1,71 @@
    +/*
    + * 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 org.apache.brooklyn.policy;
    +
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.sensor.SensorEvent;
    +import org.apache.brooklyn.api.sensor.SensorEventListener;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.policy.AbstractPolicy;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Invokes the given effector when the policy changes.
    + * 
    + * TODO
    + * * support parameters
    + * * support conditions
    + * * allow to be triggered by sensors on members
    + */
    +public class InvokeEffectorOnSensorChange extends AbstractPolicy implements SensorEventListener<Object> {
    --- End diff --
    
    yeah...


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76399497
  
    --- Diff: core/src/main/java/org/apache/brooklyn/policy/InvokeEffectorOnSensorChange.java ---
    @@ -0,0 +1,71 @@
    +/*
    + * 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 org.apache.brooklyn.policy;
    +
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.sensor.SensorEvent;
    +import org.apache.brooklyn.api.sensor.SensorEventListener;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.policy.AbstractPolicy;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Invokes the given effector when the policy changes.
    + * 
    + * TODO
    + * * support parameters
    + * * support conditions
    + * * allow to be triggered by sensors on members
    + */
    +public class InvokeEffectorOnSensorChange extends AbstractPolicy implements SensorEventListener<Object> {
    --- End diff --
    
    Needs tests


---
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] brooklyn-server issue #308: Invoke on sensor and ssh to multiple

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on the issue:

    https://github.com/apache/brooklyn-server/pull/308
  
    LGTM, but see comments


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76399739
  
    --- Diff: core/src/main/java/org/apache/brooklyn/entity/group/SshCommandMembershipTrackingPolicy.java ---
    @@ -61,11 +64,16 @@
      * executed. This can be one of: the {@link ExecutionTarget#ENTITY owing entity};
      * the {@link ExecutionTarget#MEMBER member} that was updated; or
      * {@link ExecutionTarget#ALL_MEMBERS all members} of the group.
    + * 
    + * @deprecated introduced and removed in 0.10.0-snapshot; use a combination of 
    + * InvokeEffectorOnSensorChange and SshCommandEffector instead
    + * (much simpler semantics as you normally will want to listen to a local sensor
    + * (which in turn is aggregated over members) instead of children sensors directly).
    + * If there is a need for {@link #EVENT_TYPE} or {@link #MEMBER_ID} then we'll want
    + * InvokeEffectorOnSensorChange to be able to subscribe to members/children etc as well,
    + * and pass parameters based on source.entityId and source.sensor.
      */
    -// TODO might make sense to split up behaviour into two classes,
    -// an InvokeEffectorMembershipTrackingPolicy and an SshMultiEntityCommandEffector -- 
    -// where the latter has the configurable target introduced here
    -@Beta
    +@Deprecated
    --- End diff --
    
    Actually, this could be safely removed, since the only usage of it has been updated to use the new policy defined here.


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76399460
  
    --- Diff: core/src/main/java/org/apache/brooklyn/policy/InvokeEffectorOnSensorChange.java ---
    @@ -0,0 +1,71 @@
    +/*
    + * 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 org.apache.brooklyn.policy;
    +
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.sensor.SensorEvent;
    +import org.apache.brooklyn.api.sensor.SensorEventListener;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.policy.AbstractPolicy;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Invokes the given effector when the policy changes.
    + * 
    + * TODO
    + * * support parameters
    + * * support conditions
    + * * allow to be triggered by sensors on members
    + */
    +public class InvokeEffectorOnSensorChange extends AbstractPolicy implements SensorEventListener<Object> {
    +    
    +    private static final Logger LOG = LoggerFactory.getLogger(InvokeEffectorOnSensorChange.class);
    +
    +    public static final ConfigKey<Object> SENSOR = ConfigKeys.newConfigKey(Object.class, 
    --- End diff --
    
    Would have preferred `sensorsToTrack` that takes a list of sensors


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76399634
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffector.java ---
    @@ -18,36 +18,57 @@
      */
     package org.apache.brooklyn.core.effector.ssh;
     
    +import java.util.Collection;
     import java.util.Map;
     import java.util.concurrent.ExecutionException;
     
    -import com.google.common.base.Preconditions;
    -import com.google.common.base.Predicates;
    -import com.google.common.collect.Maps;
    -
     import org.apache.brooklyn.api.effector.Effector;
     import org.apache.brooklyn.api.effector.ParameterType;
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.entity.Group;
     import org.apache.brooklyn.config.ConfigKey;
     import org.apache.brooklyn.core.config.ConfigKeys;
     import org.apache.brooklyn.core.config.MapConfigKey;
     import org.apache.brooklyn.core.effector.AddEffector;
     import org.apache.brooklyn.core.effector.EffectorBody;
     import org.apache.brooklyn.core.effector.Effectors;
     import org.apache.brooklyn.core.effector.Effectors.EffectorBuilder;
    +import org.apache.brooklyn.core.effector.ssh.SshEffectorTasks.SshEffectorTaskFactory;
    +import org.apache.brooklyn.core.entity.Attributes;
     import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
    +import org.apache.brooklyn.core.entity.Entities;
    +import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
    +import org.apache.brooklyn.core.location.Locations;
     import org.apache.brooklyn.core.sensor.ssh.SshCommandSensor;
    +import org.apache.brooklyn.location.ssh.SshMachineLocation;
     import org.apache.brooklyn.util.collections.MutableMap;
     import org.apache.brooklyn.util.core.config.ConfigBag;
     import org.apache.brooklyn.util.core.json.ShellEnvironmentSerializer;
    +import org.apache.brooklyn.util.core.task.TaskBuilder;
     import org.apache.brooklyn.util.core.task.Tasks;
     import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.apache.brooklyn.util.guava.Maybe;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.base.Predicates;
    +import com.google.common.collect.Maps;
     
     public final class SshCommandEffector extends AddEffector {
     
         public static final ConfigKey<String> EFFECTOR_COMMAND = ConfigKeys.newStringConfigKey("command");
         public static final ConfigKey<String> EFFECTOR_EXECUTION_DIR = SshCommandSensor.SENSOR_EXECUTION_DIR;
         public static final MapConfigKey<Object> EFFECTOR_SHELL_ENVIRONMENT = BrooklynConfigKeys.SHELL_ENVIRONMENT;
     
    +    public static enum ExecutionTarget {
    +        ENTITY,
    +        MEMBERS,
    +        CHILDREN
    +    }
    +    public static final ConfigKey<ExecutionTarget> EXECUTION_TARGET = ConfigKeys.newConfigKey(ExecutionTarget.class, "executionTarget", 
    --- End diff --
    
    Needs tests for these arguments, but admittedly the `SshCMTP` didn't have explicit tests for these either


---
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] brooklyn-server pull request #308: Invoke on sensor and ssh to multiple

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

    https://github.com/apache/brooklyn-server/pull/308#discussion_r76399422
  
    --- Diff: core/src/main/java/org/apache/brooklyn/policy/InvokeEffectorOnSensorChange.java ---
    @@ -0,0 +1,71 @@
    +/*
    + * 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 org.apache.brooklyn.policy;
    +
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.sensor.SensorEvent;
    +import org.apache.brooklyn.api.sensor.SensorEventListener;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.policy.AbstractPolicy;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Invokes the given effector when the policy changes.
    + * 
    + * TODO
    + * * support parameters
    --- End diff --
    
    I suggest when removing the now deprecated `SshCommandMembershipTrackingPolicy` we use a similar technique, and add the entity that changed and the sensor data that caused the change as arguments.


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