Esempio n. 1
0
    @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 = URI.create(command.getLocation().getUri());
                Preconditions.checkArgument(uri.getScheme() != null);
              } catch (Exception e) {
                throw new ServiceException(
                    "ALTER TABLESPACE's LOCATION must be a URI form (scheme:///.../), but "
                        + command.getLocation().getUri());
              }
            }
          }
        }

        store.alterTablespace(request);

        return OK;

      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);
        return returnError(t);

      } finally {
        wlock.unlock();
      }
    }