You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Peng Guo <gp...@gmail.com> on 2010/05/21 04:39:09 UTC

Can't stop org.apache.cassandra.service.StorageService.stopClient()

Hi All

This is my test code:
    public static void main(String[] args) throws IOException,
InterruptedException {
        System.setProperty("storage-config",
"D:\\apache-cassandra-0.6.1\\conf");

        StorageService.instance.initClient();

        StorageService.instance.stopClient();
    }

I find when I run this code, the process can't stop.

for I use the jstack look at this process, I find the CONSISTENCY-MANAGER
thread is still running.

So I modify the code in StorageService.java  like this:

    public void stopClient()
    {
        Gossiper.instance.unregister(this);
        Gossiper.instance.stop();
        MessagingService.shutdown();
        StageManager.shutdownNow();

        // this is added to stop the CONSISTENCY-MANAGER thread
        consistencyManager_.shutdownNow();
    }

Can I commit this code in to svn branch?

Thanks.

-- 
Regards
   Peng Guo

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Jonathan Ellis <jb...@gmail.com>.
http://dslab.epfl.ch/pubs/crashonly/crashonly.pdf

On Fri, May 21, 2010 at 7:15 AM, Peng Guo <gp...@gmail.com> wrote:
> I'm don't understand what is Cassandra's crash-only design.
>
> Could you explain that?
>
> Thanks.
>
> On Fri, May 21, 2010 at 8:35 PM, Gary Dusbabek <gd...@gmail.com> wrote:
>
>> Peng,
>>
>> I think you'll find that there are several threads in Cassandra that
>> have no mechanisms for exiting cleanly.  This is part of Cassandra's
>> crash-only design.
>>
>> If you'd like to spend time figuring out how to shutdown Cassandra
>> cleanly, that would be great.  It would simplify the way we write
>> tests and make Cassandra more embeddable.  But we still want to keep
>> Cassandra crash-only.
>>
>> Gary.
>>
>>
>> On Fri, May 21, 2010 at 01:33, Peng Guo <gp...@gmail.com> wrote:
>> > Hi
>> >
>> > I find there still something need to do:
>> >
>> > Modity the  Gossiper.java code like this:
>> >
>> >    public void start(InetAddress localEndPoint, int generationNbr)
>> >    {
>> >        localEndPoint_ = localEndPoint;
>> >        /* Get the seeds from the config and initialize them. */
>> >        Set<InetAddress> seedHosts = DatabaseDescriptor.getSeeds();
>> >        for (InetAddress seed : seedHosts)
>> >        {
>> >            if (seed.equals(localEndPoint))
>> >                continue;
>> >            seeds_.add(seed);
>> >        }
>> >
>> >        /* initialize the heartbeat state for this localEndPoint */
>> >        EndPointState localState = endPointStateMap_.get(localEndPoint_);
>> >        if ( localState == null )
>> >        {
>> >            HeartBeatState hbState = new HeartBeatState(generationNbr);
>> >            localState = new EndPointState(hbState);
>> >            localState.isAlive(true);
>> >            localState.isAGossiper(true);
>> >            endPointStateMap_.put(localEndPoint_, localState);
>> >        }
>> >
>> >        /* starts a timer thread */
>> >        if (gossipTimer_ == null) {
>> >            gossipTimer_ = new Timer(false); // makes the Gossiper
>> > reentrant.
>> >        }
>> >        gossipTimer_.schedule( new GossipTimerTask(),
>> > Gossiper.intervalInMillis_, Gossiper.intervalInMillis_);
>> >    }
>> >
>> > and
>> >
>> >    public void stop()
>> >    {
>> >        gossipTimer_.cancel();
>> >        gossipTimer_ = null;
>> >    }
>> >
>> > I don't know how to commit the patch, so I will learning it:)
>> >
>> >
>> > On Fri, May 21, 2010 at 11:50 AM, Jonathan Ellis <jb...@gmail.com>
>> wrote:
>> >
>> >> Can you submit a patch to
>> https://issues.apache.org/jira/browse/CASSANDRA?
>> >>
>> >> Thanks!
>> >>
>> >> On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
>> >> > Hi All
>> >> >
>> >> > This is my test code:
>> >> >    public static void main(String[] args) throws IOException,
>> >> > InterruptedException {
>> >> >        System.setProperty("storage-config",
>> >> > "D:\\apache-cassandra-0.6.1\\conf");
>> >> >
>> >> >        StorageService.instance.initClient();
>> >> >
>> >> >        StorageService.instance.stopClient();
>> >> >    }
>> >> >
>> >> > I find when I run this code, the process can't stop.
>> >> >
>> >> > for I use the jstack look at this process, I find the
>> CONSISTENCY-MANAGER
>> >> > thread is still running.
>> >> >
>> >> > So I modify the code in StorageService.java  like this:
>> >> >
>> >> >    public void stopClient()
>> >> >    {
>> >> >        Gossiper.instance.unregister(this);
>> >> >        Gossiper.instance.stop();
>> >> >        MessagingService.shutdown();
>> >> >        StageManager.shutdownNow();
>> >> >
>> >> >        // this is added to stop the CONSISTENCY-MANAGER thread
>> >> >        consistencyManager_.shutdownNow();
>> >> >    }
>> >> >
>> >> > Can I commit this code in to svn branch?
>> >> >
>> >> > Thanks.
>> >> >
>> >> > --
>> >> > Regards
>> >> >   Peng Guo
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Jonathan Ellis
>> >> Project Chair, Apache Cassandra
>> >> co-founder of Riptano, the source for professional Cassandra support
>> >> http://riptano.com
>> >>
>> >
>> >
>> >
>> > --
>> > Regards
>> >   Peng Guo
>> >
>>
>
>
>
> --
> Regards
>   Peng Guo
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Peng Guo <gp...@gmail.com>.
I'm don't understand what is Cassandra's crash-only design.

