Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
bugfixes for the twitter example (thanks Daniel!)
Browse files Browse the repository at this point in the history
- schedule only 1 timer activity
- fix hashtag identification
- cleanup build files
  • Loading branch information
matthieumorel committed Jun 15, 2012
1 parent ab7f020 commit 0338484
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions test-apps/simple-deployable-app-1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions test-apps/simple-deployable-app-2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 9 additions & 8 deletions test-apps/twitter-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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*;.*/
Expand Down
17 changes: 9 additions & 8 deletions test-apps/twitter-counter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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*;.*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 0338484

Please sign in to comment.