You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Chris Lohfink (Created) (JIRA)" <ji...@apache.org> on 2012/02/06 21:09:59 UTC

[jira] [Created] (CASSANDRA-3866) Allow default constructor for seed providers

Allow default constructor for seed providers
--------------------------------------------

                 Key: CASSANDRA-3866
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-3866
             Project: Cassandra
          Issue Type: Improvement
          Components: Core
    Affects Versions: 1.0.7
            Reporter: Chris Lohfink
            Priority: Trivial
         Attachments: DnsSeedProvider.java, patch.txt

Would be nice for cases where you do not have any parameters.  ie if you have a simple custom seed provider.  In that scenario you will not provide a parameters argument to the seed_provider (since using default constructor):

{code}
seed_provider:
    - class_name: foo.bar.DnsSeedProvider
{code}

This causes an exception

{code:java}ERROR 11:57:06,744 Fatal configuration error error 
Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
in "<reader>", line 10, column 1: 
cluster_name: 'Test Cluster' 
^

at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372) 
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136) 
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122) 
at org.yaml.snakeyaml.Loader.load(Loader.java:52) 
at org.yaml.snakeyaml.Yaml.load(Yaml.java:166) 
at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:133) 
at org.apache.cassandra.service.AbstractCassandraDaemon.setup(AbstractCassandraDaemon.java:125) 
at com.datastax.bdp.server.DseDaemon.setup(DseDaemon.java:89) 
at org.apache.cassandra.service.AbstractCassandraDaemon.init(AbstractCassandraDaemon.java:238) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:212) 
Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:305) 
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:184) 
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370) 
... 14 more 
Caused by: org.yaml.snakeyaml.error.YAMLException: java.lang.reflect.InvocationTargetException 
at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:589) 
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:298) 
... 16 more 
Caused by: java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:587) 
... 18 more 
Caused by: java.lang.NullPointerException 
at org.apache.cassandra.config.SeedProviderDef.<init>(SeedProviderDef.java:34) 
... 23 more
{code}

If you then add parameters you get a java.lang.NoSuchMethodException.  The workaround being you create a constructor that takes a Map argument, set the parameters to anything and ignore them, which is fine but then has to be documented as they are options that do not mean anything.  Would be nice to make the parameters optional.  I attached a very simple example and a patch that I think would work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CASSANDRA-3866) Allow default constructor for seed providers

Posted by "Chris Lohfink (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Lohfink updated CASSANDRA-3866:
-------------------------------------

    Attachment: patch.txt
                DnsSeedProvider.java
    
> Allow default constructor for seed providers
> --------------------------------------------
>
>                 Key: CASSANDRA-3866
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-3866
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.0.7
>            Reporter: Chris Lohfink
>            Priority: Trivial
>         Attachments: DnsSeedProvider.java, patch.txt
>
>
> Would be nice for cases where you do not have any parameters.  ie if you have a simple custom seed provider.  In that scenario you will not provide a parameters argument to the seed_provider (since using default constructor):
> {code}
> seed_provider:
>     - class_name: foo.bar.DnsSeedProvider
> {code}
> This causes an exception
> {code:java}ERROR 11:57:06,744 Fatal configuration error error 
> Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
> in "<reader>", line 10, column 1: 
> cluster_name: 'Test Cluster' 
> ^
> at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122) 
> at org.yaml.snakeyaml.Loader.load(Loader.java:52) 
> at org.yaml.snakeyaml.Yaml.load(Yaml.java:166) 
> at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:133) 
> at org.apache.cassandra.service.AbstractCassandraDaemon.setup(AbstractCassandraDaemon.java:125) 
> at com.datastax.bdp.server.DseDaemon.setup(DseDaemon.java:89) 
> at org.apache.cassandra.service.AbstractCassandraDaemon.init(AbstractCassandraDaemon.java:238) 
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> at java.lang.reflect.Method.invoke(Method.java:597) 
> at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:212) 
> Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:305) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:184) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370) 
> ... 14 more 
> Caused by: org.yaml.snakeyaml.error.YAMLException: java.lang.reflect.InvocationTargetException 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:589) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:298) 
> ... 16 more 
> Caused by: java.lang.reflect.InvocationTargetException 
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:587) 
> ... 18 more 
> Caused by: java.lang.NullPointerException 
> at org.apache.cassandra.config.SeedProviderDef.<init>(SeedProviderDef.java:34) 
> ... 23 more
> {code}
> If you then add parameters you get a java.lang.NoSuchMethodException.  The workaround being you create a constructor that takes a Map argument, set the parameters to anything and ignore them, which is fine but then has to be documented as they are options that do not mean anything.  Would be nice to make the parameters optional.  I attached a very simple example and a patch that I think would work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CASSANDRA-3866) Allow default constructor for seed providers

Posted by "Sylvain Lebresne (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202150#comment-13202150 ] 

Sylvain Lebresne commented on CASSANDRA-3866:
---------------------------------------------

Agreed on the principle. On the patch itself, I'd prefer having SeedProviderDef.parameters defaulting to an empty map. Custom providers that don't care about parameters could just ignore the map, but that avoids having to create 2 constructor for each providers (in particular, SimpleSeedProvider doesn't have a default constructor).
                
> Allow default constructor for seed providers
> --------------------------------------------
>
>                 Key: CASSANDRA-3866
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-3866
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.0.7
>            Reporter: Chris Lohfink
>            Priority: Trivial
>         Attachments: DnsSeedProvider.java, patch.txt
>
>
> Would be nice for cases where you do not have any parameters.  ie if you have a simple custom seed provider.  In that scenario you will not provide a parameters argument to the seed_provider (since using default constructor):
> {code}
> seed_provider:
>     - class_name: foo.bar.DnsSeedProvider
> {code}
> This causes an exception
> {code:java}ERROR 11:57:06,744 Fatal configuration error error 
> Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
> in "<reader>", line 10, column 1: 
> cluster_name: 'Test Cluster' 
> ^
> at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122) 
> at org.yaml.snakeyaml.Loader.load(Loader.java:52) 
> at org.yaml.snakeyaml.Yaml.load(Yaml.java:166) 
> at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:133) 
> at org.apache.cassandra.service.AbstractCassandraDaemon.setup(AbstractCassandraDaemon.java:125) 
> at com.datastax.bdp.server.DseDaemon.setup(DseDaemon.java:89) 
> at org.apache.cassandra.service.AbstractCassandraDaemon.init(AbstractCassandraDaemon.java:238) 
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> at java.lang.reflect.Method.invoke(Method.java:597) 
> at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:212) 
> Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; java.lang.reflect.InvocationTargetException 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:305) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:184) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370) 
> ... 14 more 
> Caused by: org.yaml.snakeyaml.error.YAMLException: java.lang.reflect.InvocationTargetException 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:589) 
> at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:298) 
> ... 16 more 
> Caused by: java.lang.reflect.InvocationTargetException 
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
> at org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:587) 
> ... 18 more 
> Caused by: java.lang.NullPointerException 
> at org.apache.cassandra.config.SeedProviderDef.<init>(SeedProviderDef.java:34) 
> ... 23 more
> {code}
> If you then add parameters you get a java.lang.NoSuchMethodException.  The workaround being you create a constructor that takes a Map argument, set the parameters to anything and ignore them, which is fine but then has to be documented as they are options that do not mean anything.  Would be nice to make the parameters optional.  I attached a very simple example and a patch that I think would work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira