@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 Tablespace tablespace = registerTableSpace(space.name, space.uri, space.getConfig(), true, true); try { //override conf for test if (space.conf != null) tablespace.init(space.conf); } catch (IOException e) { throw new RuntimeException(e); } } // if there is an existing one, return it. return Optional.fromNullable(existing); }
@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 Tablespace tablespace = registerTableSpace(space.name, space.uri, space.getConfig(), true, true); try { //override conf for test if (space.conf != null) tablespace.init(space.conf); } catch (IOException e) { throw new RuntimeException(e); } } // if there is an existing one, return it. return Optional.ofNullable(existing); }