示例#1
0
    @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();
      }
    }
示例#2
0
    @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();
      }
    }