blob: b1274c916be0a6071526652276b1c4f0561a2f81 [file] [log] [blame]
### Run client examples.
## Injecting Events with a Perl Client
# Create a directory for all the s4 project repositories.
mkdir s4project
cd s4project
# Clone repo.
git clone git@github.com:s4/s4.git
# Build it!
cd s4
gradlew clean allImage
# Create some environment variables.
export S4_IMAGE=`pwd`'/build/s4-image'
export PYTHONPATH=${S4_IMAGE}/s4-driver/lib/python
export PERLLIB=${S4_IMAGE}/s4-driver/lib/perl
# Change script permissions.
chmod u+x $S4_IMAGE/scripts/*
chmod u+x $S4_IMAGE/s4-driver/scripts/*
# Copy speech02 app to apps deployment directory.
cp -fr $S4_IMAGE/s4-example-apps/s4-example-speech02 $S4_IMAGE/s4-apps
# Start S4 server in standalone mode.
$S4_IMAGE/scripts/start-s4.sh -r client-adapter &
# Start client adapter.
$S4_IMAGE/scripts/run-client-adapter.sh -s client-adapter -g s4 \
-x -d $S4_IMAGE/s4-core/conf/default/client-stub-conf.xml &
# Inject events.
perl $S4_IMAGE/s4-driver/scripts/inject.pl RawSpeech \
org.apache.s4.example.speech01.Speech < $S4_IMAGE/testinput/speech.in
perl $S4_IMAGE/s4-driver/scripts/inject.pl RawSentence \
org.apache.s4.example.speech01.Sentence < $S4_IMAGE/testinput/sentence.in
## Injecting Events with a Java Client
# Follow same steps as before to start S4 server and client adapter.
# Inject events.
$S4_IMAGE/s4-driver/scripts/inject.sh localhost 2334 RawSpeech \
org.apache.s4.example.speech01.Speech < $S4_IMAGE/testinput/speech.in
$S4_IMAGE/s4-driver/scripts/inject.sh localhost 2334 RawSentence \
org.apache.s4.example.speech01.Sentence < $S4_IMAGE/testinput/sentence.in
## Receiving Events
# Follow same steps as before to start S4 server and client adapter.
# Start a reader client.
perl $S4_IMAGE/s4-driver/scripts/read.pl \
'{
readMode => "select",
readInclude => ["SentenceJoined"]
}'
# In a different window, inject messages like in the previous section.
# Remember to initialize the environment variables in the new shell.
export S4_IMAGE=`pwd`'/build/s4-image'
export PYTHONPATH=${S4_IMAGE}/s4-driver/lib/python
export PERLLIB=${S4_IMAGE}/s4-driver/lib/perl
# Inject events.
perl $S4_IMAGE/s4-driver/scripts/inject.pl RawSpeech \
org.apache.s4.example.speech01.Speech < $S4_IMAGE/testinput/speech.in
perl $S4_IMAGE/s4-driver/scripts/inject.pl RawSentence \
org.apache.s4.example.speech01.Sentence < $S4_IMAGE/testinput/sentence.in
## Request-Response
# Example 1: query the prototype of the joiner (SentenceJoinPE)
# in the speech02 application.
python $S4_IMAGE/s4-driver/scripts/request.py '#sentenceJoinPE' \
'org.apache.s4.message.PrototypeRequest' < $S4_IMAGE/testinput/proto-query
# Example 2: request to a single PE from
python $S4_IMAGE/s4-driver/scripts/request.py '#sentenceJoinPE' \
'org.apache.s4.message.SinglePERequest' < $S4_IMAGE/testinput/pe-query
-------
### How to set up dev environment for application developer.
# Create project dir.
mkdir myapp
cd myapp
export MYAPP_BASE=`pwd`
mkdir lib
# Create directory for s4 images.
cd SOME_DIR
mkdir s4images
cd s4images
# Download S4 binary distribution.
# put a command here to download bin tgz file.
# Extract image from tgz file.
tar xvzf s4-0.3-SNAPSHOT-bin.tgz
rm -f s4-0.3-SNAPSHOT-bin.tgz
cd s4-0.3-SNAPSHOT
export S4_IMAGE=`pwd`
# The build script will expect to find the S4_IMAGE env variable.
### Using Eclipse
# Configure Gradle as an external configuration in Eclipse:
# http://docs.codehaus.org/display/GRADLE/Running+Gradle+from+Eclipse
# To edit the build.gradle file use the Groovy editor.
# 1. Install Groovy Eclipse plugin.
# 2. Right click on the "build.gradle" file.
# 3. Select Open With -> Other -> Groovy Editor
More info. Gradle screencasts:
http://www.gradlecasts.org/