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
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
language: node_js
node_js:
- "iojs"
- "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
Expand Down
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
193 changes: 111 additions & 82 deletions infispector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ cleanUp() {
pkill -f grunt -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 @@ -34,54 +27,60 @@ ${GREEN}infispector stop${NC} - stops infispector
${GREEN}infispector nodes${NC} - starts 4 instances
${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 -iname 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
Expand All @@ -104,8 +103,11 @@ then
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
Expand All @@ -119,38 +121,33 @@ 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"
}

prepare() {
startKafka
startDruid
printf " ${GREEN}OK${NC}\n"
printf "Infispector is ready to be started!\n"
exit 0
fi
}

if [ $1 == "start" ]
then
cd $INFISPECTOR_LOCATION
start() {
cd $INFISPECTOR_LOCATION
grunt
exit 0
fi

if [ $1 == "stop" ]
then
cleanUp
exit 0
fi

}

if [ $1 == "nodes" ]
then
cd $INFISPECTOR_LOCATION/infinispan_example_app
if ! [[ -z "$2" ]]
setNumberOfNodes() {
result="4"
NUMBER_CHECK='^[0-9]+$'
if ! [[ -z "$2" ]]
then
if ! [[ $2 =~ $NUMBER_CHECK ]]
then
Expand All @@ -171,6 +168,14 @@ then
done
fi
fi
echo "$result"
}

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

printf "Starting $DEFAULT nodes ...."
while [ $cnt -ne $DEFAULT ]
do
Expand All @@ -190,7 +195,31 @@ then
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 ;;
("stop") cleanUp ;;
("nodes") nodes ;;
("help") printHelp ;;
(*) echo "invalid argument"; echo "usage: " ; printHelp ;;
esac
16 changes: 11 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

downloadMaven() {
printf "Downloading maven...\n"
wget -q --show-progress $URL_MAVEN
wget $_PROGRESS_OPT $URL_MAVEN
tar zxvf apache-maven-3.5.2-bin.tar.gz -C $HOME > /dev/null
/bin/rm apache-maven-3.5.2-bin.tar.gz > /dev/null
M2_HOME=$HOME/apache-maven-3.5.2
Expand Down Expand Up @@ -48,6 +48,10 @@ then
exit 1
fi

#set wget options
wget --help | grep -q '\--show-progress' && \
_PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT=""

printf "Looking for a druid-0.8.3 folder in device ...."
druid_location=`find /home -type d -name druid-0.8.3 2> /dev/null`
if echo $druid_location | grep "Trash" > /dev/null
Expand All @@ -59,7 +63,7 @@ fi
if [ -z "$druid_location" ]
then
printf " ${RED}NOT FOUND${NC}.\n"
wget -q --show-progress $URL_DRUID
wget $_PROGRESS_OPT $URL_DRUID
if [ $? -eq 0 ]
then
tar -xvzf druid-0.8.3-bin.tar.gz -C $HOME > /dev/null
Expand All @@ -84,7 +88,7 @@ fi
if [ -z "$kafka_location" ]
then
printf " ${RED}NOT FOUND${NC}.\n"
wget -q --show-progress $URL_KAFKA
wget $_PROGRESS_OPT $URL_KAFKA
if [ $? -eq 0 ]
then
tar -xvzf kafka_2.10-0.8.2.0.tgz -C $HOME > /dev/null
Expand All @@ -94,7 +98,7 @@ then
printf "Kafka download failed\n" >&2
fi
else
printf " ${GREEN}FOUND${NC}. Download will be skipped.\n"
printf " ${GREEN}FOUND${NC}.\nDownload will be skipped.\n"
fi

#sets alias infispector to start script infispector.sh
Expand All @@ -116,6 +120,8 @@ fi
if ! grep "alias infispector='${infispector_location}/infispector.sh'" < ~/.bashrc > /dev/null
then
printf "alias infispector='${infispector_location}/infispector.sh'\n" >> ~/.bashrc
printf "infispector_location='${infispector_location}'\n" >> ~/.bashrc
printf "export infispector_location\n" >> ~/.bashrc
fi

#create new file with autocomplete - requires permission
Expand Down Expand Up @@ -189,7 +195,7 @@ then
fi
printf "mvn install ...."
cd $infispector_location/infinispan_example_app/
mvn -q clean install 2> $infispector_location/mvn_err.log
mvn clean install 2> $infispector_location/mvn_err.log
if [ $? -eq 0 ]
then
printf " ${GREEN}OK${NC}\n"
Expand Down
Loading