Beispiel #1
0
  public static void AddTableSpace(
      String spaceName, URI uri, boolean isDefault, JSONObject configs, boolean override) {

    if (isDefault) {
      registerTableSpace(DEFAULT_TABLESPACE_NAME, uri, configs, true, override);
    }
    registerTableSpace(spaceName, uri, configs, true, override);
  }
Beispiel #2
0
 private void addLocalFsTablespace() {
   if (TABLE_SPACES.headMap(LOCAL_FS_URI, true).firstEntry() == null
       && TABLE_SPACE_HANDLERS.containsKey("file")) {
     String tmpName = UUID.randomUUID().toString();
     registerTableSpace(tmpName, LOCAL_FS_URI, null, false, false);
   }
 }
Beispiel #3
0
  @VisibleForTesting
  public static Optional<Tablespace> addTableSpaceForTest(Tablespace space) {
    Tablespace existing;
    synchronized (SPACES_URIS_MAP) {
      String scheme = UriUtil.getScheme(space.getUri());
      if (!TABLE_SPACE_HANDLERS.containsKey(scheme)) {
        TABLE_SPACE_HANDLERS.put(scheme, space.getClass());
      }

      // Remove existing one
      SPACES_URIS_MAP.remove(space.getName());
      existing = TABLE_SPACES.remove(space.getUri());

      // Add anotherone for test
      registerTableSpace(space.name, space.uri, space.getConfig(), true, true);
    }
    // if there is an existing one, return it.
    return Optional.fromNullable(existing);
  }
Beispiel #4
0
  private static void registerTableSpace(
      String spaceName, URI uri, JSONObject spaceDesc, boolean visible, boolean override) {
    Tablespace tableSpace = initializeTableSpace(spaceName, uri, spaceDesc);
    tableSpace.setVisible(visible);

    try {
      tableSpace.init(systemConf);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    putTablespace(tableSpace, override);

    // If the arbitrary path is allowed, root uri is also added as a tablespace
    if (tableSpace.getProperty().isArbitraryPathAllowed()) {
      URI rootUri = tableSpace.getRootUri();
      // if there already exists or the rootUri is 'file:/', it won't overwrite the tablespace.
      if (!TABLE_SPACES.containsKey(rootUri)
          && !rootUri.toString().startsWith(LOCAL_FS_URI.toString())) {
        String tmpName = UUID.randomUUID().toString();
        registerTableSpace(tmpName, rootUri, spaceDesc, false, override);
      }
    }
  }
Beispiel #5
0
 private void addWarehouseAsSpace() {
   Path warehouseDir = TajoConf.getWarehouseDir(systemConf);
   registerTableSpace(DEFAULT_TABLESPACE_NAME, warehouseDir.toUri(), null, true, false);
 }