private static void checkMatchingSchemeAndAuthority(URI configKeyURI, ConfigStore cs) { Preconditions.checkNotNull(configKeyURI, "input can not be null"); Preconditions.checkNotNull(cs, "input can not be null"); Preconditions.checkArgument(configKeyURI.getScheme().equals(cs.getStoreURI().getScheme()), "Scheme name not match"); boolean authorityCheck = configKeyURI.getAuthority() == null || configKeyURI.getAuthority().equals(cs.getStoreURI().getAuthority()); Preconditions.checkArgument(authorityCheck, "Authority not match"); }
/** * * @param configKeyURI - URI provided by client , which could missing authority/store root directory * @param cs - ConfigStore corresponding to the input URI. Require input URI's scheme/authority name * match ConfigStore's scheme/authority * @return - {@link ConfigKeyPath} for the relative path */ public static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs) { checkMatchingSchemeAndAuthority(configKeyURI, cs); // Example store root is etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest URI relative = cs.getStoreURI().relativize(configKeyURI); return getConfigKeyPath(relative.getPath()); }
private ConfigStoreAccessor getConfigStoreAccessor(URI configKeyURI) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException { URI matchedFloorKey = getMatchedFloorKeyFromCache(configKeyURI); ConfigStoreAccessor result; if (matchedFloorKey != null) { result = this.configStoreAccessorMap.get(matchedFloorKey); return result; } result = createNewConfigStoreAccessor(configKeyURI); ConfigStore cs = result.configStore; // put default root URI in cache as well for the URI which missing authority if (configKeyURI.getAuthority() == null) { // configKeyURI is missing authority/configstore root "etl-hdfs:///datasets/a1/a2" try { this.configStoreAccessorMap.put(new URI(configKeyURI.getScheme(), null, "/", null, null), result); } catch (URISyntaxException e) { // should not come here throw new RuntimeException("Can not build URI based on " + configKeyURI); } } else { // need to check Config Store's root is the prefix of input configKeyURI if (!ConfigClientUtils.isAncestorOrSame(configKeyURI, cs.getStoreURI())) { throw new RuntimeException( String.format("Config Store root URI %s is not the prefix of input %s", cs.getStoreURI(), configKeyURI)); } } // put to cache this.configStoreAccessorMap.put(cs.getStoreURI(), result); return result; }
return new URI(cs.getStoreURI().getScheme(), null, configKeyPath.getAbsolutePathString(), null, null); URI storeRoot = cs.getStoreURI();
@BeforeClass public void setup() throws Exception{ mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS); URI configStorURI = new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest"); when(mockConfigStore.getCurrentVersion()).thenReturn(version); when(mockConfigStore.getStoreURI()).thenReturn(configStorURI); }
when(mockConfigStore.getStoreURI()).thenReturn(new URI("etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest"));
if (this.policy == VersionStabilityPolicy.CROSS_JVM_STABILITY) { throw new RuntimeException(String.format("with policy set to %s, can not connect to unstable config store %s", VersionStabilityPolicy.CROSS_JVM_STABILITY, cs.getStoreURI()));
private static void checkMatchingSchemeAndAuthority(URI configKeyURI, ConfigStore cs) { Preconditions.checkNotNull(configKeyURI, "input can not be null"); Preconditions.checkNotNull(cs, "input can not be null"); Preconditions.checkArgument(configKeyURI.getScheme().equals(cs.getStoreURI().getScheme()), "Scheme name not match"); boolean authorityCheck = configKeyURI.getAuthority() == null || configKeyURI.getAuthority().equals(cs.getStoreURI().getAuthority()); Preconditions.checkArgument(authorityCheck, "Authority not match"); }
/** * * @param configKeyURI - URI provided by client , which could missing authority/store root directory * @param cs - ConfigStore corresponding to the input URI. Require input URI's scheme/authority name * match ConfigStore's scheme/authority * @return - {@link ConfigKeyPath} for the relative path */ public static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs) { checkMatchingSchemeAndAuthority(configKeyURI, cs); // Example store root is etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest URI relative = cs.getStoreURI().relativize(configKeyURI); return getConfigKeyPath(relative.getPath()); }
private ConfigStoreAccessor getConfigStoreAccessor(URI configKeyURI) throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException { URI matchedFloorKey = getMatchedFloorKeyFromCache(configKeyURI); ConfigStoreAccessor result; if (matchedFloorKey != null) { result = this.configStoreAccessorMap.get(matchedFloorKey); return result; } result = createNewConfigStoreAccessor(configKeyURI); ConfigStore cs = result.configStore; // put default root URI in cache as well for the URI which missing authority if (configKeyURI.getAuthority() == null) { // configKeyURI is missing authority/configstore root "etl-hdfs:///datasets/a1/a2" try { this.configStoreAccessorMap.put(new URI(configKeyURI.getScheme(), null, "/", null, null), result); } catch (URISyntaxException e) { // should not come here throw new RuntimeException("Can not build URI based on " + configKeyURI); } } else { // need to check Config Store's root is the prefix of input configKeyURI if (!ConfigClientUtils.isAncestorOrSame(configKeyURI, cs.getStoreURI())) { throw new RuntimeException( String.format("Config Store root URI %s is not the prefix of input %s", cs.getStoreURI(), configKeyURI)); } } // put to cache this.configStoreAccessorMap.put(cs.getStoreURI(), result); return result; }
return new URI(cs.getStoreURI().getScheme(), null, configKeyPath.getAbsolutePathString(), null, null); URI storeRoot = cs.getStoreURI();
if (this.policy == VersionStabilityPolicy.CROSS_JVM_STABILITY) { throw new RuntimeException(String.format("with policy set to %s, can not connect to unstable config store %s", VersionStabilityPolicy.CROSS_JVM_STABILITY, cs.getStoreURI()));