Could you explain that?

Thanks.

On Fri, May 21, 2010 at 8:35 PM, Gary Dusbabek <gd...@gmail.com> wrote:

> Peng,
>
> I think you'll find that there are several threads in Cassandra that
> have no mechanisms for exiting cleanly.  This is part of Cassandra's
> crash-only design.
>
> If you'd like to spend time figuring out how to shutdown Cassandra
> cleanly, that would be great.  It would simplify the way we write
> tests and make Cassandra more embeddable.  But we still want to keep
> Cassandra crash-only.
>
> Gary.
>
>
> On Fri, May 21, 2010 at 01:33, Peng Guo <gp...@gmail.com> wrote:
> > Hi
> >
> > I find there still something need to do:
> >
> > Modity the  Gossiper.java code like this:
> >
> >    public void start(InetAddress localEndPoint, int generationNbr)
> >    {
> >        localEndPoint_ = localEndPoint;
> >        /* Get the seeds from the config and initialize them. */
> >        Set<InetAddress> seedHosts = DatabaseDescriptor.getSeeds();
> >        for (InetAddress seed : seedHosts)
> >        {
> >            if (seed.equals(localEndPoint))
> >                continue;
> >            seeds_.add(seed);
> >        }
> >
> >        /* initialize the heartbeat state for this localEndPoint */
> >        EndPointState localState = endPointStateMap_.get(localEndPoint_);
> >        if ( localState == null )
> >        {
> >            HeartBeatState hbState = new HeartBeatState(generationNbr);
> >            localState = new EndPointState(hbState);
> >            localState.isAlive(true);
> >            localState.isAGossiper(true);
> >            endPointStateMap_.put(localEndPoint_, localState);
> >        }
> >
> >        /* starts a timer thread */
> >        if (gossipTimer_ == null) {
> >            gossipTimer_ = new Timer(false); // makes the Gossiper
> > reentrant.
> >        }
> >        gossipTimer_.schedule( new GossipTimerTask(),
> > Gossiper.intervalInMillis_, Gossiper.intervalInMillis_);
> >    }
> >
> > and
> >
> >    public void stop()
> >    {
> >        gossipTimer_.cancel();
> >        gossipTimer_ = null;
> >    }
> >
> > I don't know how to commit the patch, so I will learning it:)
> >
> >
> > On Fri, May 21, 2010 at 11:50 AM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >
> >> Can you submit a patch to
> https://issues.apache.org/jira/browse/CASSANDRA?
> >>
> >> Thanks!
> >>
> >> On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
> >> > Hi All
> >> >
> >> > This is my test code:
> >> >    public static void main(String[] args) throws IOException,
> >> > InterruptedException {
> >> >        System.setProperty("storage-config",
> >> > "D:\\apache-cassandra-0.6.1\\conf");
> >> >
> >> >        StorageService.instance.initClient();
> >> >
> >> >        StorageService.instance.stopClient();
> >> >    }
> >> >
> >> > I find when I run this code, the process can't stop.
> >> >
> >> > for I use the jstack look at this process, I find the
> CONSISTENCY-MANAGER
> >> > thread is still running.
> >> >
> >> > So I modify the code in StorageService.java  like this:
> >> >
> >> >    public void stopClient()
> >> >    {
> >> >        Gossiper.instance.unregister(this);
> >> >        Gossiper.instance.stop();
> >> >        MessagingService.shutdown();
> >> >        StageManager.shutdownNow();
> >> >
> >> >        // this is added to stop the CONSISTENCY-MANAGER thread
> >> >        consistencyManager_.shutdownNow();
> >> >    }
> >> >
> >> > Can I commit this code in to svn branch?
> >> >
> >> > Thanks.
> >> >
> >> > --
> >> > Regards
> >> >   Peng Guo
> >> >
> >>
> >>
> >>
> >> --
> >> Jonathan Ellis
> >> Project Chair, Apache Cassandra
> >> co-founder of Riptano, the source for professional Cassandra support
> >> http://riptano.com
> >>
> >
> >
> >
> > --
> > Regards
> >   Peng Guo
> >
>



