Permalink
Browse files

bugfixes for the twitter example (thanks Daniel!)

- schedule only 1 timer activity
- fix hashtag identification
- cleanup build files
  • Loading branch information...
matthieumorel committed Jun 15, 2012
1 parent ab7f020 commit 03384849ef815d0b22777733133a06ec0780c3a4
@@ -356,9 +356,6 @@ public ProcessingElement setTimerInterval(long interval, TimeUnit timeUnit) {
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 @@ void initPEPrototypeInternal() {
/* 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. */
@@ -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.
@@ -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.
@@ -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,15 +63,15 @@ 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. */
flatDir name: 'libDir', dirs: "$rootDir/lib"
}
/* 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*;.*/
@@ -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,15 +61,15 @@ 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. */
flatDir name: 'libDir', dirs: "$rootDir/lib"
}
/* 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*;.*/
@@ -34,13 +34,19 @@ public void setDownStream(Streamable<Event> stream) {
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));
}
}

0 comments on commit 0338484

Please sign in to comment.