You are viewing a plain text version of this content. The canonical link for it is here.
Posted to s4-commits@incubator.apache.org by mm...@apache.org on 2012/06/15 16:06:01 UTC
[16/22] git commit: updated examples with recent core API changes
updated examples with recent core API changes
Project: http://git-wip-us.apache.org/repos/asf/incubator-s4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s4/commit/593d04ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s4/tree/593d04ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s4/diff/593d04ba
Branch: refs/heads/piper
Commit: 593d04baedd2a689b6480c2148fd49a74b60b57e
Parents: 4878cba
Author: Matthieu Morel <mm...@apache.org>
Authored: Thu Mar 29 17:09:05 2012 +0200
Committer: Matthieu Morel <mm...@apache.org>
Committed: Thu Mar 29 17:09:05 2012 +0200
----------------------------------------------------------------------
.../java/org/apache/s4/example/counter/MyApp.java | 46 ++++----------
.../java/org/apache/s4/example/model/MyApp.java | 12 +---
2 files changed, 17 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/593d04ba/subprojects/s4-example/src/main/java/org/apache/s4/example/counter/MyApp.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-example/src/main/java/org/apache/s4/example/counter/MyApp.java b/subprojects/s4-example/src/main/java/org/apache/s4/example/counter/MyApp.java
index b5cf2b1..eeceaed 100644
--- a/subprojects/s4-example/src/main/java/org/apache/s4/example/counter/MyApp.java
+++ b/subprojects/s4-example/src/main/java/org/apache/s4/example/counter/MyApp.java
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
- *
+ *
* Licensed 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. See accompanying LICENSE file.
+ * License. See accompanying LICENSE file.
*/
package org.apache.s4.example.counter;
@@ -27,9 +27,9 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
/*
- * This is a sample application to test a new S4 API.
+ * This is a sample application to test a new S4 API.
* See README file for details.
- *
+ *
* */
final public class MyApp extends App {
@@ -61,20 +61,11 @@ final public class MyApp extends App {
/* PE that prints counts to console. */
PrintPE printPE = createPE(PrintPE.class);
- Stream<CountEvent> userCountStream = createStream(CountEvent.class);
- userCountStream.setName("User Count Stream");
- userCountStream.setKey(new CountKeyFinder());
- userCountStream.setPE(printPE);
+ Stream<CountEvent> userCountStream = createStream("User Count Stream", new CountKeyFinder(), printPE);
- Stream<CountEvent> genderCountStream = createStream(CountEvent.class);
- genderCountStream.setName("Gender Count Stream");
- genderCountStream.setKey(new CountKeyFinder());
- genderCountStream.setPE(printPE);
+ Stream<CountEvent> genderCountStream = createStream("Gender Count Stream", new CountKeyFinder(), printPE);
- Stream<CountEvent> ageCountStream = createStream(CountEvent.class);
- ageCountStream.setName("Age Count Stream");
- ageCountStream.setKey(new CountKeyFinder());
- ageCountStream.setPE(printPE);
+ Stream<CountEvent> ageCountStream = createStream("Age Count Stream", new CountKeyFinder(), printPE);
/* PEs that count events by user, gender, and age. */
CounterPE userCountPE = createPE(CounterPE.class);
@@ -90,22 +81,11 @@ final public class MyApp extends App {
ageCountPE.setCountStream(ageCountStream);
/* Streams that output user events keyed on user, gender, and age. */
- Stream<UserEvent> userStream = createStream(UserEvent.class);
- userStream.setName("User Stream");
- userStream.setKey(new UserIDKeyFinder());
- userStream.setPE(userCountPE);
-
- Stream<UserEvent> genderStream = createStream(UserEvent.class);
- genderStream.setName("Gender Stream");
- /* It is possible to specify a field name of a primitive type as a string instead of using a KeyFinder object. */
- // genderStream.setKey(new GenderKeyFinder());
- genderStream.setKey("gender");
- genderStream.setPE(genderCountPE);
-
- Stream<UserEvent> ageStream = createStream(UserEvent.class);
- ageStream.setName("Age Stream");
- ageStream.setKey(new AgeKeyFinder());
- ageStream.setPE(ageCountPE);
+ Stream<UserEvent> userStream = createStream("User Stream", new UserIDKeyFinder(), userCountPE);
+
+ Stream<UserEvent> genderStream = createStream("Gender Stream", new GenderKeyFinder(), genderCountPE);
+
+ Stream<UserEvent> ageStream = createStream("Age Stream", new AgeKeyFinder(), ageCountPE);
generateUserEventPE = createPE(GenerateUserEventPE.class);
generateUserEventPE.setStreams(userStream, genderStream, ageStream);
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/593d04ba/subprojects/s4-example/src/main/java/org/apache/s4/example/model/MyApp.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-example/src/main/java/org/apache/s4/example/model/MyApp.java b/subprojects/s4-example/src/main/java/org/apache/s4/example/model/MyApp.java
index ee649cb..2985c63 100644
--- a/subprojects/s4-example/src/main/java/org/apache/s4/example/model/MyApp.java
+++ b/subprojects/s4-example/src/main/java/org/apache/s4/example/model/MyApp.java
@@ -1,18 +1,18 @@
/*
* Copyright (c) 2011 The S4 Project, http://s4.io.
* All rights reserved.
- *
+ *
* Licensed 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. See accompanying LICENSE file.
+ * License. See accompanying LICENSE file.
*/
package org.apache.s4.example.model;
@@ -95,7 +95,7 @@ public class MyApp extends App {
modelPE.setStream(distanceStream, resultStream);
// modelPE.setOutputIntervalInEvents(10); // output every 10 events
metricsPE.setTimerInterval(outputInterval, timeUnit); // output every 5
- // seconds
+ // seconds
// obsStream = new Stream<ObsEvent>(this, "Observation Stream", new
// ClassIDKeyFinder(), modelPE);
obsStream = createStream("Observation Stream", modelPE);
@@ -163,10 +163,6 @@ public class MyApp extends App {
close();
}
- @Override
- protected void close() {
- }
-
public long getObsCount() {
return modelPE.getObsCount();