-- 
Regards
   Peng Guo

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Gary Dusbabek <gd...@gmail.com>.
Peng,

I think you'll find that there are several threads in Cassandra that
have no mechanisms for exiting cleanly.  This is part of Cassandra's
crash-only design.

If you'd like to spend time figuring out how to shutdown Cassandra
cleanly, that would be great.  It would simplify the way we write
tests and make Cassandra more embeddable.  But we still want to keep
Cassandra crash-only.

Gary.


On Fri, May 21, 2010 at 01:33, Peng Guo <gp...@gmail.com> wrote:
> Hi
>
> I find there still something need to do:
>
> Modity the  Gossiper.java code like this:
>
>    public void start(InetAddress localEndPoint, int generationNbr)
>    {
>        localEndPoint_ = localEndPoint;
>        /* Get the seeds from the config and initialize them. */
>        Set<InetAddress> seedHosts = DatabaseDescriptor.getSeeds();
>        for (InetAddress seed : seedHosts)
>        {
>            if (seed.equals(localEndPoint))
>                continue;
>            seeds_.add(seed);
>        }
>
>        /* initialize the heartbeat state for this localEndPoint */
>        EndPointState localState = endPointStateMap_.get(localEndPoint_);
>        if ( localState == null )
>        {
>            HeartBeatState hbState = new HeartBeatState(generationNbr);
>            localState = new EndPointState(hbState);
>            localState.isAlive(true);
>            localState.isAGossiper(true);
>            endPointStateMap_.put(localEndPoint_, localState);
>        }
>
>        /* starts a timer thread */
>        if (gossipTimer_ == null) {
>            gossipTimer_ = new Timer(false); // makes the Gossiper
> reentrant.
>        }
>        gossipTimer_.schedule( new GossipTimerTask(),
> Gossiper.intervalInMillis_, Gossiper.intervalInMillis_);
>    }
>
> and
>
>    public void stop()
>    {
>        gossipTimer_.cancel();
>        gossipTimer_ = null;
>    }
>
> I don't know how to commit the patch, so I will learning it:)
>
>
> On Fri, May 21, 2010 at 11:50 AM, Jonathan Ellis <jb...@gmail.com> wrote:
>
>> Can you submit a patch to https://issues.apache.org/jira/browse/CASSANDRA?
>>
>> Thanks!
>>
>> On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
>> > Hi All
>> >
>> > This is my test code:
>> >    public static void main(String[] args) throws IOException,
>> > InterruptedException {
>> >        System.setProperty("storage-config",
>> > "D:\\apache-cassandra-0.6.1\\conf");
>> >
>> >        StorageService.instance.initClient();
>> >
>> >        StorageService.instance.stopClient();
>> >    }
>> >
>> > I find when I run this code, the process can't stop.
>> >
>> > for I use the jstack look at this process, I find the CONSISTENCY-MANAGER
>> > thread is still running.
>> >
>> > So I modify the code in StorageService.java  like this:
>> >
>> >    public void stopClient()
>> >    {
>> >        Gossiper.instance.unregister(this);
>> >        Gossiper.instance.stop();
>> >        MessagingService.shutdown();
>> >        StageManager.shutdownNow();
>> >
>> >        // this is added to stop the CONSISTENCY-MANAGER thread
>> >        consistencyManager_.shutdownNow();
>> >    }
>> >
>> > Can I commit this code in to svn branch?
>> >
>> > Thanks.
>> >
>> > --
>> > Regards
>> >   Peng Guo
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> Project Chair, Apache Cassandra
>> co-founder of Riptano, the source for professional Cassandra support
>> http://riptano.com
>>
>
>
>
> --
> Regards
>   Peng Guo
>

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Jonathan Ellis <jb...@gmail.com>.
http://wiki.apache.org/cassandra/HowToContribute

