/** * Called prior to modifying a table's properties. Called as part of modify * table RPC call. * @param ctx the environment to interact with the framework and master * @param tableName the name of the table * @param currentDescriptor current TableDescriptor of the table * @param newDescriptor after modify operation, table will have this descriptor */ default TableDescriptor preModifyTable(final ObserverContext<MasterCoprocessorEnvironment> ctx, final TableName tableName, TableDescriptor currentDescriptor, TableDescriptor newDescriptor) throws IOException { preModifyTable(ctx, tableName, newDescriptor); return newDescriptor; }
@Override protected TableDescriptor call(MasterObserver observer) throws IOException { return observer.preModifyTable(this, tableName, currentDescriptor, getResult()); } });
@Override public void preAlterTable(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String tableName, TableName physicalTableName, TableName parentPhysicalTableName, PTableType tableType) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { if (tableType != PTableType.VIEW) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } } if (tableType == PTableType.VIEW) { requireAccess("Alter "+tableType, parentPhysicalTableName, Action.READ, Action.EXEC); } }
@Override public void preIndexUpdate(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String indexName, TableName physicalTableName, TableName parentPhysicalTableName, PIndexState newState) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } // Check for read access in case of rebuild if (newState == PIndexState.BUILDING) { requireAccess("Rebuild:", parentPhysicalTableName, Action.READ, Action.EXEC); } }
@Override public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException { oserver.preModifyTable(ctx, tableName, htd); } });
@Override public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HTableDescriptor htd) throws IOException { if(LOG.isDebugEnabled()) { LOG.debug("==> HBaseAtlasCoprocessor.preModifyTable()"); } try { activatePluginClassLoader(); implMasterObserver.preModifyTable(c, tableName, htd); } finally { deactivatePluginClassLoader(); } if(LOG.isDebugEnabled()) { LOG.debug("<== HBaseAtlasCoprocessor.preModifyTable()"); } }
@Override public void preAlterTable(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String tableName, TableName physicalTableName, TableName parentPhysicalTableName, PTableType tableType) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { if (tableType != PTableType.VIEW) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } } if (tableType == PTableType.VIEW) { requireAccess("Alter "+tableType, parentPhysicalTableName, Action.READ, Action.EXEC); } }
@Override public void preIndexUpdate(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String indexName, TableName physicalTableName, TableName parentPhysicalTableName, PIndexState newState) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } // Check for read access in case of rebuild if (newState == PIndexState.BUILDING) { requireAccess("Rebuild:", parentPhysicalTableName, Action.READ, Action.EXEC); } }
@Override public void preAlterTable(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String tableName, TableName physicalTableName, TableName parentPhysicalTableName, PTableType tableType) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { if (tableType != PTableType.VIEW) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } } if (tableType == PTableType.VIEW) { requireAccess("Alter "+tableType, parentPhysicalTableName, Action.READ, Action.EXEC); } }
@Override public void preIndexUpdate(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId, String indexName, TableName physicalTableName, TableName parentPhysicalTableName, PIndexState newState) throws IOException { if (!accessCheckEnabled) { return; } for (MasterObserver observer : getAccessControllers()) { observer.preModifyTable(getMasterObsevrverContext(), physicalTableName, TableDescriptorBuilder.newBuilder(physicalTableName).build()); } // Check for read access in case of rebuild if (newState == PIndexState.BUILDING) { requireAccess("Rebuild:", parentPhysicalTableName, Action.READ, Action.EXEC); } }
void preModifyTable(final byte[] tableName, HTableDescriptor htd) throws IOException { ObserverContext<MasterCoprocessorEnvironment> ctx = null; for (MasterEnvironment env: coprocessors) { if (env.getInstance() instanceof MasterObserver) { ctx = ObserverContext.createAndPrepare(env, ctx); try { ((MasterObserver)env.getInstance()).preModifyTable(ctx, tableName, htd); } catch (Throwable e) { handleCoprocessorThrowable(env, e); } if (ctx.shouldComplete()) { break; } } } }