Unclean shutdown, I mean really clean.

11 views
Skip to first unread message

Harold A

unread,
May 19, 2011, 3:57:14 AM5/19/11
to hector-users
Hi,

I've got the following working. However, it seems clean and orderly
shutdown is not possible even after calling 'shutdownCluster'. I can
see from my console 'Should exit!?!?!?', there must be some thread
still hanging out there: maybe stuck in an infinite loop or 'wait' not
being interrupted ...


## -- SOURCE CODE: BEGIN --##
public class Main {

/**
* @param args
*/
public static void main(String[] args) {
CassandraHostConfigurator cassandraHostConfigurator = new
CassandraHostConfigurator("192.168.65.254:9160");
cassandraHostConfigurator.setMaxActive(20);
cassandraHostConfigurator.setMaxIdle(5);
cassandraHostConfigurator.setCassandraThriftSocketTimeout(3000);
cassandraHostConfigurator.setMaxWaitTimeWhenExhausted(4000);

ThriftCluster cluster = new ThriftCluster("Cluster1",
cassandraHostConfigurator);

Keyspace keyspace = HFactory.createKeyspace("Twissandra", cluster);
Serializer<String> stringSerializer = StringSerializer.get();

Mutator<String> mutator = HFactory.createMutator(keyspace,
stringSerializer);
mutator.insert("cassandra", "User",
HFactory.createStringColumn("first", "Cassandra"));

HFactory.shutdownCluster(cluster);

System.out.println("Should exit!?!?!?");
}


}

##-- SOURCE CODE: END --#

harold alcala

unread,
May 19, 2011, 4:12:58 AM5/19/11
to hector-users
Ok, confirmed, it's not really shutting down.

I just added another insert statement after calling the shutdownCluster and it was able to add records -- exception or anything.

Patricio Echagüe

unread,
May 19, 2011, 10:18:34 AM5/19/11
to hector...@googlegroups.com

can you try to create the cluster with HFactory.getOrCreateCluster() instead.

Sent from my Android

Cody

unread,
May 21, 2011, 4:39:20 PM5/21/11
to hector-users
I can confirm this issue as well. The JVM just hangs after execution
and debug shows a thread created after the insert just sitting there.

Mine was created with the HFactory.getOrCreateCluster

https://gist.github.com/984873

Using hector-core-0.8.0-1-20110518.221009-14 and cassandra 0.8rc1


On May 19, 8:18 am, Patricio Echagüe <patric...@gmail.com> wrote:
> can you try to create the cluster with HFactory.getOrCreateCluster()
> instead.
>
> Sent from my Android
> On May 19, 2011 1:12 AM, "harold alcala" <harold....@gmail.com> wrote:> Ok, confirmed, it's not really shutting down.
>
> > I just added another insert statement after calling the shutdownCluster
> and
> > it was able to add records -- exception or anything.
>
> > And perhaps this may correct the response to this thread
>
> http://groups.google.com/group/hector-users/browse_thread/thread/9979...
>
>
>
>
>
>
>
> > shutting down properly.

Nate McCall

unread,
May 21, 2011, 6:10:57 PM5/21/11
to hector...@googlegroups.com
You need to add a System.exit() clause in a self managed program like
this. We used to have shutdown hooks registered with the JVM for the
background tasks, but they were causing memory leaks in permgen for
containers like Tomcat because the shutdown hooks prevented the
classes from being cleaned up when a webapp was reloaded.
Reply all
Reply to author
Forward
0 new messages