On Thu, May 20, 2010 at 11:33 PM, Peng Guo <gp...@gmail.com> wrote:
> Hi
>
> I find there still something need to do:
>
> Modity the  Gossiper.java code like this:
>
>    public void start(InetAddress localEndPoint, int generationNbr)
>    {
>        localEndPoint_ = localEndPoint;
>        /* Get the seeds from the config and initialize them. */
>        Set<InetAddress> seedHosts = DatabaseDescriptor.getSeeds();
>        for (InetAddress seed : seedHosts)
>        {
>            if (seed.equals(localEndPoint))
>                continue;
>            seeds_.add(seed);
>        }
>
>        /* initialize the heartbeat state for this localEndPoint */
>        EndPointState localState = endPointStateMap_.get(localEndPoint_);
>        if ( localState == null )
>        {
>            HeartBeatState hbState = new HeartBeatState(generationNbr);
>            localState = new EndPointState(hbState);
>            localState.isAlive(true);
>            localState.isAGossiper(true);
>            endPointStateMap_.put(localEndPoint_, localState);
>        }
>
>        /* starts a timer thread */
>        if (gossipTimer_ == null) {
>            gossipTimer_ = new Timer(false); // makes the Gossiper
> reentrant.
>        }
>        gossipTimer_.schedule( new GossipTimerTask(),
> Gossiper.intervalInMillis_, Gossiper.intervalInMillis_);
>    }
>
> and
>
>    public void stop()
>    {
>        gossipTimer_.cancel();
>        gossipTimer_ = null;
>    }
>
> I don't know how to commit the patch, so I will learning it:)
>
>
> On Fri, May 21, 2010 at 11:50 AM, Jonathan Ellis <jb...@gmail.com> wrote:
>
>> Can you submit a patch to https://issues.apache.org/jira/browse/CASSANDRA?
>>
>> Thanks!
>>
>> On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
>> > Hi All
>> >
>> > This is my test code:
>> >    public static void main(String[] args) throws IOException,
>> > InterruptedException {
>> >        System.setProperty("storage-config",
>> > "D:\\apache-cassandra-0.6.1\\conf");
>> >
>> >        StorageService.instance.initClient();
>> >
>> >        StorageService.instance.stopClient();
>> >    }
>> >
>> > I find when I run this code, the process can't stop.
>> >
>> > for I use the jstack look at this process, I find the CONSISTENCY-MANAGER
>> > thread is still running.
>> >
>> > So I modify the code in StorageService.java  like this:
>> >
>> >    public void stopClient()
>> >    {
>> >        Gossiper.instance.unregister(this);
>> >        Gossiper.instance.stop();
>> >        MessagingService.shutdown();
>> >        StageManager.shutdownNow();
>> >
>> >        // this is added to stop the CONSISTENCY-MANAGER thread
>> >        consistencyManager_.shutdownNow();
>> >    }
>> >
>> > Can I commit this code in to svn branch?
>> >
>> > Thanks.
>> >
>> > --
>> > Regards
>> >   Peng Guo
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> Project Chair, Apache Cassandra
>> co-founder of Riptano, the source for professional Cassandra support
>> http://riptano.com
>>
>
>
>
> --
> Regards
>   Peng Guo
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Peng Guo <gp...@gmail.com>.
Hi

