186
186
import org .apache .phoenix .thirdparty .com .google .common .annotations .VisibleForTesting ;
187
187
import org .apache .hadoop .hbase .HConstants ;
188
188
import org .apache .hadoop .hbase .client .Admin ;
189
- import org .apache .hadoop .hbase .client .ClusterConnection ;
190
189
import org .apache .hadoop .hbase .client .ColumnFamilyDescriptor ;
191
190
import org .apache .hadoop .hbase .client .ColumnFamilyDescriptorBuilder ;
192
191
import org .apache .hadoop .hbase .client .Delete ;
@@ -6573,7 +6572,7 @@ public MutationState changePermissions(ChangePermsStatement changePermsStatement
6573
6572
LOGGER .info (changePermsStatement .toString ());
6574
6573
6575
6574
try (Admin admin = connection .getQueryServices ().getAdmin ()) {
6576
- ClusterConnection clusterConnection = ( ClusterConnection ) admin .getConnection ();
6575
+ org . apache . hadoop . hbase . client . Connection hConnection = admin .getConnection ();
6577
6576
6578
6577
if (changePermsStatement .getSchemaName () != null ) {
6579
6578
// SYSTEM.CATALOG doesn't have any entry for "default" HBase namespace, hence we will bypass the check
@@ -6583,7 +6582,7 @@ public MutationState changePermissions(ChangePermsStatement changePermsStatement
6583
6582
connection );
6584
6583
}
6585
6584
6586
- changePermsOnSchema (clusterConnection , changePermsStatement );
6585
+ changePermsOnSchema (hConnection , changePermsStatement );
6587
6586
} else if (changePermsStatement .getTableName () != null ) {
6588
6587
PTable inputTable = connection .getTable (SchemaUtil .
6589
6588
normalizeFullTableName (changePermsStatement .getTableName ().toString ()));
@@ -6593,11 +6592,11 @@ public MutationState changePermissions(ChangePermsStatement changePermsStatement
6593
6592
6594
6593
// Changing perms on base table and update the perms for global and view indexes
6595
6594
// Views and local indexes are not physical tables and hence update perms is not needed
6596
- changePermsOnTables (clusterConnection , admin , changePermsStatement , inputTable );
6595
+ changePermsOnTables (hConnection , admin , changePermsStatement , inputTable );
6597
6596
} else {
6598
6597
6599
6598
// User can be given perms at the global level
6600
- changePermsOnUser (clusterConnection , changePermsStatement );
6599
+ changePermsOnUser (hConnection , changePermsStatement );
6601
6600
}
6602
6601
6603
6602
} catch (SQLException e ) {
@@ -6612,20 +6611,25 @@ public MutationState changePermissions(ChangePermsStatement changePermsStatement
6612
6611
return new MutationState (0 , 0 , connection );
6613
6612
}
6614
6613
6615
- private void changePermsOnSchema (ClusterConnection clusterConnection , ChangePermsStatement changePermsStatement ) throws Throwable {
6614
+ private void changePermsOnSchema (org .apache .hadoop .hbase .client .Connection hConnection ,
6615
+ ChangePermsStatement changePermsStatement ) throws Throwable {
6616
6616
if (changePermsStatement .isGrantStatement ()) {
6617
- AccessControlClient .grant (clusterConnection , changePermsStatement .getSchemaName (), changePermsStatement .getName (), changePermsStatement .getPermsList ());
6617
+ AccessControlClient .grant (hConnection , changePermsStatement .getSchemaName (),
6618
+ changePermsStatement .getName (), changePermsStatement .getPermsList ());
6618
6619
} else {
6619
- AccessControlClient .revoke (clusterConnection , changePermsStatement .getSchemaName (), changePermsStatement .getName (), Permission .Action .values ());
6620
+ AccessControlClient .revoke (hConnection , changePermsStatement .getSchemaName (),
6621
+ changePermsStatement .getName (), Permission .Action .values ());
6620
6622
}
6621
6623
}
6622
6624
6623
- private void changePermsOnTables (ClusterConnection clusterConnection , Admin admin , ChangePermsStatement changePermsStatement , PTable inputTable ) throws Throwable {
6625
+ private void changePermsOnTables (org .apache .hadoop .hbase .client .Connection hConnection ,
6626
+ Admin admin , ChangePermsStatement changePermsStatement ,
6627
+ PTable inputTable ) throws Throwable {
6624
6628
6625
6629
org .apache .hadoop .hbase .TableName tableName = SchemaUtil .getPhysicalTableName
6626
6630
(inputTable .getPhysicalName ().getBytes (), inputTable .isNamespaceMapped ());
6627
6631
6628
- changePermsOnTable (clusterConnection , changePermsStatement , tableName );
6632
+ changePermsOnTable (hConnection , changePermsStatement , tableName );
6629
6633
6630
6634
boolean schemaInconsistency = false ;
6631
6635
List <PTable > inconsistentTables = null ;
@@ -6646,7 +6650,7 @@ private void changePermsOnTables(ClusterConnection clusterConnection, Admin admi
6646
6650
LOGGER .info ("Updating permissions for Index Table: " +
6647
6651
indexTable .getName () + " Base Table: " + inputTable .getName ());
6648
6652
tableName = SchemaUtil .getPhysicalTableName (indexTable .getPhysicalName ().getBytes (), indexTable .isNamespaceMapped ());
6649
- changePermsOnTable (clusterConnection , changePermsStatement , tableName );
6653
+ changePermsOnTable (hConnection , changePermsStatement , tableName );
6650
6654
}
6651
6655
6652
6656
if (schemaInconsistency ) {
@@ -6664,7 +6668,7 @@ private void changePermsOnTables(ClusterConnection clusterConnection, Admin admi
6664
6668
if (viewIndexTableExists ) {
6665
6669
LOGGER .info ("Updating permissions for View Index Table: " +
6666
6670
Bytes .toString (viewIndexTableBytes ) + " Base Table: " + inputTable .getName ());
6667
- changePermsOnTable (clusterConnection , changePermsStatement , tableName );
6671
+ changePermsOnTable (hConnection , changePermsStatement , tableName );
6668
6672
} else {
6669
6673
if (inputTable .isMultiTenant ()) {
6670
6674
LOGGER .error ("View Index Table not found for MultiTenant Table: " + inputTable .getName ());
@@ -6675,23 +6679,28 @@ private void changePermsOnTables(ClusterConnection clusterConnection, Admin admi
6675
6679
}
6676
6680
}
6677
6681
6678
- private void changePermsOnTable (ClusterConnection clusterConnection , ChangePermsStatement changePermsStatement , org .apache .hadoop .hbase .TableName tableName )
6682
+ private void changePermsOnTable (org .apache .hadoop .hbase .client .Connection hConnection ,
6683
+ ChangePermsStatement changePermsStatement ,
6684
+ org .apache .hadoop .hbase .TableName tableName )
6679
6685
throws Throwable {
6680
6686
if (changePermsStatement .isGrantStatement ()) {
6681
- AccessControlClient .grant (clusterConnection , tableName , changePermsStatement .getName (),
6687
+ AccessControlClient .grant (hConnection , tableName , changePermsStatement .getName (),
6682
6688
null , null , changePermsStatement .getPermsList ());
6683
6689
} else {
6684
- AccessControlClient .revoke (clusterConnection , tableName , changePermsStatement .getName (),
6690
+ AccessControlClient .revoke (hConnection , tableName , changePermsStatement .getName (),
6685
6691
null , null , Permission .Action .values ());
6686
6692
}
6687
6693
}
6688
6694
6689
- private void changePermsOnUser (ClusterConnection clusterConnection , ChangePermsStatement changePermsStatement )
6695
+ private void changePermsOnUser (org .apache .hadoop .hbase .client .Connection hConnection ,
6696
+ ChangePermsStatement changePermsStatement )
6690
6697
throws Throwable {
6691
6698
if (changePermsStatement .isGrantStatement ()) {
6692
- AccessControlClient .grant (clusterConnection , changePermsStatement .getName (), changePermsStatement .getPermsList ());
6699
+ AccessControlClient .grant (hConnection , changePermsStatement .getName (),
6700
+ changePermsStatement .getPermsList ());
6693
6701
} else {
6694
- AccessControlClient .revoke (clusterConnection , changePermsStatement .getName (), Permission .Action .values ());
6702
+ AccessControlClient .revoke (hConnection , changePermsStatement .getName (),
6703
+ Permission .Action .values ());
6695
6704
}
6696
6705
}
6697
6706
}
0 commit comments