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
[3/22] git commit: bugfixes for the twitter example (thanks Daniel!)
- schedule only 1 timer activity - fix hashtag identification - cleanup build
files
bugfixes for the twitter example (thanks Daniel!)
- schedule only 1 timer activity
- fix hashtag identification
- cleanup build files
Project: http://git-wip-us.apache.org/repos/asf/incubator-s4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s4/commit/03384849
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s4/tree/03384849
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s4/diff/03384849
Branch: refs/heads/piper
Commit: 03384849ef815d0b22777733133a06ec0780c3a4
Parents: ab7f020
Author: Matthieu Morel <mm...@apache.org>
Authored: Fri Jun 15 09:57:59 2012 +0200
Committer: Matthieu Morel <mm...@apache.org>
Committed: Fri Jun 15 09:57:59 2012 +0200
----------------------------------------------------------------------
.../java/org/apache/s4/core/ProcessingElement.java | 6 +---
test-apps/simple-deployable-app-1/build.gradle | 4 +-
test-apps/simple-deployable-app-2/build.gradle | 4 +-
test-apps/twitter-adapter/build.gradle | 17 +++++++------
test-apps/twitter-counter/build.gradle | 17 +++++++------
.../s4/example/twitter/TopicExtractorPE.java | 18 ++++++++++-----
6 files changed, 36 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/subprojects/s4-core/src/main/java/org/apache/s4/core/ProcessingElement.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/main/java/org/apache/s4/core/ProcessingElement.java b/subprojects/s4-core/src/main/java/org/apache/s4/core/ProcessingElement.java
index 804b9b5..1576044 100644
--- a/subprojects/s4-core/src/main/java/org/apache/s4/core/ProcessingElement.java
+++ b/subprojects/s4-core/src/main/java/org/apache/s4/core/ProcessingElement.java
@@ -356,9 +356,6 @@ public abstract class ProcessingElement implements Cloneable {
return this;
timer = new Timer();
- logger.info("Created timer for PE prototype [{}] with interval [{}].", this.getClass().getName(),
- timerIntervalInMilliseconds);
- timer.schedule(new OnTimeTask(), 0, timerIntervalInMilliseconds);
return this;
}
@@ -482,7 +479,8 @@ public abstract class ProcessingElement implements Cloneable {
/* Start timer. */
if (timer != null) {
timer.schedule(new OnTimeTask(), 0, timerIntervalInMilliseconds);
- logger.info("Started timer for PE [{}] with ID [{}].", this.getClass().getName(), id);
+ logger.debug("Started timer for PE prototype [{}], ID [{}] with interval [{}].", new String[] {
+ this.getClass().getName(), id, String.valueOf(timerIntervalInMilliseconds) });
}
/* Check if this PE is annotated as thread safe. */
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/test-apps/simple-deployable-app-1/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/simple-deployable-app-1/build.gradle b/test-apps/simple-deployable-app-1/build.gradle
index ad4dca5..6933b58 100644
--- a/test-apps/simple-deployable-app-1/build.gradle
+++ b/test-apps/simple-deployable-app-1/build.gradle
@@ -39,8 +39,8 @@ project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/app
project.ext["s4Version"] = '0.5.0-SNAPSHOT'
description = 'Apache S4 App'
//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
+project.ext["archivesBaseName"] = "$project.name"
+project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
// Append the suffix 'SNAPSHOT' when the build is not for release.
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/test-apps/simple-deployable-app-2/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/simple-deployable-app-2/build.gradle b/test-apps/simple-deployable-app-2/build.gradle
index ad4dca5..6933b58 100644
--- a/test-apps/simple-deployable-app-2/build.gradle
+++ b/test-apps/simple-deployable-app-2/build.gradle
@@ -39,8 +39,8 @@ project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/app
project.ext["s4Version"] = '0.5.0-SNAPSHOT'
description = 'Apache S4 App'
//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
+project.ext["archivesBaseName"] = "$project.name"
+project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
// Append the suffix 'SNAPSHOT' when the build is not for release.
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/test-apps/twitter-adapter/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/twitter-adapter/build.gradle b/test-apps/twitter-adapter/build.gradle
index c0f3576..06c5a29 100644
--- a/test-apps/twitter-adapter/build.gradle
+++ b/test-apps/twitter-adapter/build.gradle
@@ -34,13 +34,13 @@
/* Set the destination where we want to install the apps. */
//s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
-s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
-s4Version = '0.5.0-SNAPSHOT'
+project.ext["s4Version"] = '0.5.0-SNAPSHOT'
description = 'Apache S4 App'
//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
+project.ext["archivesBaseName"] = "$project.name"
+project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
// Append the suffix 'SNAPSHOT' when the build is not for release.
@@ -63,7 +63,7 @@ targetCompatibility = 1.6
repositories {
mavenLocal()
mavenCentral()
- mavenRepo name: "gson", urls: "http://google-gson.googlecode.com/svn/mavenrepo"
+ mavenRepo name: "gson", url: "http://google-gson.googlecode.com/svn/mavenrepo"
/* Add lib dir as a repo. Some jar files that are not available
in a public repo are distributed in the lib dir. */
@@ -71,7 +71,7 @@ repositories {
}
/* All project libraries must be defined here. */
-libraries = [
+project.ext["libraries"] = [
twitter4j_core: 'org.twitter4j:twitter4j-core:2.2.5',
twitter4j_stream: 'org.twitter4j:twitter4j-stream:2.2.5',
s4_base: 'org.apache.s4:s4-base:0.5.0-SNAPSHOT',
@@ -110,7 +110,7 @@ manifest.mainAttributes(
'S4-Version': s4Version
)
-appDependencies = ( configurations.compile )
+project.ext["appDependencies"] = ( configurations.compile )
/* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
// TODO: exclude schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
@@ -177,7 +177,8 @@ task cp << {
*/
def getAppClassname(file) {
def classname = "UNKNOWN"
- lines= file.readLines()
+ def lines= file.readLines()
+ def packageName = ""
for(line in lines) {
def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/test-apps/twitter-counter/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/twitter-counter/build.gradle b/test-apps/twitter-counter/build.gradle
index 4b7f6ff..6fd625d 100644
--- a/test-apps/twitter-counter/build.gradle
+++ b/test-apps/twitter-counter/build.gradle
@@ -34,13 +34,13 @@
/* Set the destination where we want to install the apps. */
//s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
-s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
-s4Version = '0.5.0-SNAPSHOT'
+project.ext["s4Version"] = '0.5.0-SNAPSHOT'
description = 'Apache S4 App'
//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
+project.ext["archivesBaseName"] = "$project.name"
+project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
// Append the suffix 'SNAPSHOT' when the build is not for release.
@@ -61,7 +61,7 @@ targetCompatibility = 1.6
repositories {
mavenLocal()
mavenCentral()
- mavenRepo name: "gson", urls: "http://google-gson.googlecode.com/svn/mavenrepo"
+ mavenRepo name: "gson", url: "http://google-gson.googlecode.com/svn/mavenrepo"
/* Add lib dir as a repo. Some jar files that are not available
in a public repo are distributed in the lib dir. */
@@ -69,7 +69,7 @@ repositories {
}
/* All project libraries must be defined here. */
-libraries = [
+project.ext["libraries"] = [
s4_base: 'org.apache.s4:s4-base:0.5.0-SNAPSHOT',
s4_comm: 'org.apache.s4:s4-comm:0.5.0-SNAPSHOT',
@@ -106,7 +106,7 @@ manifest.mainAttributes(
'S4-Version': s4Version
)
-appDependencies = ( configurations.compile )
+project.ext["appDependencies"] = ( configurations.compile )
/* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
// TODO: exclude schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
@@ -169,7 +169,8 @@ task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
*/
def getAppClassname(file) {
def classname = "UNKNOWN"
- lines= file.readLines()
+ def lines= file.readLines()
+ def packageName = ""
for(line in lines) {
def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/03384849/test-apps/twitter-counter/src/main/java/org/apache/s4/example/twitter/TopicExtractorPE.java
----------------------------------------------------------------------
diff --git a/test-apps/twitter-counter/src/main/java/org/apache/s4/example/twitter/TopicExtractorPE.java b/test-apps/twitter-counter/src/main/java/org/apache/s4/example/twitter/TopicExtractorPE.java
index 946e3c9..9211583 100644
--- a/test-apps/twitter-counter/src/main/java/org/apache/s4/example/twitter/TopicExtractorPE.java
+++ b/test-apps/twitter-counter/src/main/java/org/apache/s4/example/twitter/TopicExtractorPE.java
@@ -34,13 +34,19 @@ public class TopicExtractorPE extends ProcessingElement {
public void onEvent(Event event) {
String text = event.get("statusText", String.class);
logger.trace("event text [{}]", text);
- if (text.contains("#")) {
- Iterable<String> split = Splitter.on("#").omitEmptyStrings().trimResults()
- .split(text.substring(text.indexOf("#") + 1, text.length()));
- for (String topic : split) {
- String topicOnly = topic.split(" ")[0];
- downStream.put(new TopicEvent(topicOnly, 1));
+ if (!text.contains("#")) {
+ return;
+ }
+ Iterable<String> split = Splitter.on(' ').omitEmptyStrings().trimResults().split(text);
+ for (String topic : split) {
+ if (!topic.startsWith("#")) {
+ continue;
+ }
+ String topicOnly = topic.substring(1);
+ if (topicOnly.length() == 0 || topicOnly.contains("#")) {
+ continue;
}
+ downStream.put(new TopicEvent(topicOnly, 1));
}
}