I find there still something need to do:

Modity the  Gossiper.java code like this:

    public void start(InetAddress localEndPoint, int generationNbr)
    {
        localEndPoint_ = localEndPoint;
        /* Get the seeds from the config and initialize them. */
        Set<InetAddress> seedHosts = DatabaseDescriptor.getSeeds();
        for (InetAddress seed : seedHosts)
        {
            if (seed.equals(localEndPoint))
                continue;
            seeds_.add(seed);
        }

        /* initialize the heartbeat state for this localEndPoint */
        EndPointState localState = endPointStateMap_.get(localEndPoint_);
        if ( localState == null )
        {
            HeartBeatState hbState = new HeartBeatState(generationNbr);
            localState = new EndPointState(hbState);
            localState.isAlive(true);
            localState.isAGossiper(true);
            endPointStateMap_.put(localEndPoint_, localState);
        }

        /* starts a timer thread */
        if (gossipTimer_ == null) {
            gossipTimer_ = new Timer(false); // makes the Gossiper
reentrant.
        }
        gossipTimer_.schedule( new GossipTimerTask(),
Gossiper.intervalInMillis_, Gossiper.intervalInMillis_);
    }

and

    public void stop()
    {
        gossipTimer_.cancel();
        gossipTimer_ = null;
    }

I don't know how to commit the patch, so I will learning it:)


On Fri, May 21, 2010 at 11:50 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> Can you submit a patch to https://issues.apache.org/jira/browse/CASSANDRA?
>
> Thanks!
>
> On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
> > Hi All
> >
> > This is my test code:
> >    public static void main(String[] args) throws IOException,
> > InterruptedException {
> >        System.setProperty("storage-config",
> > "D:\\apache-cassandra-0.6.1\\conf");
> >
> >        StorageService.instance.initClient();
> >
> >        StorageService.instance.stopClient();
> >    }
> >
> > I find when I run this code, the process can't stop.
> >
> > for I use the jstack look at this process, I find the CONSISTENCY-MANAGER
> > thread is still running.
> >
> > So I modify the code in StorageService.java  like this:
> >
> >    public void stopClient()
> >    {
> >        Gossiper.instance.unregister(this);
> >        Gossiper.instance.stop();
> >        MessagingService.shutdown();
> >        StageManager.shutdownNow();
> >
> >        // this is added to stop the CONSISTENCY-MANAGER thread
> >        consistencyManager_.shutdownNow();
> >    }
> >
> > Can I commit this code in to svn branch?
> >
> > Thanks.
> >
> > --
> > Regards
> >   Peng Guo
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of Riptano, the source for professional Cassandra support
> http://riptano.com
>



-- 
Regards
   Peng Guo

Re: Can't stop org.apache.cassandra.service.StorageService.stopClient()

Posted by Jonathan Ellis <jb...@gmail.com>.
Can you submit a patch to https://issues.apache.org/jira/browse/CASSANDRA ?

Thanks!

On Thu, May 20, 2010 at 7:39 PM, Peng Guo <gp...@gmail.com> wrote:
> Hi All
>
> This is my test code:
>    public static void main(String[] args) throws IOException,
> InterruptedException {
>        System.setProperty("storage-config",
> "D:\\apache-cassandra-0.6.1\\conf");
>
>        StorageService.instance.initClient();
>
>        StorageService.instance.stopClient();
>    }
>
> I find when I run this code, the process can't stop.
>
> for I use the jstack look at this process, I find the CONSISTENCY-MANAGER
> thread is still running.
>
> So I modify the code in StorageService.java  like this:
>
>    public void stopClient()
>    {
>        Gossiper.instance.unregister(this);
>        Gossiper.instance.stop();
>        MessagingService.shutdown();
>        StageManager.shutdownNow();
>
>        // this is added to stop the CONSISTENCY-MANAGER thread
>        consistencyManager_.shutdownNow();
>    }
>
> Can I commit this code in to svn branch?
>
> Thanks.
>
> --
> Regards
>   Peng Guo
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com