Пример #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();
      }
    }
Пример #2
0
  public static Properties getConnParams(Collection<Map.Entry<String, String>> properties) {
    Properties connParams = new Properties();
    for (Map.Entry<String, String> entry : properties) {
      if (PARAMETERS.containsKey(entry.getKey())
          && PARAMETERS.get(entry.getKey()).type() == CONNECTION_PARAM) {
        Pair<String, String> keyValue =
            ((ConnectionParamAction) PARAMETERS.get(entry.getKey())).doAction(entry.getValue());
        connParams.put(keyValue.getFirst(), keyValue.getSecond());
      }
    }

    return connParams;
  }
Пример #3
0
  public static Map<String, String> getSessionVars(
      Collection<Map.Entry<String, String>> properties) {
    Map<String, String> sessionVars = new HashMap<>();

    for (Map.Entry<String, String> entry : properties) {
      if (PARAMETERS.containsKey(entry.getKey())
          && PARAMETERS.get(entry.getKey()).type() == SESSION_UPDATE) {
        Pair<String, String> keyValue =
            ((SessionAction) PARAMETERS.get(entry.getKey())).doAction(entry.getValue());
        sessionVars.put(keyValue.getFirst(), keyValue.getSecond());
      }
    }

    return sessionVars;
  }