Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ node_modules/
ideas
*_err.log
*.swp
package-lock.json
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
language: node_js
node_js:
- "8"
sudo: required
before_install:
- 'if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi'
- wget "http://static.druid.io/artifacts/releases/druid-0.8.3-bin.tar.gz"
- tar -zxvf druid-0.8.3-bin.tar.gz
- wget "https://archive.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz"
- tar -zxvf kafka_2.10-0.8.2.0.tgz
install:
- npm -s install
- mvn -q clean install -f ./infinispan_example_app/pom.xml
- npm install
- mvn clean install -f ./infinispan_example_app/pom.xml
script:
- node --version
- ./infispector.sh help
- ./infispector.sh prepare
- ./infispector.sh nodes
- ./infispector.sh nodes 1
- ./infispector.sh nodes 1
- ./infispector.sh nodes 1
- ./infispector.sh nodes 1
- ./testFunctionality.sh
- npm --harmony test
4 changes: 2 additions & 2 deletions gruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
serverFile: 'app.js',
shell: {
nodemon: {
command: 'nodemon <%= serverFile %>',
command: '${infispector_location}/node_modules/nodemon/bin/nodemon.js <%= serverFile %>',
options: {
stdout: true,
stderr: true,
Expand All @@ -218,4 +218,4 @@
});


};
};
4 changes: 2 additions & 2 deletions infinispan_example_app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<!-- JBoss dependency versions -->
<version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
Expand Down
233 changes: 139 additions & 94 deletions infispector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@ cleanUp() {
pkill -f kafka -e
pkill -f zookeeper -e
pkill -f grunt -e
pkill -f nodemon -e
}

#colors
NC='\033[0m'
WHITE='\033[1;37m'
GREEN='\033[0;32m'
RED='\033[0;31m'

if [ "$#" -eq "0" ] || [ $1 == "help" ]
then
printHelp() {
printf "
_____ __ _ _
|_ _| / _|(_) | |
| | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __
_____ __ _ _
|_ _| / _|(_) | |
| | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __
| | | '_ \ | _|| |/ __|| '_ \ / _ \ / __|| __| / _ \ | '__|
_| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || |
|_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_|
| |
|_|
_| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || |
|_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_|
| |
|_|


commands:
Expand All @@ -32,60 +26,67 @@ ${GREEN}infispector prepare${NC} - starts dependecies (zookeeper, kafka, druid)
${GREEN}infispector start${NC} - starts application
${GREEN}infispector stop${NC} - stops infispector
${GREEN}infispector nodes${NC} - starts 4 instances
${GREEN}infispector uninstall${NC} - uninstalls infispector
${GREEN}infispector nodes ${RED}NUMBER${NC} - starts specified ${RED}NUMBER${NC} of instances
"
exit 0
fi

#paths
DRUID_LOCATION=`find /home -type d -name druid-0.8.3 2> /dev/null`
KAFKA_LOCATION=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null`
INFISPECTOR_LOCATION=`find /home -type d -iname infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '`

DEFAULT="4"
NUMBER_CHECK='^[0-9]+$'
cnt="0"
TIMEOUT="0"

if [ -z $DRUID_LOCATION ]
then
printf "Druid not found. Druid must be in /home/* directory\n" >&2
exit 1
fi

if [ -z $KAFKA_LOCATION ]
then
printf "Kafka not found. Kafka must be in /home/* directory\n" >&2
exit 1
fi
}

if [ -z $INFISPECTOR_LOCATION ]
then
printf "Infispector not found. Infispector must be in /home/* directory\n" >&2
exit 1
fi
getInfispectorLocation() {
result=""
if [[ -z "$infispector_location" ]]
then
result=`find /home -type d -name infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '`
else
result="$infispector_location"
fi
if [[ -z "$result" ]]
then
printf "Infispector not found. Infispector must be in /home/* directory\n" >&2
exit 1
fi
echo "$result"
}

if [ $EUID -eq 0 ]
then
printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >$2
exit 1
fi
getDruidLocation() {
result=`find /home -type d -name druid-0.8.3 2> /dev/null`
if [[ -z "$result" ]]
then
printf "Druid not found. Druid must be in /home/* directory\n" >&2
exit 1
fi
echo "$result"
}

