@Override public ReturnState dropDatabase(RpcController controller, StringProto request) { String databaseName = request.getValue(); if (linkedMetadataManager.existsDatabase(databaseName)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } if (metaDictionary.isSystemDatabase(databaseName)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } if (databaseName.equals(TajoConstants.DEFAULT_DATABASE_NAME)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } wlock.lock(); try { store.dropDatabase(databaseName); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState dropDatabase(RpcController controller, StringProto request) { String databaseName = request.getValue(); if (linkedMetadataManager.existsDatabase(databaseName)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } if (metaDictionary.isSystemDatabase(databaseName)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } if (databaseName.equals(TajoConstants.DEFAULT_DATABASE_NAME)) { return errInsufficientPrivilege("drop a table in database '" + databaseName + "'"); } wlock.lock(); try { store.dropDatabase(databaseName); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState dropTable(RpcController controller, TableIdentifierProto request) throws ServiceException { String dbName = request.getDatabaseName(); String tbName = request.getTableName(); if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } if (metaDictionary.isSystemDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } wlock.lock(); try { store.dropTable(dbName, tbName); LOG.info(String.format("relation \"%s\" is deleted from the catalog (%s)", CatalogUtil.getCanonicalTableName(dbName, tbName), bindAddressStr)); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState createTable(RpcController controller, TableDescProto request) { String [] splitted = CatalogUtil.splitFQTableName(request.getTableName()); String dbName = splitted[0]; String tbName = splitted[1]; if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } if (metaDictionary.isSystemDatabase(dbName)) { return errInsufficientPrivilege("create a table in database '" + dbName + "'"); } wlock.lock(); try { store.createTable(request); LOG.info(String.format("relation \"%s\" is added to the catalog (%s)", CatalogUtil.getCanonicalTableName(dbName, tbName), bindAddressStr)); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState dropTable(RpcController controller, TableIdentifierProto request) throws ServiceException { String dbName = request.getDatabaseName(); String tbName = request.getTableName(); if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } if (metaDictionary.isSystemDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } wlock.lock(); try { store.dropTable(dbName, tbName); LOG.info(String.format("relation \"%s\" is deleted from the catalog (%s)", IdentifierUtil.getCanonicalTableName(dbName, tbName), bindAddress)); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState createTable(RpcController controller, TableDescProto request) { String [] splitted = IdentifierUtil.splitFQTableName(request.getTableName()); String dbName = splitted[0]; String tbName = splitted[1]; if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("drop a table in database '" + dbName + "'"); } if (metaDictionary.isSystemDatabase(dbName)) { return errInsufficientPrivilege("create a table in database '" + dbName + "'"); } wlock.lock(); try { store.createTable(request); LOG.info(String.format("relation \"%s\" is added to the catalog (%s)", IdentifierUtil.getCanonicalTableName(dbName, tbName), bindAddress)); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState alterTable(RpcController controller, AlterTableDescProto proto) { String [] split = IdentifierUtil.splitTableName(proto.getTableName()); if (linkedMetadataManager.existsDatabase(split[0])) { return errInsufficientPrivilege("alter a table in database '" + split[0] + "'"); } if (metaDictionary.isSystemDatabase(split[0])) { return errInsufficientPrivilege("alter a table in database '" + split[0] + "'"); } // TODO: This should be removed at TAJO-1891 if (proto.getAlterTableType() == CatalogProtos.AlterTableType.ADD_PARTITION) { return errFeatureNotImplemented("ADD PARTTIION"); } wlock.lock(); try { store.alterTable(proto); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState alterTablespace(RpcController controller, AlterTablespaceProto request) { wlock.lock(); try { if (linkedMetadataManager.getTablespace(request.getSpaceName()).isPresent()) { return errInsufficientPrivilege("alter tablespace '"+request.getSpaceName()+"'"); } if (request.getCommandList().size() > 0) { for (AlterTablespaceCommand command : request.getCommandList()) { if (command.getType() == AlterTablespaceProto.AlterTablespaceType.LOCATION) { try { URI uri = new URI(command.getLocation()); Preconditions.checkArgument(uri.getScheme() != null); } catch (URISyntaxException e) { return returnError(ResultCode.INVALID_URL, command.getLocation()); } } } } store.alterTablespace(request); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState alterTable(RpcController controller, AlterTableDescProto proto) { String [] split = CatalogUtil.splitTableName(proto.getTableName()); if (linkedMetadataManager.existsDatabase(split[0])) { return errInsufficientPrivilege("alter a table in database '" + split[0] + "'"); } if (metaDictionary.isSystemDatabase(split[0])) { return errInsufficientPrivilege("alter a table in database '" + split[0] + "'"); } // TODO: This should be removed at TAJO-1891 if (proto.getAlterTableType() == CatalogProtos.AlterTableType.ADD_PARTITION) { return errFeatureNotImplemented("ADD PARTTIION"); } wlock.lock(); try { store.alterTable(proto); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState alterTablespace(RpcController controller, AlterTablespaceProto request) { wlock.lock(); try { if (linkedMetadataManager.getTablespace(request.getSpaceName()).isPresent()) { return errInsufficientPrivilege("alter tablespace '"+request.getSpaceName()+"'"); } if (request.getCommandList().size() > 0) { for (AlterTablespaceCommand command : request.getCommandList()) { if (command.getType() == AlterTablespaceProto.AlterTablespaceType.LOCATION) { try { URI uri = new URI(command.getLocation()); Preconditions.checkArgument(uri.getScheme() != null); } catch (URISyntaxException e) { return returnError(ResultCode.INVALID_URL, command.getLocation()); } } } } store.alterTablespace(request); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState createIndex(RpcController controller, IndexDescProto indexDesc) { String dbName = indexDesc.getTableIdentifier().getDatabaseName(); try { // linked meta data do not support index. The request will be failed. if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("to create index in database '" + dbName + "'"); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } rlock.lock(); try { store.createIndex(indexDesc); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { rlock.unlock(); } }
@Override public ReturnState createIndex(RpcController controller, IndexDescProto indexDesc) { String dbName = indexDesc.getTableIdentifier().getDatabaseName(); try { // linked meta data do not support index. The request will be failed. if (linkedMetadataManager.existsDatabase(dbName)) { return errInsufficientPrivilege("to create index in database '" + dbName + "'"); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } rlock.lock(); try { store.createIndex(indexDesc); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { rlock.unlock(); } }