<commit_before>#!/bin/bash
#
#
# Author:	<NAME>
#			<EMAIL>
#
# Note:		This software is released as it is, and the author is not responsible for
#			any damage or problem this may cause to its users
#
# Prerequisites: Maven, Java, Screen, Matlab (for the Plasticity search)
#
#
COMPONENT_NAME="iter"

# 
# TODO installation directory and log folders must be updated manually for the moment.
#
TODO=1

COMPONENT_PATH="/opt/$COMPONENT_NAME/"
LOG_FOLDER="/var/log/$COMPONENT_NAME/"

write_log()
{
  if [ ! -e "$LOG_FILE" ] ; then setup_log ; fi
  echo "* $*" | tee -a "$LOG_FILE"
}

setup_log()
{
  if [ ! -e "$LOG_FOLDER" ]
  then
    mkdir "$LOG_FOLDER"
  fi
  LOG_FILE="$LOG_FOLDER/$COMPONENT_NAME.log"
  touch $LOG_FILE
}

clean()
{
	write_log "Clean $COMPONENT_NAME"
	rm -v "$LOG_FOLDER/$COMPONENT_NAME."*
	rm -v "$COMPONENT_PATH"start-in-screen.sh
}

buildStartupOption(){
	# Default values
	STARTUP_OPTIONS=""
	# JVM settings
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Xms256m"
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Xmx384m"
	# ITER Mandatory configurations	
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Dlog4j.configuration=file://"$COMPONENT_PATH"conf/log4j.properties"
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Dat.ac.tuwien.dsg.cloud.configuration="$COMPONENT_PATH"conf/cloud.properties"
}

start() {
	write_log "  Starting $COMPONENT_NAME"

	buildStartupOption

	local oldpath="$PWD"
	cd "$COMPONENT_PATH"

	# TODO At the moment we use maven. As soon as the tool becomes a bit more stable we will provide proper
	# startup scripts
	export MAVEN_OPTS="$STARTUP_OPTIONS"

	TODO=1
	MANIFEST_URL=""
	
	TODO=1
	JMX_URL=""
	
	mvn exec:java \
	-Dexec.args="-c ite -s ite -m $MANIFEST_URL -j $JMX_URL" 2>&1 | tee -a "$LOG_FOLDER/$COMPONENT_NAME.out"

	# FOR THE MEANING OF THE PARAMETERS/OPTIONS READ THE PROVIDED README.md FILE
	#
	# -c ite => NOTE THIS MUST BE 3 char long !
	# -s ite => NOTE THIS MUST BE 3 char long !
	#	
	# -e plasticity (default, plasticity)
	# -b
	# --input-file bootstrap.xml
	# --output-file sawtooth.2013.11.05.xml
	# -l sawtooth-rand
	# -n 1
	# -N 1
	# -r 0 
	cd "$oldpath"
}

stop()
{
	# TODO Use screen -S ites -X quit or something to kill the screen
	write_log "  Stopping $COMPONENT_NAME: NOT TESTED !"
	local oldpath="$PWD"
	cd "$COMPONENT_PATH"
		ps aux | grep iter | grep -v grep | awk '{print $2}' | sudo xargs kill -15 >> "$LOG_FOLDER/$COMPONENT_NAME".out 2>&1
	cd "$oldpath"
	write_log "Stopped"
}

#######################################################################
# Here the main begins
#######################################################################

if [ "$TODO" == "1" ]; then
	write_log "The startup script must be update ! And all TODO entries removed"
	RETVAL=1
	exit $RETVAL
fi

case "$1" in<commit_msg>Consmetic changes<commit_after>#!/bin/bash
#
#
# Author:	<NAME>
#			<EMAIL>
#
# Note:		This software is released as it is, and the author is not responsible for
#			any damage or problem this may cause to its users
#
# Prerequisites: Maven, Java, Screen, Matlab (for the Plasticity search)
#
#
COMPONENT_NAME="iter"
COMPONENT_PATH="/opt/$COMPONENT_NAME/"
LOG_FOLDER="/var/log/$COMPONENT_NAME/"

write_log()
{
  if [ ! -e "$LOG_FILE" ] ; then setup_log ; fi
  echo "* $*" | tee -a "$LOG_FILE"
}

setup_log()
{
  if [ ! -e "$LOG_FOLDER" ]
  then
    mkdir "$LOG_FOLDER"
  fi
  LOG_FILE="$LOG_FOLDER/$COMPONENT_NAME.log"
  touch $LOG_FILE
}

clean()
{
	write_log "Clean $COMPONENT_NAME"
	rm -v "$LOG_FOLDER/$COMPONENT_NAME."*
	rm -v "$COMPONENT_PATH"start-in-screen.sh
}

buildStartupOption(){
	# Default values
	STARTUP_OPTIONS=""
	# JVM settings
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Xms256m"
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Xmx384m"
	# ITER Mandatory configurations	
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Dlog4j.configuration=file://"$COMPONENT_PATH"conf/log4j.properties"
	STARTUP_OPTIONS="$STARTUP_OPTIONS -Dat.ac.tuwien.dsg.cloud.configuration="$COMPONENT_PATH"conf/cloud.properties"
}

start() {
	write_log "  Starting $COMPONENT_NAME"

	buildStartupOption

	local oldpath="$PWD"
	cd "$COMPONENT_PATH"

	export MAVEN_OPTS="$STARTUP_OPTIONS"

	MANIFEST_URL="http://www.inf.usi.ch/phd/gambi/attachments/autocles/doodle-manifest.xml"
	JMX_URL="http://www.inf.usi.ch/phd/gambi/attachments/autocles/doodle-clients.jmx"

	mvn exec:java \
	-Dexec.args="-c ite -s ite -m $MANIFEST_URL -j $JMX_URL" 2>&1 | tee -a "$LOG_FOLDER/$COMPONENT_NAME.out"

	# FOR THE MEANING OF THE PARAMETERS/OPTIONS READ THE PROVIDED README.md FILE
	#
	# -c ite => NOTE THIS MUST BE 3 char long !
	# -s ite => NOTE THIS MUST BE 3 char long !
	#
	# -e plasticity (default, plasticity)
	# -b
	# --input-file bootstrap.xml
	# --output-file sawtooth.2013.11.05.xml
	# -l sawtooth-rand
	# -n 1
	# -N 1
	# -r 0
	cd "$oldpath"
}

stop()
{
	# TODO Use screen -S ites -X quit or something to kill the screen
	write_log "  Stopping $COMPONENT_NAME: NOT TESTED !"
	local oldpath="$PWD"
	cd "$COMPONENT_PATH"
		#screen -S $COMPONENT_NAME -X quit
		ps aux | grep iter | grep -v grep | awk '{print $2}' | sudo xargs kill -15 >> "$LOG_FOLDER/$COMPONENT_NAME".out 2>&1
	cd "$oldpath"
	write_log "Stopped"
}

#######################################################################
# Here the main begins
#######################################################################

case "$1" in
{'fraction_non_alphanumeric': 0.18149129447388343, 'fraction_numerical': 0.011922785768357305, 'mean_word_length': 4.300902708124373, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5942781', 'n_tokens_mistral': 2100, 'n_tokens_neox': 2001, 'n_words': 494}