if [ "$#" -gt "2" ] || { [ "$#" -eq "2" ] && [ "$1" != "nodes" ]; }
#if [ \( "$#" -gt "2" \) -o \( "$g" "$#" -eq "2" -a "$1" -ne "nodes" \) ]
then
printf "Invalid number of arguments!\n" >$2
exit 1
fi
getKafkaLocation() {
result=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null`
if [[ -z "$result" ]]
then
printf "Kafka not found. Kafka must be in /home/* directory\n" >&2
exit 1
fi
echo "$result"
}

checkUserAndParams() {
if [[ $EUID -eq 0 ]]
then
printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >&2
exit 1
fi

if [[ "$#" -gt "2" ]] || { [[ "$#" -eq "2" ]] && [[ "$1" != "nodes" ]]; }
then
printf "Invalid number of arguments!\n" >&2
exit 1
fi
}

if [ $1 == "prepare" ]
then
cd $KAFKA_LOCATION
startKafka() {
cd ${KAFKA_LOCATION}
printf "Starting zookeeper ...."
bin/zookeeper-server-start.sh config/zookeeper.properties > /dev/null &
sleep 1
if [ $? -ne 0 ]
if [[ $? -ne 0 ]]
then
printf " ${RED}FAIL${NC}\n"
cleanUp
Expand All @@ -96,19 +97,22 @@ then
printf "Starting kafka ...."
bin/kafka-server-start.sh config/server.properties > /dev/null &
sleep 1
if [ $? -ne 0 ]
if [[ $? -ne 0 ]]
then
printf " ${RED}FAIL${NC}\n"
cleanUp
exit 1
else
printf " ${GREEN}OK${NC}\n"
fi
}

cd $DRUID_LOCATION
startDruid() {
TIMEOUT="0"
cd ${DRUID_LOCATION}
printf "Starting druid ...."
java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Ddruid.realtime.specFile=$INFISPECTOR_LOCATION/kafka_druid_infrastructure/infispectorDruid.spec -classpath "config/_common:config/realtime:lib/*" io.druid.cli.Main server realtime > log.txt 2> log_err.txt &
if echo $INFISPECTOR_LOCATION | grep travis > /dev/null
java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Ddruid.realtime.specFile=${INFISPECTOR_LOCATION}/kafka_druid_infrastructure/infispectorDruid.spec -classpath "config/_common:config/realtime:lib/*" io.druid.cli.Main server realtime > log.txt 2> log_err.txt &
if echo ${INFISPECTOR_LOCATION} | grep travis > /dev/null
then
sleep 10
fi
Expand All @@ -119,78 +123,119 @@ then
then
break
fi
if [ $TIMEOUT -eq "20" ]
if [[ "$TIMEOUT" -eq 20 ]]
then
printf " ${RED}FAIL${NC}\n"
cleanUp
exit 1
fi
TIMEOUT=$[$TIMEOUT + 1]
sleep 1
sleep 1
done
printf " ${GREEN}OK${NC}\n"
printf "Infispector is ready to be started!\n"
exit 0
fi
}

if [ $1 == "start" ]
then
cd $INFISPECTOR_LOCATION
grunt
exit 0
fi
prepare() {
startKafka
startDruid
printf " ${GREEN}OK${NC}\n"
printf "Infispector is ready to be started!\n"
}

if [ $1 == "stop" ]
then
cleanUp
exit 0
fi
start() {
cd ${INFISPECTOR_LOCATION}
grunt | tee output.out &
while true
do
if cat output.out | grep "Server is listening on port 8080" > /dev/null
then
break
fi
done
rm output.out
}

uninstall() {
${INFISPECTOR_LOCATION}/uninstall.sh
}

if [ $1 == "nodes" ]
then
cd $INFISPECTOR_LOCATION/infinispan_example_app
if ! [[ -z "$2" ]]
setNumberOfNodes() {
result="4"
NUMBER_CHECK='^[0-9]+$'
if ! [[ -z "$1" ]]
then
if ! [[ $2 =~ $NUMBER_CHECK ]]
if ! [[ $1 =~ $NUMBER_CHECK ]]
then
printf "Second argument must be a number\n" >&2
exit 1
fi
DEFAULT=$2
if [ $DEFAULT -ge "10" ]
result=$1
if [[ "$result" -ge "10" ]]
then
while true;
do
read -p "Are you sure you want to start ${DEFAULT} instances? [y/n] " yn
read -p "Are you sure you want to start ${result} instances? [y/n] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
*) echo "Please answer y or n.";;
*) echo "Please answer y or n." >&2;;
esac
done
fi
fi
echo "$result"
}

nodes() {
DEFAULT="$(setNumberOfNodes "$1")"
cnt="0"
cd ${INFISPECTOR_LOCATION}/infinispan_example_app

printf "Starting $DEFAULT nodes ...."
while [ $cnt -ne $DEFAULT ]
while [[ "$cnt" -ne "$DEFAULT" ]]
do
if [ $cnt -eq $[$DEFAULT - 1] ]
if [[ ${cnt} -eq $((DEFAULT - 1)) ]]
then
mvn exec:exec > /dev/null
else
nohup mvn exec:exec > /dev/null 2> /dev/null &
fi
cnt=$[$cnt + 1]
done
if [ $? -eq 0 ]
if [[ $? -eq 0 ]]
then
printf " ${GREEN}OK${NC}\n"
exit 0
else
printf " ${RED}FAIL${NC}\n"
exit 1
fi
}

#paths
DRUID_LOCATION=$(getDruidLocation)
KAFKA_LOCATION=$(getKafkaLocation)
INFISPECTOR_LOCATION=$(getInfispectorLocation)

#colors
NC='\033[0m'
WHITE='\033[1;37m'
GREEN='\033[0;32m'
RED='\033[0;31m'

checkUserAndParams
if [[ $# -eq 0 ]]
then
printHelp
exit 0
fi

printf "Invalid argument!\n" >&2
exit 1
case $1 in
("prepare") prepare ;;
("start") start; xdg-open http://localhost:8080 ;;
("stop") cleanUp ;;
("nodes") nodes $2;;
("uninstall") uninstall ;;
("help") printHelp ;;
(*) echo "invalid argument"; echo "usage: " ; printHelp ;;
esac
exit 0
2 changes: 1 addition & 1 deletion infispectorAutocomplete
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _infispector_complete() {
local words cur
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=()
words="prepare start nodes help stop"
words="prepare start nodes help stop uninstall"
if [ ${COMP_CWORD} -eq 1 ]
then
COMPREPLY=( $(compgen -W "${words}" -- $cur) )
Expand Down
Loading