You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@edgent.apache.org by dlaboss <gi...@git.apache.org> on 2016/04/14 02:08:56 UTC

[GitHub] incubator-quarks-website pull request: [QUARKS-123] [WIP] adaptabl...

GitHub user dlaboss opened a pull request:

    https://github.com/apache/incubator-quarks-website/pull/40

    [QUARKS-123] [WIP] adaptable polling source recipe

    Open for feedback.
    Can't merge this PR until quarks supports the functionality here: https://github.com/apache/incubator-quarks/pull/86

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

    $ git pull https://github.com/dlaboss/incubator-quarks-website quarks-123-adaptable-poll-recipe

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

    https://github.com/apache/incubator-quarks-website/pull/40.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 #40
    
----
commit 71835ced9a5dc1c4b16826d3af679382bd8cc0ff
Author: Dale LaBossiere <dl...@us.ibm.com>
Date:   2016-04-14T00:00:23Z

    [QUARKS-123] [WIP] adaptable polling source recipe

commit cd755165e8f681892317b95a7c8d7be4d3226494
Author: Dale LaBossiere <dl...@us.ibm.com>
Date:   2016-04-14T00:07:17Z

    tweak recipe title

----


---
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-quarks-website pull request: [QUARKS-123] adaptable poll...

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

    https://github.com/apache/incubator-quarks-website/pull/40


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612095
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    +
    +A Quarks IotProvider and IoTDevice with its command streams would be a natural way to control the application.  In this recipe we will just simulate a "set poll period" command stream.
    --- End diff --
    
    Consider putting `IotProvider` and `IotDevice` in inline code blocks 


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60632624
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    --- End diff --
    
    done


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612063
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    --- End diff --
    
    Please use sentence style capitalization: "Changing a polled source stream's period"


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60634022
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    +
    +A Quarks IotProvider and IoTDevice with its command streams would be a natural way to control the application.  In this recipe we will just simulate a "set poll period" command stream.
    +
    +The ``Topology.poll()`` documentation describes how the poll period may be changed at runtime.
    +
    +The mechanism is based on a more general Quarks runtime ``quarks.execution.services.ControlService`` service.  The runtime registers "control beans" for entities that are controllable.  These controls can be retrieved at runtime via the service.
    +
    +At runtime, ``Topology.poll()`` registers a ``quarks.execution.mbeans.PeriodicMXBean`` control. Retrieving the control at runtime requires setting an alias on the poll generated stream using ``TStream.alias()``.
    +
    +## Create the polled stream and set its alias
    +
    +```java
    +        Topology top = ...;
    +        SimulatedTemperatureSensor tempSensor = new SimulatedTemperatureSensor();
    +        TStream<Double> engineTemp = top.poll(tempSensor, 1, TimeUnit.SECONDS)
    +                                      .alias("engineTemp")
    +                                      .tag("engineTemp");
    +```
    +
    +It's also a good practice to add tags to streams to improve the usability of the development mode Quarks console.
    +
    +## Define a "set poll period" method
    +
    +```java
    +    static <T> void setPollPeriod(TStream<T> pollStream, long period, TimeUnit unit) {
    +        // get the topology's runtime ControlService service
    +        ControlService cs = pollStream.topology().getRuntimeServiceSupplier()
    +                                    .get().getService(ControlService.class);
    +
    +        // using the the stream's alias, get its PeriodicMXBean control
    +        PeriodicMXBean control = cs.getControl("periodic", pollStream.getAlias(), PeriodicMXBean.class);
    +
    +        // change the poll period using the control
    +        System.out.println("Setting period="+period+" "+unit+" stream="+pollStream);
    +        control.setPeriod(period, unit);
    +    }
    +```
    +
    +## Process the "set poll period" command stream
    +
    +Our commands are on the "TStream&lt;JsonObject&gt; cmds" stream.  Each JsonObject tuple is a command with the properties "period" and "unit".
    --- End diff --
    
    done


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612073
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    --- End diff --
    
    Please use sentence style capitalization: "Writing a source function"


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612083
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    --- End diff --
    
    Missing an "as" between "such" and "a" in: _For example, an event such a sudden rise..._


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60632446
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    --- End diff --
    
    done


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60632364
  
    --- Diff: site/recipes/recipe_adaptable_filter_range.md ---
    @@ -1,5 +1,5 @@
     ---
    -title: Adaptable filter behavior
    +title: Changing a Filter's Range
     ---
    --- End diff --
    
    Will do.  Related: created QUARKS-153 (should have just added to 104 :-/)


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612102
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    +
    +A Quarks IotProvider and IoTDevice with its command streams would be a natural way to control the application.  In this recipe we will just simulate a "set poll period" command stream.
    +
    +The ``Topology.poll()`` documentation describes how the poll period may be changed at runtime.
    +
    +The mechanism is based on a more general Quarks runtime ``quarks.execution.services.ControlService`` service.  The runtime registers "control beans" for entities that are controllable.  These controls can be retrieved at runtime via the service.
    +
    +At runtime, ``Topology.poll()`` registers a ``quarks.execution.mbeans.PeriodicMXBean`` control. Retrieving the control at runtime requires setting an alias on the poll generated stream using ``TStream.alias()``.
    +
    +## Create the polled stream and set its alias
    +
    +```java
    +        Topology top = ...;
    +        SimulatedTemperatureSensor tempSensor = new SimulatedTemperatureSensor();
    +        TStream<Double> engineTemp = top.poll(tempSensor, 1, TimeUnit.SECONDS)
    +                                      .alias("engineTemp")
    +                                      .tag("engineTemp");
    +```
    +
    +It's also a good practice to add tags to streams to improve the usability of the development mode Quarks console.
    +
    +## Define a "set poll period" method
    +
    +```java
    +    static <T> void setPollPeriod(TStream<T> pollStream, long period, TimeUnit unit) {
    +        // get the topology's runtime ControlService service
    +        ControlService cs = pollStream.topology().getRuntimeServiceSupplier()
    +                                    .get().getService(ControlService.class);
    +
    +        // using the the stream's alias, get its PeriodicMXBean control
    +        PeriodicMXBean control = cs.getControl("periodic", pollStream.getAlias(), PeriodicMXBean.class);
    +
    +        // change the poll period using the control
    +        System.out.println("Setting period="+period+" "+unit+" stream="+pollStream);
    +        control.setPeriod(period, unit);
    +    }
    +```
    +
    +## Process the "set poll period" command stream
    +
    +Our commands are on the "TStream&lt;JsonObject&gt; cmds" stream.  Each JsonObject tuple is a command with the properties "period" and "unit".
    --- End diff --
    
    Consider putting `JsonObject` in an inline code block


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60632412
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    --- End diff --
    
    will do


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60612051
  
    --- Diff: site/recipes/recipe_adaptable_filter_range.md ---
    @@ -1,5 +1,5 @@
     ---
    -title: Adaptable filter behavior
    +title: Changing a Filter's Range
     ---
    --- End diff --
    
    Please use sentence style capitalization as mentioned in [QUARKS-104](https://issues.apache.org/jira/browse/QUARKS-104): "Changing a filter's range"


---
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-quarks-website pull request: [QUARKS-123] [REVIEW] adapt...

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

    https://github.com/apache/incubator-quarks-website/pull/40#discussion_r60633997
  
    --- Diff: site/recipes/recipe_adaptable_polling_source.md ---
    @@ -0,0 +1,138 @@
    +---
    +title: Changing a Polled Source Stream's Period
    +---
    +
    +The [Writing a Source Function](recipe_source_function.html) recipe introduced the basics of creating a source stream by polling a data source periodically.
    +
    +Oftentimes, a user wants the poll frequency to be adaptable rather than static.  For example, an event such a sudden rise in a temperature sensor may motivate more frequent polling of the sensor and analysis of the data until the condition subsides.  A change in the poll frequency may be driven by locally performed analytics or via a command from an external source.
    +
    +A Quarks IotProvider and IoTDevice with its command streams would be a natural way to control the application.  In this recipe we will just simulate a "set poll period" command stream.
    --- End diff --
    
    done


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