Permalink
Browse files

- scalarisctl: always provide a full nodename to erlang (including th…

…e domain or IP address)

-> if not given by the user, use "hostname -f"
 -> should be consistent with Java which should not need any quirks anymore
-> allows stopping of nodes started with a full nodename e.g. "scalarisctl -n node@127.0.0.1"
  • Loading branch information...
1 parent 4576f2b commit 5577eac641c2b07c68919992780d5fee3955fcb5 kruber@zib.de committed Oct 7, 2011
Showing with 20 additions and 31 deletions.
  1. +19 −10 bin/scalarisctl.in
  2. +1 −21 java-api/scalaris.in
View
@@ -100,6 +100,13 @@ fix_paths() {
fi
}
+fix_node_name() {
+ # if the given node name includes an '@', leave untouched
+ if ! echo $NODE_NAME | grep "@" >/dev/null ; then
+ NODE_NAME=$NODE_NAME@`hostname -f`
+ fi
+}
+
# only get cookie from scalarisctl.conf if installed!
get_cookie() {
ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
@@ -186,23 +193,23 @@ checkinstallation() {
echo " 'make java' will build the Java-API"
echo "We were trying to run: $SCALARISCLIENT"
else
- ERLANGHOST=`$ERL -noinput -name boot -eval "io:format(\"~p~n\", [node()]), halt(0)."`
+ HOSTNAME=`hostname -f`
JAVAHOST="'boot@`$SCALARISCLIENT -lh`'"
- if [ "$ERLANGHOST" != "$JAVAHOST" ]; then
- echo "WARNING: the hostnames reported by Erlang and Java do not match. You won't be"
- echo " able to connect to erlang using the Java-API through scalaris.jar. Also, the"
+ if [ "$HOSTNAME" != "$JAVAHOST" ]; then
+ echo "WARNING: the hostnames reported by 'hostname -f' and Java do not match. You won't be"
+ echo " able to connect to Scalaris using the Java-API through scalaris.jar. Also, the"
echo " java unit tests will probably not work."
- echo " The java-api/scalaris script will work around this by asking erlang for its"
- echo " hostname and using this for both."
+ echo " The java-api/scalaris script will work around this by using the value provided by"
+ echo " 'hostname -f' and using this for both."
echo " If you implement your own application either do not use \"@localhost\" in the"
echo " scalaris.properties file or set the scalaris.erlang.nodename system property"
echo " with the correct hostname (only the domain name part after the \"@\") or fix"
echo " your hostname setup system-wide."
echo " Please refer to your system's manual to set your hostname, e.g. change the"
echo " values in /etc/hosts or /etc/hostname, and check that it is consistent with"
echo " the DNS."
- echo "erlang: $ERL -noinput -name boot -eval \"io:format(\"~p~n\", [node()]), halt(0).\""
- echo " -> $ERLANGHOST"
+ echo "system: hostname -f"
+ echo " -> $HOSTNAME"
echo "java: $SCALARISCLIENT -lh"
echo " -> $JAVAHOST"
fi
@@ -298,7 +305,7 @@ scalarisstop(){
-name ctl_$RANDOM \
-pa $BEAMDIR \
-noinput \
- -s scalaris cli -extra $NODE_NAME@`hostname -f` stop
+ -s scalaris cli -extra $NODE_NAME stop
popd > /dev/null
}
@@ -308,7 +315,7 @@ list_erlang_processes(){
debug(){
# look into epmd -list: boot or node
- $ERL -pa $BEAMDIR -setcookie "$SCALARIS_COOKIE" -name rem -remsh $NODE_NAME@`hostname -f` $*
+ $ERL -pa $BEAMDIR -setcookie "$SCALARIS_COOKIE" -name rem -remsh $NODE_NAME $*
}
fix_paths
@@ -336,6 +343,8 @@ done
shift $(($OPTIND-1))
+fix_node_name
+
case $1 in
checkinstallation)
checkinstallation;;
View
@@ -109,29 +109,9 @@ if $rpm_mode ; then
fi
fi
-get_erlang_node_name() {
- # test whether erlang is installed
- $ERL -noinput -eval 'halt(0).' > /dev/null 2>/dev/null
- FAILED=$?
- if [ $FAILED -eq 0 ]; then
- # if erlang is available, get the domain part erlang uses for local nodes
- NODE_NAME=""
- COUNT=0
- while [ -z "$NODE_NAME" ]; do
- COUNT=$(($COUNT+1))
- NODE_NAME_FULL=`$ERL -noinput -name "scalaris-java-api-$COUNT" -eval 'io:format("~s~n", [node()]), halt().'`
- FAILED=$?
- if [ $FAILED -eq 0 ]; then
- NODE_NAME=`echo "$NODE_NAME_FULL" | cut -d '@' -f 2`
- fi
- echo -n $NODE_NAME
- done
- fi
-}
-
# Get local host name from erlang
if ! $no_erl; then
- ERLANG_NODE_NAME="`get_erlang_node_name`"
+ ERLANG_NODE_NAME="`hostname -f`"
fi
# OS specific support. $var _must_ be set to either true or false.

0 comments on commit 5577eac

Please sign in to comment.