I am trying to test out the SimpleAuthority feature and am running
into a problem when I do the write from Hector. I have already made
the changes to the Access/Passwd properties and YAML files. Here is
the error I get in Eclipse:
Exception in thread "main"
me.prettyprint.hector.api.exceptions.HectorException:
AuthenticationException(why:Authentication request was missing the
required key 'username')
at
me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:
58)
at
me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:
230)
Caused by: AuthenticationException(why:Authentication request was
missing the required key 'username')
at org.apache.cassandra.thrift.Cassandra
$login_result.read(Cassandra.java:4217)
at org.apache.cassandra.thrift.Cassandra
$Client.recv_login(Cassandra.java:412)
Looking at HFactory.java it looks like the createKeyspace method
expects the username and password to be passed in as a Map of strings:
public static Keyspace createKeyspace(String keyspace, Cluster
cluster,
ConsistencyLevelPolicy consistencyLevelPolicy,
FailoverPolicy failoverPolicy, Map<String, String> credentials)
{
return new ExecutingKeyspace(keyspace,
cluster.getConnectionManager(),
consistencyLevelPolicy, failoverPolicy, credentials);
}
(from
https://github.com/rantav/hector/blob/master/core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java)
Here is how I'm creating the cluster, Map and keyspace objects:
Cluster cluster = HFactory.getOrCreateCluster("Demo_Cluster_beta1",
"
darknet.compute-1.amazonaws.com:9160");
Map AccessMap = new HashMap();
AccessMap.put("hal", "nodave");
Keyspace keyspace = HFactory.createKeyspace("MDR", cluster, new
AllOneConsistencyLevelPolicy(),
FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE, AccessMap);
I'm guessing my syntax is incorrect...
Any ideas on what I can change in the Map to make this work?
- Sameer
On May 12, 10:22 am, Nate McCall <
n...@datastax.com> wrote:
> HFactory#createKeyspace has an overloaded form that takes a
> "credentials" Map as the last argument.
>
> You can play around with authentication in CQL pretty easily. Take a
> look at the authentication setup in JdbcDriverTest in Cassandra source
> (drivers/java/test folder).
>
> Caveat: if there is no authentication configured on the keyspace, the
> auth parameters in the jdbc url are ignored.
>
> On Thu, May 12, 2011 at 12:07 PM, Sameer Farooqui
>
>
>
>
>
>
>
> <
cassandral...@gmail.com> wrote:
> > I was wondering the same thing.
>
> > Also, if it's not possible in the current version of Hector... has
> > anybody successfully usedSimpleAuthoritywith Cassandra Query