phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eli Levine <elilev...@gmail.com>
Subject Re: multi tenancy
Date Tue, 26 Aug 2014 17:51:01 GMT
Jan, thank you for reporting. Working on reproing now.


On Tue, Aug 26, 2014 at 10:50 AM, Eli Levine <elilevine@gmail.com> wrote:

> Dan, TenantId can be embedded directly into a URL used to establish
> connections like this.  e.g. jdbc:phoenix:localhost;TenantId=jan Note the
> use of a semicolon after localhost.
>
>
> On Tue, Aug 26, 2014 at 9:40 AM, Dan Di Spaltro <dan.dispaltro@gmail.com>
> wrote:
>
>> I've only ever used TenantId in the properties map, I didn't know you
>> could do that from the connection string (can you?).
>>
>> Properties pros = new Properties();
>> props.setProperty("TenantId", "jan");
>> Connection tenantConn = DriverManager.getConnection(tenantUrl, props);
>>
>>
>>
>>
>> On Tue, Aug 26, 2014 at 7:07 AM, Jan Van Besien <janvanbesien@gmail.com>
>> wrote:
>>
>>> On Fri, Aug 22, 2014 at 5:18 PM, James Taylor <jamestaylor@apache.org>
>>> wrote:
>>> > Yes, this works as designed. Would you mind filing a JIRA for us to
>>> enhance
>>> > our multi tenant docs, as it sounds like it's unclear?
>>>
>>> I created the jira ticket and some progress has already been made,
>>> happy about that ;-)
>>>
>>> However, I still have the impression that there are some things which
>>> do not work as expected. Here is a first testcase which triggers what
>>> looks like a bug to me. I would expect this to work, but the last
>>> statement fails (upsert and commit) with
>>> org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03):
>>> Table undefined. tableName=TEST
>>>
>>> Note that just before, I execute a select query on the same table.
>>>
>>> Thanks for looking into this,
>>> Jan
>>>
>>>     @Test
>>>     public void phoenixMultiTenancyTest() throws Exception {
>>>         HBaseTestingUtility testUtil = new HBaseTestingUtility();
>>>         testUtil.startMiniCluster();
>>>
>>>         String globalUrl = "jdbc:phoenix:localhost:" +
>>> testUtil.getConfiguration().get("hbase.zookeeper.property.clientPort");
>>>         Connection globalConn = DriverManager.getConnection(globalUrl);
>>>
>>>         Statement stmt = globalConn.createStatement();
>>>         stmt.execute("CREATE TABLE test (tenant_id VARCHAR not null,
>>> id bigint not null, " +
>>>                 "first_name varchar constraint pk primary
>>> key(tenant_id, id)) MULTI_TENANT=true");
>>>
>>>         stmt.execute("upsert into test values('jan', 1, 'a')");
>>>         stmt.execute("upsert into test values('bruno', 1, 'b')");
>>>         globalConn.commit();
>>>
>>>         String tenantUrl = globalUrl + ";TenantId=jan";
>>>         Connection tenantConn = DriverManager.getConnection(tenantUrl);
>>>         Statement tenantStmt = tenantConn.createStatement();
>>>
>>>         // this works and is correctly limited to only data for tenant
>>> "jan"
>>>         ResultSet rs = tenantStmt.executeQuery("select id, first_name
>>> from test");
>>>         Assert.assertTrue(rs.next());
>>>         Assert.assertEquals("1", rs.getString(1));
>>>         Assert.assertEquals("a", rs.getString(2));
>>>         Assert.assertFalse(rs.next());
>>>
>>>         // this fails with TableNotFoundException
>>>         tenantStmt.execute("upsert into test values (2, 'b')");
>>>         tenantConn.commit();
>>>     }
>>>
>>
>>
>>
>> --
>> Dan Di Spaltro
>>
>
>

Mime
View raw message