You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by indika kumara <in...@apache.org> on 2011/01/30 17:21:25 UTC

In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Hi All,

I observed the behavior indicated in the subject of this email even the
‘default User’ returned from authentication is null.  Is this correct?

Thanks,

Indika

Re: In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Posted by indika kumara <in...@gmail.com>.
Aaron, thanks again for your help.

In the first step, the user add the keyspace 'foo'. In the server side, it
is modified prefixing the user's domain name if there is one. So after that,
there is no keyspace with name 'foo' but 'bar.com_foo'. The client is not
aware of this and he still refers it with 'foo'.

The prefixing the keyspace name with the tenant's namespace is in the 'idea
under consideration' [http://wiki.apache.org/cassandra/MultiTenant].

Thanks,

Indika

On Mon, Jan 31, 2011 at 1:21 PM, aaron morton <aa...@thelastpickle.com>wrote:

> I'm having trouble understanding the steps you've described in step 1.
>
> The error is raised because the Keyspace must exist in the system meta
> data. It's used as the container to find the CF definition, and as part of
> the Resource description when the request is Authorized .
>
> Hope that helps.
> Aaron
>
> On 31 Jan 2011, at 17:39, indika kumara wrote:
>
> Hi Aaron,
>
> Thank a lot for your help.
>
> I have still some questions to get clarified.. The issue happens in the
> following scenario.
>
> 1) Call add keyspace from a client API -The keyspace given by the client is
> modified and used for further operations.
>    e.g  Client's keysace = 'foo' and the his domain name = 'bar.com'  =>
> modified keyspace = 'bar.com_foo'
> 2) Call add column family from a a client API
>    Client's keyspace = 'foo' ...now prior to calling 'login',
> 'set_keyspace' is called. Within that method, the following method is
> called. This throws an error because the keyspace Cassadara kept is
> 'bar.com_foo' not 'foo'
>
>    public static void validateTable(String tablename) throws
> KeyspaceNotDefinedException
>     {
>         if (!DatabaseDescriptor.getTables().contains(tablename))
>         {
>             throw new KeyspaceNotDefinedException("Keyspace " + tablename +
> " does not exist");
>         }
>     }
>
> Thanks,
>
> Indika
>
>
> On Mon, Jan 31, 2011 at 1:58 AM, Aaron Morton <aa...@thelastpickle.com>wrote:
>
>> AFAIK The order of calling login() and set_keyspace() is not important.
>>
>> set_keyspace() just stores the keyspace in the ClientState on the
>> connection thread, and  login authenticates the user name and password and
>> stores them in the ClientState. Functions on CassandraServer that require
>> authorisation call functions such as ClientState.hasColumnFamilyAccess()
>> where things are checked.
>>
>> If you wanted to set the keyspace based on the login, you could do it in
>> the login() function on the ClientState. Then your client would not need to
>> call set_keyspace() . The keyspace has to exist though, it's used it lots of
>> places to identify the CF
>>
>> Hope that helps.
>> Aaron
>>
>>
>> On 31 Jan, 2011,at 07:18 AM, indika kumara <in...@gmail.com> wrote:
>>
>> This issue came when I was trying to implement an idea listed at [
>> http://wiki.apache.org/cassandra/MultiTenant] – Namespaces. I thought the
>> namespace can be the tenant’s domain name provided though username (e.g.
>> foo@bar.com) or can be returned through authentication backend on login.
>> For both cases, calling ‘login’ prior to ‘set_keyspace’ is required.
>>
>> The ‘CassandraServer.java’’s ‘set_keyspace()’ checks the availability of a
>> given keyspace. Here, prior to pass the keyspace, it has to be modified.
>> Any solutions? I would like to create a JIRA for the idea with a working
>> patch.
>>
>> Highly appreciate the suggestions for implementing the aforementioned idea
>> listed in the wiki.
>>
>> Thanks,
>>
>> Indika
>>
>> On Sun, Jan 30, 2011 at 10:21 PM, indika kumara <in...@apache.org>wrote:
>>
>>> Hi All,
>>>
>>> I observed the behavior indicated in the subject of this email even the
>>> ‘default User’ returned from authentication is null.  Is this correct?
>>>
>>> Thanks,
>>>
>>> Indika
>>>
>>
>>
>
>

Re: In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Posted by aaron morton <aa...@thelastpickle.com>.
I'm having trouble understanding the steps you've described in step 1. 

The error is raised because the Keyspace must exist in the system meta data. It's used as the container to find the CF definition, and as part of the Resource description when the request is Authorized .  
 
Hope that helps.
Aaron

On 31 Jan 2011, at 17:39, indika kumara wrote:

> Hi Aaron,
> 
> Thank a lot for your help. 
> 
> I have still some questions to get clarified.. The issue happens in the following scenario.
> 
> 1) Call add keyspace from a client API -The keyspace given by the client is modified and used for further operations. 
>    e.g  Client's keysace = 'foo' and the his domain name = 'bar.com'  => modified keyspace = 'bar.com_foo'
> 2) Call add column family from a a client API
>    Client's keyspace = 'foo' ...now prior to calling 'login', 'set_keyspace' is called. Within that method, the following method is called. This throws an error because the keyspace Cassadara kept is   'bar.com_foo' not 'foo'
> 
>    public static void validateTable(String tablename) throws KeyspaceNotDefinedException
>     {
>         if (!DatabaseDescriptor.getTables().contains(tablename))
>         {
>             throw new KeyspaceNotDefinedException("Keyspace " + tablename + " does not exist");
>         }
>     }
> 
> Thanks,
> 
> Indika       
>    
> 
> On Mon, Jan 31, 2011 at 1:58 AM, Aaron Morton <aa...@thelastpickle.com> wrote:
> AFAIK The order of calling login() and set_keyspace() is not important. 
> 
> set_keyspace() just stores the keyspace in the ClientState on the connection thread, and  login authenticates the user name and password and stores them in the ClientState. Functions on CassandraServer that require authorisation call functions such as ClientState.hasColumnFamilyAccess() where things are checked.
> 
> If you wanted to set the keyspace based on the login, you could do it in the login() function on the ClientState. Then your client would not need to call set_keyspace() . The keyspace has to exist though, it's used it lots of places to identify the CF
> 
> Hope that helps.
> Aaron
> 
> 
> On 31 Jan, 2011,at 07:18 AM, indika kumara <in...@gmail.com> wrote:
> 
>> This issue came when I was trying to implement an idea listed at [http://wiki.apache.org/cassandra/MultiTenant] – Namespaces. I thought the namespace can be the tenant’s domain name provided though username (e.g. foo@bar.com) or can be returned through authentication backend on login. For both cases, calling ‘login’ prior to ‘set_keyspace’ is required. 
>> 
>> The ‘CassandraServer.java’’s ‘set_keyspace()’ checks the availability of a given keyspace. Here, prior to pass the keyspace, it has to be modified.  Any solutions? I would like to create a JIRA for the idea with a working patch.
>> 
>> Highly appreciate the suggestions for implementing the aforementioned idea listed in the wiki. 
>> 
>> Thanks,
>> 
>> Indika
>> 
>> On Sun, Jan 30, 2011 at 10:21 PM, indika kumara <in...@apache.org> wrote:
>> Hi All,
>> 
>> I observed the behavior indicated in the subject of this email even the ‘default User’ returned from authentication is null.  Is this correct? 
>> 
>> 
>> Thanks,
>> 
>> Indika
>> 
> 


Re: In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Posted by indika kumara <in...@gmail.com>.
Hi Aaron,

Thank a lot for your help.

I have still some questions to get clarified.. The issue happens in the
following scenario.

1) Call add keyspace from a client API -The keyspace given by the client is
modified and used for further operations.
   e.g  Client's keysace = 'foo' and the his domain name = 'bar.com'  =>
