Exemple #1
0
    @Override
    public GetTablespaceResponse getTablespace(RpcController controller, StringProto request) {
      rlock.lock();

      try {

        // if there exists the tablespace in linked meta data
        Optional<Pair<String, URI>> optional =
            linkedMetadataManager.getTablespace(request.getValue());

        if (optional.isPresent()) {
          Pair<String, URI> spaceInfo = optional.get();
          return GetTablespaceResponse.newBuilder()
              .setState(OK)
              .setTablespace(
                  TablespaceProto.newBuilder()
                      .setSpaceName(spaceInfo.getFirst())
                      .setUri(spaceInfo.getSecond().toString()))
              .build();
        }

        return GetTablespaceResponse.newBuilder()
            .setState(OK)
            .setTablespace(store.getTablespace(request.getValue()))
            .build();

      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);
        return GetTablespaceResponse.newBuilder().setState(returnError(t)).build();

      } finally {
        rlock.unlock();
      }
    }