phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject git commit: Phoenix-1147: Ensure data table is sent to client if index table changes states - Addendum to handle schema name
Date Fri, 08 Aug 2014 23:58:01 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master 01542165b -> bf26ef233


Phoenix-1147: Ensure data table is sent to client if index table changes states - Addendum
to handle schema name


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/bf26ef23
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/bf26ef23
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/bf26ef23

Branch: refs/heads/master
Commit: bf26ef23370ed4bf455bd09215a24b48f5324196
Parents: 0154216
Author: Jeffrey Zhong <jeffreyz@apache.org>
Authored: Fri Aug 8 16:52:00 2014 -0700
Committer: Jeffrey Zhong <jeffreyz@apache.org>
Committed: Fri Aug 8 16:58:00 2014 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/index/MutableIndexFailureIT.java    | 12 +++++++-----
 .../phoenix/coprocessor/MetaDataRegionObserver.java     |  8 ++++++--
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bf26ef23/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
index 103c81b..e499c3b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
@@ -109,7 +109,7 @@ public class MutableIndexFailureIT extends BaseTest {
     private static HBaseTestingUtility util;
     private Timer scheduleTimer;
 
-    private static final String SCHEMA_NAME = "";
+    private static final String SCHEMA_NAME = "S";
     private static final String INDEX_TABLE_NAME = "I";
     private static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME,
"T");
     private static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME,
"I");
@@ -178,7 +178,7 @@ public class MutableIndexFailureIT extends BaseTest {
         stmt.execute();
         conn.commit();
 
-        TableName indexTable = TableName.valueOf(INDEX_TABLE_NAME);
+        TableName indexTable = TableName.valueOf(INDEX_TABLE_FULL_NAME);
         HBaseAdmin admin = this.util.getHBaseAdmin();
         HTableDescriptor indexTableDesc = admin.getTableDescriptor(indexTable);
         try{
@@ -221,7 +221,8 @@ public class MutableIndexFailureIT extends BaseTest {
         admin.createTable(indexTableDesc);
         do {
           Thread.sleep(15 * 1000); // sleep 15 secs
-          rs = conn.getMetaData().getTables(null, "", INDEX_TABLE_NAME, new String[] {PTableType.INDEX.toString()});
+          rs = conn.getMetaData().getTables(null, StringUtil.escapeLike(SCHEMA_NAME), INDEX_TABLE_NAME,
+              new String[] { PTableType.INDEX.toString() });
           assertTrue(rs.next());
           if(PIndexState.ACTIVE.toString().equals(rs.getString("INDEX_STATE"))){
               break;
@@ -275,7 +276,7 @@ public class MutableIndexFailureIT extends BaseTest {
         
         // find a RS which doesn't has CATALOG table
         TableName catalogTable = TableName.valueOf("SYSTEM.CATALOG");
-        TableName indexTable = TableName.valueOf(INDEX_TABLE_NAME);
+        TableName indexTable = TableName.valueOf(INDEX_TABLE_FULL_NAME);
         final HBaseCluster cluster = this.util.getHBaseCluster();
         Collection<ServerName> rss = cluster.getClusterStatus().getServers();
         HBaseAdmin admin = this.util.getHBaseAdmin();
@@ -320,7 +321,8 @@ public class MutableIndexFailureIT extends BaseTest {
         // Verify the metadata for index is correct.       
         do {
           Thread.sleep(15 * 1000); // sleep 15 secs
-          rs = conn.getMetaData().getTables(null, "", INDEX_TABLE_NAME, new String[] {PTableType.INDEX.toString()});
+          rs = conn.getMetaData().getTables(null, StringUtil.escapeLike(SCHEMA_NAME), INDEX_TABLE_NAME,
+              new String[] { PTableType.INDEX.toString() });
           assertTrue(rs.next());
           if(PIndexState.ACTIVE.toString().equals(rs.getString("INDEX_STATE"))){
               break;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bf26ef23/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 3a72c5d..6ce0148 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -207,6 +207,7 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
 
                     byte[][] rowKeyMetaData = new byte[3][];
                     SchemaUtil.getVarChars(r.getRow(), 3, rowKeyMetaData);
+                    byte[] schemaName = rowKeyMetaData[PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX];
                     byte[] indexTable = rowKeyMetaData[PhoenixDatabaseMetaData.TABLE_NAME_INDEX];
 
                     // validity check
@@ -218,8 +219,11 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
                     if (conn == null) {
                         conn = DriverManager.getConnection(getJdbcUrl()).unwrap(PhoenixConnection.class);
                     }
-                    PTable dataPTable = PhoenixRuntime.getTable(conn, Bytes.toString(dataTable));
-                    PTable indexPTable = PhoenixRuntime.getTable(conn, Bytes.toString(indexTable));
+
+                    String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTable);
+                    String indexTableFullName = SchemaUtil.getTableName(schemaName, indexTable);
+                    PTable dataPTable = PhoenixRuntime.getTable(conn, dataTableFullName);
+                    PTable indexPTable = PhoenixRuntime.getTable(conn, indexTableFullName);
                     if (!MetaDataUtil.tableRegionsOnline(this.env.getConfiguration(), indexPTable))
{
                         LOG.debug("Index rebuild has been skipped because not all regions
of index table="
                                 + indexPTable.getName() + " are online.");


Mime
View raw message