cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <>
Subject [jira] [Updated] (CASSANDRA-7597) Remove static initializer in DatabaseDescriptor
Date Sun, 03 Aug 2014 19:15:12 GMT


Robert Stupp updated CASSANDRA-7597:

    Attachment: 7597.txt

Attached a new patch (against trunk).

First I tried to do explicit initialization from {{CassandraDaemon}}, any relevant executable
class. Then I encountered that many tests would also require explicit initialization. And
this did not cover code that is in use "in the wild".

So I replaced static initialization with lazy initialization.
If some code wants to get an exception, it can call {{DatabaseDescriptor.loadAndApplyConfig()}}.
{{DatabaseDescriptor.loadAndApplyConfigStandalone()}} does not throw an exception but will
log and call {{System.exit(1)}}.

But even this patch is not really cool. Both {{loadAndApplyConfig}} variants can only be called
once because there MBeans created implicitly and the system keyspace is initialized.

The patch is better than nothing, but I'm not sold on this. Any other opinion?

> Remove static initializer in DatabaseDescriptor
> -----------------------------------------------
>                 Key: CASSANDRA-7597
>                 URL:
>             Project: Cassandra
>          Issue Type: Improvement
>         Environment: Cassandra 2.0.9 (earlier version should be affected as well)
>            Reporter: Pavel Sakun
>            Assignee: Robert Stupp
>         Attachments: 7597.txt
> As discussed below, it's difficult to properly react on invalid configuration values
in a client tool that uses cassandra code (here: an sstable loader).
> Reason is that the static initializer in DatabaseDescriptor calls System.exit in case
of configuration failures.
> Recommend to implement some "loadAndApplyConfig" method on DatabaseDescriptor and remove
the static initializer and let the calling code react accordingly (print error, exit VM).
> All direct and indirect uses of DatabaseDescriptor must be catched to solve this ticket
- so this is not a 2.1 ticket.
> --------------------------
> Old Description:
> We're using SSTableSimpleUnsortedWriter API to generate SSTable to be loaded into cassandra.
In case of any issue with config DatabaseDescriptor calls System.exit() which is apparently
not the thing you expect while using API.
> Test case is simple:
> System.setProperty( "cassandra.config", "" );
> new YamlConfigurationLoader().loadConfig();
> Thread.sleep( 5000 );
> System.out.println("We're still alive"); // this will never be called

This message was sent by Atlassian JIRA

View raw message