Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B7E1E7ABD for ; Thu, 25 Aug 2011 15:14:28 +0000 (UTC) Received: (qmail 94545 invoked by uid 500); 25 Aug 2011 15:14:26 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 94403 invoked by uid 500); 25 Aug 2011 15:14:25 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 94384 invoked by uid 99); 25 Aug 2011 15:14:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Aug 2011 15:14:25 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.172] (HELO mail-wy0-f172.google.com) (74.125.82.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Aug 2011 15:14:18 +0000 Received: by wyg8 with SMTP id 8so2004187wyg.31 for ; Thu, 25 Aug 2011 08:13:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.138.88 with SMTP id z66mr734843wei.92.1314285237550; Thu, 25 Aug 2011 08:13:57 -0700 (PDT) Received: by 10.216.93.147 with HTTP; Thu, 25 Aug 2011 08:13:57 -0700 (PDT) X-Originating-IP: [96.10.173.94] In-Reply-To: References: Date: Thu, 25 Aug 2011 11:13:57 -0400 Message-ID: Subject: Re: question about cassandra.in.sh From: Koert Kuipers To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=0016e6de1528b7bda304ab55e0aa X-Virus-Checked: Checked by ClamAV on apache.org --0016e6de1528b7bda304ab55e0aa Content-Type: text/plain; charset=ISO-8859-1 hey eric, the one thing i do not agree that it is the element of least surprise. i would argue that the default behavior for *nix appplications is that they find out what their home directory is and operate relative to that. something like: script_dir="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")" home_dir=${script_dir%/bin} or production quality code from hadoop-config.sh which is sourced by the main hadoop script: this="${BASH_SOURCE-$0}" bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P) script="$(basename -- "$this")" this="$bin/$script" # the root of the Hadoop installation if [ -z "$HADOOP_HOME" ]; then export HADOOP_HOME=`dirname "$this"`/.. fi i find setting a variable in your shell like CASSANDRA_INCLUDE to be error prone. at some point i will forget what i set it to and them i am by accident using the wrong application. once applications are aware of their home dir all i have to do is "ln -s /usr/lib/cassandra-0.7/bin/nodetool /usr/sbin/nodetool-0.7" and then i can use it without risk of confusion. best, koert On Wed, Aug 24, 2011 at 9:48 PM, Eric Evans wrote: > On Wed, Aug 24, 2011 at 1:28 PM, Koert Kuipers wrote: > > my problem is that the scripts for my cassandra 0.7 instance don't work > > properly. the problem lies in the code snippets below. when i run the > > scripts they source /usr/share/cassandra/cassandra.in.sh, which has the > > wrong settings (it now loads all the jars from > > /usr/share/brisk/cassandra/lib). i know i can fix it by settings > > CASSANDRA_INCLUDE but i think thats not a very nice solution. > > > > why was the decision made that the central "casssandra.in.sh" should > have > > higher priority than the local one? doesn't that break local installs? > > It was considered the element of least surprise. If it exists in > /usr/share/cassandra then Cassandra's been "installed", and in the > absence of any other data, that's probably what should be used. If > it's a local copy *and* there's a copy installed in > /usr/share/cassandra, it's probably the owner of the local copy that > needs to know what they are doing and intervene with > CASSANDRA_INCLUDE. > > > wouldnt it make more sense if scripts assumed they were in SOMEDIR/bin > and > > then tried to load casssandra.in.sh from SOMEDIR first with the highest > > priority? > > I don't think so, but then I was the one that reasoned out the current > search order, so YMMV. :) > > > code snippet: > > if [ "x$CASSANDRA_INCLUDE" = "x" ]; then > > # Locations (in order) to use when searching for an include file. > > for include in /usr/share/cassandra/cassandra.in.sh \ > > /usr/local/share/cassandra/cassandra.in.sh \ > > /opt/cassandra/cassandra.in.sh \ > > ~/.cassandra.in.sh \ > > `dirname $0`/cassandra.in.sh; do > > if [ -r $include ]; then > > . $include > > break > > fi > > done > > > > -- > Eric Evans > Acunu | http://www.acunu.com | @acunu > --0016e6de1528b7bda304ab55e0aa Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable hey eric, the one thing i do not agree that it is the element of least surp= rise. i would argue that the default behavior for *nix appplications is tha= t they find out what their home directory is and operate relative to that. = something like:

script_dir=3D"$(dirname "$(readlink -f ${BASH_SOURCE[0]})&quo= t;)"
home_dir=3D${script_dir%/bin}

or production quality cod= e from hadoop-config.sh which is sourced by the main hadoop script:
this= =3D"${BASH_SOURCE-$0}"
bin=3D$(cd -P -- "$(dirname -- "$this")" && pwd= -P)
script=3D"$(basename -- "$this")"
this=3D&qu= ot;$bin/$script"
# the root of the Hadoop installation
if [ -z &= quot;$HADOOP_HOME" ]; then
=A0 export HADOOP_HOME=3D`dirname "$this"`/..
fi

i find= setting a variable in your shell like CASSANDRA_INCLUDE to be error prone.= at some point i will forget what i set it to and them i am by accident usi= ng the wrong application. once applications are aware of their home dir all= i have to do is "ln -s /usr/lib/cassandra-0.7/bin/nodetool /usr/sbin/= nodetool-0.7" and then i can use it without risk of confusion.

best, koert

On Wed, Aug 24, 2011 at 9= :48 PM, Eric Evans <eevans@acunu.com> wrote:
On Wed, Aug 24, 2011 at 1:28 PM, Koert Kuipers <koert@tresata.com> wrote:
> my problem is that the scripts for my cassandra 0.7 instance don't= work
> properly. the problem lies in the code snippets below. when i run the<= br> > scripts they source /usr/share/cassandra/cassandra.in.sh, which has the
> wrong settings (it now loads all the jars from
> /usr/share/brisk/cassandra/lib). i know i can fix it by settings
> CASSANDRA_INCLUDE but i think thats not a very nice solution.
>
> why was the decision made that the central "casssandra.in.sh" should have
> higher priority than the local one? doesn't that break local insta= lls?

It was considered the element of least surprise. =A0If it exists in /usr/share/cassandra then Cassandra's been "installed", and i= n the
absence of any other data, that's probably what should be used. =A0If it's a local copy *and* there's a copy installed in
/usr/share/cassandra, it's probably the owner of the local copy that needs to know what they are doing and intervene with
CASSANDRA_INCLUDE.

> wouldnt it make more sense if scripts assumed they were in SOMEDIR/bin= and
> then tried to load casssandra.in.sh from SOMEDIR first with the highest
> priority?

I don't think so, but then I was the one that reasoned out the cu= rrent
search order, so YMMV. :)

> code snippet:
> if [ "x$CASSANDRA_INCLUDE" =3D "x" ]; then
> =A0=A0=A0 # Locations (in order) to use when searching for an include = file.
> =A0=A0=A0 for include in /usr/share/cassandra/cassandra.in.sh \
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /usr/local/shar= e/cassandra/cassandra.= in.sh \
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /opt/cassandra/= cassandra.in.sh \<= br> > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ~/.cassandra.in.sh \
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 `dirname $0`/cassandra.in.sh; do<= br> > =A0=A0=A0=A0=A0=A0=A0 if [ -r $include ]; then
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 . $include
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break
> =A0=A0=A0=A0=A0=A0=A0 fi
> =A0=A0=A0 done
>

--
Eric Evans
Acunu |=A0http://www.acu= nu.com=A0| @acunu

--0016e6de1528b7bda304ab55e0aa--