modified keyspace = 'bar.com_foo'
2) Call add column family from a a client API
   Client's keyspace = 'foo' ...now prior to calling 'login', 'set_keyspace'
is called. Within that method, the following method is called. This throws
an error because the keyspace Cassadara kept is   'bar.com_foo' not 'foo'

   public static void validateTable(String tablename) throws
KeyspaceNotDefinedException
    {
        if (!DatabaseDescriptor.getTables().contains(tablename))
        {
            throw new KeyspaceNotDefinedException("Keyspace " + tablename +
" does not exist");
        }
    }

Thanks,

Indika


On Mon, Jan 31, 2011 at 1:58 AM, Aaron Morton <aa...@thelastpickle.com>wrote:

> AFAIK The order of calling login() and set_keyspace() is not important.
>
> set_keyspace() just stores the keyspace in the ClientState on the
> connection thread, and  login authenticates the user name and password and
> stores them in the ClientState. Functions on CassandraServer that require
> authorisation call functions such as ClientState.hasColumnFamilyAccess()
> where things are checked.
>
> If you wanted to set the keyspace based on the login, you could do it in
> the login() function on the ClientState. Then your client would not need to
> call set_keyspace() . The keyspace has to exist though, it's used it lots of
> places to identify the CF
>
> Hope that helps.
> Aaron
>
>
> On 31 Jan, 2011,at 07:18 AM, indika kumara <in...@gmail.com> wrote:
>
> This issue came when I was trying to implement an idea listed at [
> http://wiki.apache.org/cassandra/MultiTenant] – Namespaces. I thought the
> namespace can be the tenant’s domain name provided though username (e.g.
> foo@bar.com) or can be returned through authentication backend on login.
> For both cases, calling ‘login’ prior to ‘set_keyspace’ is required.
>
> The ‘CassandraServer.java’’s ‘set_keyspace()’ checks the availability of a
> given keyspace. Here, prior to pass the keyspace, it has to be modified.
> Any solutions? I would like to create a JIRA for the idea with a working
> patch.
>
> Highly appreciate the suggestions for implementing the aforementioned idea
> listed in the wiki.
>
> Thanks,
>
> Indika
>
> On Sun, Jan 30, 2011 at 10:21 PM, indika kumara <in...@apache.org> wrote:
>
>> Hi All,
>>
>> I observed the behavior indicated in the subject of this email even the
>> ‘default User’ returned from authentication is null.  Is this correct?
>>
>> Thanks,
>>
>> Indika
>>
>
>

Re: In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Posted by Aaron Morton <aa...@thelastpickle.com>.
AFAIK The order of calling login() and set_keyspace() is not important. 

set_keyspace() just stores the keyspace in the ClientState on the connection thread, and  login authenticates the user name and password and stores them in the ClientState. Functions on CassandraServer that require authorisation call functions such as ClientState.hasColumnFamilyAccess() where things are checked.

If you wanted to set the keyspace based on the login, you could do it in the login() function on the ClientState. Then your client would not need to call set_keyspace() . The keyspace has to exist though, it's used it lots of places to identify the CF

Hope that helps.
Aaron


On 31 Jan, 2011,at 07:18 AM, indika kumara <in...@gmail.com> wrote:

This issue came when I was trying to implement an idea listed at [http://wiki.apache.org/cassandra/MultiTenant] – Namespaces. I thought the namespace can be the tenant’s domain name provided though username (e.g. foo@bar.com) or can be returned through authentication backend on login. For both cases, calling ‘login’ prior to ‘set_keyspace’ is required. 

The ‘CassandraServer.java’’s ‘set_keyspace()’ checks the availability of a given keyspace. Here, prior to pass the keyspace, it has to be modified.  Any solutions? I would like to create a JIRA for the idea with a working patch.

Highly appreciate the suggestions for implementing the aforementioned idea listed in the wiki. 

Thanks,

Indika

On Sun, Jan 30, 2011 at 10:21 PM, indika kumara <in...@apache.org> wrote:
Hi All,

I observed the behavior indicated in the subject of this email even the ‘default User’ returned from authentication is null.  Is this correct? 

Thanks,

Indika


Re: In the ‘Cassandra.Iface’ interface, is it correct to call ‘void set_keyspace()’ prior to ‘login()’?

Posted by indika kumara <in...@gmail.com>.
This issue came when I was trying to implement an idea listed at [
http://wiki.apache.org/cassandra/MultiTenant] – Namespaces. I thought the
namespace can be the tenant’s domain name provided though username (e.g.
foo@bar.com) or can be returned through authentication backend on login. For
both cases, calling ‘login’ prior to ‘set_keyspace’ is required.

The ‘CassandraServer.java’’s ‘set_keyspace()’ checks the availability of a
given keyspace. Here, prior to pass the keyspace, it has to be modified.
Any solutions? I would like to create a JIRA for the idea with a working
patch.

Highly appreciate the suggestions for implementing the aforementioned idea
listed in the wiki.

Thanks,

Indika

On Sun, Jan 30, 2011 at 10:21 PM, indika kumara <in...@apache.org> wrote:

> Hi All,
>
> I observed the behavior indicated in the subject of this email even the
> ‘default User’ returned from authentication is null.  Is this correct?
>
> Thanks,
>
> Indika
>