public Configuration(Map<String, ?> config) { Field[] fields = this.getClass().getDeclaredFields(); this.options = Collections.unmodifiableMap(buildOptions(fields)); this.config = buildConfig(config); }
public ClassLoaderCache(final SchemaRegistryClient schemaRegistryClient) { this.schemaRegistryClient = schemaRegistryClient; CacheLoader<String, ClassLoader> cacheLoader = new CacheLoader<String, ClassLoader>() { @Override public ClassLoader load(String fileId) throws Exception { File file = getFile(fileId); return new URLClassLoader(new URL[]{file.toURI().toURL()}); } }; SchemaRegistryClient.Configuration configuration = schemaRegistryClient.getConfiguration(); loadingCache = CacheBuilder.newBuilder() .maximumSize(((Number) configuration.getValue(CACHE_SIZE_KEY)).longValue()) .expireAfterAccess(((Number) configuration.getValue(CACHE_EXPIRY_INTERVAL_KEY)).longValue(), TimeUnit.SECONDS) .build(cacheLoader); localJarsDir = new File((String) this.schemaRegistryClient.getConfiguration().getValue(SchemaRegistryClient.Configuration.LOCAL_JAR_PATH.name())); ensureLocalDirsExist(); }
public SchemaRegistryClient(Map<String, ?> conf) { configuration = new Configuration(conf); ((Number) configuration.getValue(Configuration.SCHEMA_VERSION_CACHE_SIZE.name())).intValue(), ((Number) configuration.getValue(Configuration.SCHEMA_VERSION_CACHE_EXPIRY_INTERVAL_SECS.name())).longValue() * 1000L ); schemaMetadataCache = new SchemaMetadataCache(((Number) configuration.getValue(Configuration.SCHEMA_METADATA_CACHE_SIZE .name())).longValue(), ((Number) configuration.getValue(Configuration.SCHEMA_METADATA_CACHE_EXPIRY_INTERVAL_SECS .name())).longValue(), schemaMetadataFetcher); .maximumSize(((Number) configuration.getValue(Configuration.SCHEMA_TEXT_CACHE_SIZE .name())).longValue()) .expireAfterAccess(((Number) configuration.getValue(Configuration.SCHEMA_TEXT_CACHE_EXPIRY_INTERVAL_SECS .name())).longValue(), TimeUnit.SECONDS)
private UrlSelector createUrlSelector() { UrlSelector urlSelector = null; String rootCatalogURL = configuration.getValue(SCHEMA_REGISTRY_URL.name()); String urlSelectorClass = configuration.getValue(Configuration.URL_SELECTOR_CLASS.name()); if (urlSelectorClass == null) { urlSelector = new LoadBalancedFailoverUrlSelector(rootCatalogURL); } else { try { urlSelector = (UrlSelector) Class.forName(urlSelectorClass) .getConstructor(String.class) .newInstance(rootCatalogURL); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { throw new RuntimeException(e); } } urlSelector.init(configuration.getConfig()); return urlSelector; }