You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2016/04/26 21:35:24 UTC
[08/14] incubator-quarks git commit: PeriodicMXBean=>PeriodMXBean,
register mbean with new TStream.TYPE
PeriodicMXBean=>PeriodMXBean, register mbean with new TStream.TYPE
Project: http://git-wip-us.apache.org/repos/asf/incubator-quarks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quarks/commit/042b4a9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quarks/tree/042b4a9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quarks/diff/042b4a9f
Branch: refs/heads/master
Commit: 042b4a9f4839a215f2548b5a35045a63ba9385d3
Parents: e0b630c
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Fri Apr 22 09:35:31 2016 -0400
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Fri Apr 22 09:35:31 2016 -0400
----------------------------------------------------------------------
.../quarks/execution/mbeans/PeriodMXBean.java | 59 ++++++++++++++++++++
.../quarks/execution/mbeans/PeriodicMXBean.java | 52 -----------------
.../java/quarks/oplet/core/PeriodicSource.java | 9 +--
.../src/main/java/quarks/topology/TStream.java | 7 +++
.../src/main/java/quarks/topology/Topology.java | 8 ++-
.../java/quarks/test/topology/TopologyTest.java | 5 +-
6 files changed, 79 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/execution/src/main/java/quarks/execution/mbeans/PeriodMXBean.java
----------------------------------------------------------------------
diff --git a/api/execution/src/main/java/quarks/execution/mbeans/PeriodMXBean.java b/api/execution/src/main/java/quarks/execution/mbeans/PeriodMXBean.java
new file mode 100644
index 0000000..cf030a1
--- /dev/null
+++ b/api/execution/src/main/java/quarks/execution/mbeans/PeriodMXBean.java
@@ -0,0 +1,59 @@
+/*
+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 quarks.execution.mbeans;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Control mbean interface for an entity having an a time period control.
+ * <P>
+ * This mbean lacks a {@code TYPE} declaration because it's
+ * a generic control interface applicable to a variety of
+ * object types (e.g., a stream or window).
+ * The type of the associated object is to be used when
+ * registering instances of this mbean with the
+ * {@link quarks.execution.services.ControlService ControlService}.
+ * </P>
+ *
+ * @see quarks.topology.Topology#poll(quarks.function.Supplier, long, TimeUnit)
+ */
+public interface PeriodMXBean {
+
+ /**
+ * Get the period.
+ * @return period
+ */
+ public long getPeriod();
+
+ /**
+ * Get the time unit for {@link #getPeriod()}.
+ * @return time unit
+ */
+ public TimeUnit getUnit();
+
+ /**
+ * Set the period.
+ */
+ public void setPeriod(long period);
+
+ /**
+ * Set the period and unit
+ */
+ public void setPeriod(long period, TimeUnit unit);
+}
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/execution/src/main/java/quarks/execution/mbeans/PeriodicMXBean.java
----------------------------------------------------------------------
diff --git a/api/execution/src/main/java/quarks/execution/mbeans/PeriodicMXBean.java b/api/execution/src/main/java/quarks/execution/mbeans/PeriodicMXBean.java
deleted file mode 100644
index 41f293e..0000000
--- a/api/execution/src/main/java/quarks/execution/mbeans/PeriodicMXBean.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-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 quarks.execution.mbeans;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Control interface for a periodic entity.
- *
- * @see quarks.topology.Topology#poll(quarks.function.Supplier, long, TimeUnit)
- *
- */
-public interface PeriodicMXBean {
-
- /**
- * Get the period.
- * @return period
- */
- public long getPeriod();
-
- /**
- * Get the time unit for {@link #getPeriod()}.
- * @return time unit
- */
- public TimeUnit getUnit();
-
- /**
- * Set the period.
- */
- public void setPeriod(long period);
-
- /**
- * Set the period and unit
- */
- public void setPeriod(long period, TimeUnit unit);
-}
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/oplet/src/main/java/quarks/oplet/core/PeriodicSource.java
----------------------------------------------------------------------
diff --git a/api/oplet/src/main/java/quarks/oplet/core/PeriodicSource.java b/api/oplet/src/main/java/quarks/oplet/core/PeriodicSource.java
index 47bb1f1..36333f0 100644
--- a/api/oplet/src/main/java/quarks/oplet/core/PeriodicSource.java
+++ b/api/oplet/src/main/java/quarks/oplet/core/PeriodicSource.java
@@ -22,12 +22,13 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import quarks.execution.mbeans.PeriodicMXBean;
+import quarks.execution.mbeans.PeriodMXBean;
import quarks.execution.services.ControlService;
import quarks.oplet.OpletContext;
import quarks.oplet.OutputContext;
+import quarks.topology.TStream;
-public abstract class PeriodicSource<T> extends Source<T> implements Runnable, PeriodicMXBean {
+public abstract class PeriodicSource<T> extends Source<T> implements Runnable, PeriodMXBean {
private long period;
private TimeUnit unit;
@@ -47,8 +48,8 @@ public abstract class PeriodicSource<T> extends Source<T> implements Runnable, P
public synchronized void start() {
ControlService cs = getOpletContext().getService(ControlService.class);
if (cs != null)
- cs.registerControl("periodic", getOpletContext().uniquify(getClass().getSimpleName()),
- getAlias(), PeriodicMXBean.class, this);
+ cs.registerControl(TStream.TYPE, getOpletContext().uniquify(getClass().getSimpleName()),
+ getAlias(), PeriodMXBean.class, this);
schedule(false);
}
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/topology/src/main/java/quarks/topology/TStream.java
----------------------------------------------------------------------
diff --git a/api/topology/src/main/java/quarks/topology/TStream.java b/api/topology/src/main/java/quarks/topology/TStream.java
index 9f3707f..c22f5c5 100644
--- a/api/topology/src/main/java/quarks/topology/TStream.java
+++ b/api/topology/src/main/java/quarks/topology/TStream.java
@@ -53,6 +53,13 @@ import quarks.oplet.core.Sink;
* Tuple type.
*/
public interface TStream<T> extends TopologyElement {
+
+ /**
+ * TYPE is used to identify {@link ControlService} mbeans registered for
+ * for a TStream.
+ * The value is {@value}
+ */
+ public static final String TYPE = "stream";
/**
* Declare a new stream that filters tuples from this stream. Each tuple
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/topology/src/main/java/quarks/topology/Topology.java
----------------------------------------------------------------------
diff --git a/api/topology/src/main/java/quarks/topology/Topology.java b/api/topology/src/main/java/quarks/topology/Topology.java
index c3dc6e5..b5115ec 100644
--- a/api/topology/src/main/java/quarks/topology/Topology.java
+++ b/api/topology/src/main/java/quarks/topology/Topology.java
@@ -21,6 +21,7 @@ package quarks.topology;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
+import quarks.execution.services.ControlService;
import quarks.execution.services.RuntimeServices;
import quarks.function.Consumer;
import quarks.function.Supplier;
@@ -92,10 +93,11 @@ public interface Topology extends TopologyElement {
* method will be called when the topology's execution is terminated.
* </p><p>
* The poll rate may be changed when the topology is running via a runtime
- * {@link quarks.execution.mbeans.PeriodicMXBean PeriodicMXBean}
- * control service for the returned stream.
+ * {@link quarks.execution.mbeans.PeriodMXBean PeriodMXBean}.
* In order to use this mechanism the caller must provide a
* alias for the stream when building the topology.
+ * The {@code PeriodMXBean} is registered with the {@link ControlService}
+ * with type {@link TStream#TYPE} and the stream's alias.
* e.g.,
* <pre>{@code
* Topology t = ...
@@ -105,7 +107,7 @@ public interface Topology extends TopologyElement {
* static <T> void setPollFrequency(TStream<T> pollStream, long period, TimeUnit unit) {
* ControlService cs = t.getRuntimeServiceSupplier().getService(ControlService.class);
* String alias = pollStream.getAlias();
- * PeriodicMXBean control = cs.getControl("periodic", alias, PeriodicMXBean.class);
+ * PeriodMXBean control = cs.getControl(TStream.TYPE, alias, PeriodMXBean.class);
* control.setPoll(period, unit);
* }
* }</pre>
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/042b4a9f/api/topology/src/test/java/quarks/test/topology/TopologyTest.java
----------------------------------------------------------------------
diff --git a/api/topology/src/test/java/quarks/test/topology/TopologyTest.java b/api/topology/src/test/java/quarks/test/topology/TopologyTest.java
index 85c3bcb..4e73b61 100644
--- a/api/topology/src/test/java/quarks/test/topology/TopologyTest.java
+++ b/api/topology/src/test/java/quarks/test/topology/TopologyTest.java
@@ -35,7 +35,7 @@ import org.junit.Ignore;
import org.junit.Test;
import quarks.execution.Job;
-import quarks.execution.mbeans.PeriodicMXBean;
+import quarks.execution.mbeans.PeriodMXBean;
import quarks.execution.services.ControlService;
import quarks.execution.services.RuntimeServices;
import quarks.function.Supplier;
@@ -153,7 +153,8 @@ public abstract class TopologyTest extends TopologyAbstractTest {
static <T> void setPollFrequency(TStream<T> pollStream, long period, TimeUnit unit) {
ControlService cs = pollStream.topology().getRuntimeServiceSupplier()
.get().getService(ControlService.class);
- PeriodicMXBean control = cs.getControl("periodic", pollStream.getAlias(), PeriodicMXBean.class);
+ PeriodMXBean control = cs.getControl(TStream.TYPE,
+ pollStream.getAlias(), PeriodMXBean.class);
control.setPeriod(period, unit);
}