private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException { final Table.ID tableId = ClientServiceHandler.checkTableId(master.getContext(), tableName, op); Namespace.ID namespaceId = getNamespaceIdFromTableId(op, tableId); if (!master.security.canAlterTable(c, tableId, namespaceId)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); try { if (value == null || value.isEmpty()) { TablePropUtil.removeTableProperty(master.getContext(), tableId, property); } else if (!TablePropUtil.setTableProperty(master.getContext(), tableId, property, value)) { throw new Exception("Invalid table property."); } } catch (KeeperException.NoNodeException e) { // race condition... table no longer exists? This call will throw an exception if the table // was deleted: ClientServiceHandler.checkTableId(master.getContext(), tableName, op); log.info("Error altering table property", e); throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } catch (Exception e) { log.error("Problem altering table property", e); throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } }
private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException { final String tableId = checkTableId(tableName, op); if (!security.canAlterTable(c, tableId)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); try { if (value == null || value.isEmpty()) { TablePropUtil.removeTableProperty(tableId, property); } else if (!TablePropUtil.setTableProperty(tableId, property, value)) { throw new Exception("Invalid table property."); } } catch (KeeperException.NoNodeException e) { // race condition... table no longer exists? This call will throw an exception if the table was deleted: checkTableId(tableName, op); log.info("Error altering table property", e); throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } catch (Exception e) { log.error("Problem altering table property", e); throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } }
private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException { final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, op); String namespaceId = getNamespaceIdFromTableId(op, tableId); if (!master.security.canAlterTable(c, tableId, namespaceId)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); try { if (value == null || value.isEmpty()) { TablePropUtil.removeTableProperty(tableId, property); } else if (!TablePropUtil.setTableProperty(tableId, property, value)) { throw new Exception("Invalid table property."); } } catch (KeeperException.NoNodeException e) { // race condition... table no longer exists? This call will throw an exception if the table // was deleted: ClientServiceHandler.checkTableId(master.getInstance(), tableName, op); log.info("Error altering table property", e); throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } catch (Exception e) { log.error("Problem altering table property", e); throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } }