/** * Get a package scoped variable name. * * @param suffix The variable name of the configuration variable without the package prefix * @return variable name */ default String getPackageVariableName(String suffix) { return getStringProperty("package_name") + "__" + suffix; }
@Override public void reset() { SYSTEM_CONFIG.clearProperty(SYSTEM_CONFIG.getPackageVariableName(propertyName)); on = null; } }
@Override public boolean isOn() { if (on == null) { on = SYSTEM_CONFIG.getBooleanProperty(SYSTEM_CONFIG.getPackageVariableName(propertyName), false); } return on; }
/** * Gets the list of allowed user roles. * * @return List of allowed user roles */ private List<String> getAllowedUserRoles() { try { return SYSTEM_CONFIG.getListProperty( SYSTEM_CONFIG.getPackageVariableName("user_roles") ); } catch (SystemConfigException ignored) { return Collections.emptyList(); } } }
/** * Returns a clock for generating instants for timestamps. * * @return The clock with which to generate instants for timestamps, by default uses the system clock with the * system timezone */ protected Clock getClock() { return Clock.system( ZoneId.of(SYSTEM_CONFIG.getStringProperty( SYSTEM_CONFIG.getPackageVariableName(SYSTEM_CONFIG_TIMEZONE_KEY), "UTC" )) ); }
/** * Constructor. * * @param druidClient The client to query Druid coordinator * @param dimensionDictionary A {@link com.yahoo.bard.webservice.data.dimension.DimensionDictionary} that is used * to obtain a list of lookups in Fili. */ public RegisteredLookupMetadataLoadTask(DruidWebService druidClient, DimensionDictionary dimensionDictionary) { super( RegisteredLookupMetadataLoadTask.class.getSimpleName(), SYSTEM_CONFIG.getLongProperty(INITIAL_LOOKUP_CHECKING_DELAY, 0), SYSTEM_CONFIG.getLongProperty(LOOKUP_NORMAL_CHECKING_PERIOD_KEY, TimeUnit.MINUTES.toMillis(1)) ); this.druidClient = druidClient; this.dimensionDictionary = dimensionDictionary; this.successCallback = buildLookupSuccessCallback(); this.failureCallback = getFailureCallback(); this.errorCallback = getErrorCallback(); this.pendingLookups = new HashSet<>(); this.lookupTiers = getTiers(SYSTEM_CONFIG.getStringProperty(TIERS_KEY, "__default")); }
float dailySegmentationFactor = SYSTEM_CONFIG.getFloatProperty( DAILY_SEGMENTATION_FACTOR_KEY, DAILY_SEGMENTATION_FACTOR_DEFAULT); float weeklySegmentationFactor = SYSTEM_CONFIG.getFloatProperty( WEEKLY_SEGMENTATION_FACTOR_KEY, WEEKLY_SEGMENTATION_FACTOR_DEFAULT); float monthlySegmentationFactor = SYSTEM_CONFIG.getFloatProperty( MONTHLY_SEGMENTATION_FACTOR_KEY, MONTHLY_SEGMENTATION_FACTOR_DEFAULT); float allFactor = SYSTEM_CONFIG.getFloatProperty(ALL_SEGMENTATION_FACTOR_KEY, ALL_SEGMENTATION_FACTOR_DEFAULT); long queryWeightLimit = SYSTEM_CONFIG.getLongProperty( QUERY_WEIGHT_LIMIT_KEY, QUERY_WEIGHT_LIMIT_DEFAULT ); float defaultFactor = SYSTEM_CONFIG.getFloatProperty( DEFAULT_SEGMENTATION_FACTOR_KEY, SEGMENTATION_FACTOR_DEFAULT
/** * Loads defaults and creates DefaultRateLimiter. * * @throws SystemConfigException If any parameters fail to load */ public DefaultRateLimiter() throws SystemConfigException { // Load limits requestLimitGlobal = SYSTEM_CONFIG.getIntProperty(REQUEST_LIMIT_GLOBAL_KEY, DEFAULT_REQUEST_LIMIT_GLOBAL); requestLimitPerUser = SYSTEM_CONFIG.getIntProperty(REQUEST_LIMIT_PER_USER_KEY, DEFAULT_REQUEST_LIMIT_PER_USER); requestLimitUi = SYSTEM_CONFIG.getIntProperty(REQUEST_LIMIT_UI_KEY, DEFAULT_REQUEST_LIMIT_UI); // Register counters for currently active requests usersCounter = REGISTRY.counter("ratelimit.count.users"); requestGlobalCounter = REGISTRY.counter("ratelimit.count.global"); // Register meters for number of requests requestUserMeter = REGISTRY.meter("ratelimit.meter.request.user"); requestUiMeter = REGISTRY.meter("ratelimit.meter.request.ui"); requestBypassMeter = REGISTRY.meter("ratelimit.meter.request.bypass"); rejectUserMeter = REGISTRY.meter("ratelimit.meter.reject.user"); rejectUiMeter = REGISTRY.meter("ratelimit.meter.reject.ui"); }
/** * DruidDimensionRowProvider fetches data from Druid and adds it to the dimension cache. * The dimensions loaded are taken from the system config. * * @param physicalTableDictionary The physical tables * @param dimensionDictionary The dimensions to update * @param druidWebService The druid webservice to query */ public DruidDimensionValueLoader( PhysicalTableDictionary physicalTableDictionary, DimensionDictionary dimensionDictionary, DruidWebService druidWebService ) { this( physicalTableDictionary, dimensionDictionary, //Our configuration framework automatically converts a comma-separated config value into a list. SYSTEM_CONFIG.getListProperty(DRUID_DIM_LOADER_DIMENSIONS), druidWebService ); }
/** * Datasource metadata loader fetches data from the druid coordinator and updates the datasource metadata service. * * @param physicalTableDictionary The physical tables with data sources to update * @param metadataService The service that will store the metadata loaded by this loader * @param druidWebService The druid webservice to query * @param mapper Object mapper to parse druid metadata */ public DataSourceMetadataLoadTask( PhysicalTableDictionary physicalTableDictionary, DataSourceMetadataService metadataService, DruidWebService druidWebService, ObjectMapper mapper ) { super( DataSourceMetadataLoadTask.class.getSimpleName(), SYSTEM_CONFIG.getLongProperty(DRUID_SEG_LOADER_TIMER_DELAY_KEY, 0), SYSTEM_CONFIG.getLongProperty( DRUID_SEG_LOADER_TIMER_DURATION_KEY, TimeUnit.MINUTES.toMillis(1) ) ); this.physicalTableDictionary = physicalTableDictionary; this.metadataService = metadataService; this.druidWebService = druidWebService; this.mapper = mapper; this.failureCallback = getFailureCallback(); this.lastRunTimestamp = new AtomicReference<>(); }
setupDruidDimensionsLoader(healthCheckRegistry, dimensionLoader); if (SYSTEM_CONFIG.getBooleanProperty(DEPRECATED_PERMISSIVE_AVAILABILITY_FLAG, false)) { LOG.warn( "Permissive column availability feature flag is no longer supported, please use " +
/** * Returns whether the feature flag has been configured. * * @return true if the feature flag has been configured. */ default boolean isSet() { SystemConfig systemConfig = SystemConfigProvider.getInstance(); try { return systemConfig.getStringProperty(systemConfig.getPackageVariableName(getName())) != null; } catch (SystemConfigException exception) { return false; } }
/** * Get instance pointing to a search provider. This method makes sure that there just one instance of search * provider for a given dimension. * * @param providerName name unique identifier for search provider instances * * @return The search provider instance */ public static synchronized SearchProvider getInstance(String providerName) { NoOpSearchProvider noOpProvider = noOpProviders.get(providerName); if (noOpProvider == null) { noOpProvider = new NoOpSearchProvider( SYSTEM_CONFIG.getIntProperty(QueryWeightUtil.QUERY_WEIGHT_LIMIT_KEY, DEFAULT_QUERY_WEIGHT_LIMIT) ); noOpProviders.put(providerName, noOpProvider); } return noOpProvider; }
/** * Initialize the client config. * * @param requestTimeout Timeout to use for the client configuration. * * @return the set up client */ private static AsyncHttpClient initializeWebClient(int requestTimeout) { LOG.debug("Druid request timeout: {}ms", requestTimeout); List<String> cipherSuites = SYSTEM_CONFIG.getListProperty(SSL_ENABLED_CIPHER_KEY, null); String[] enabledCipherSuites = cipherSuites == null || cipherSuites.isEmpty() ? null : cipherSuites.toArray(new String[cipherSuites.size()]); // Build the configuration AsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder() .setReadTimeout(requestTimeout) .setRequestTimeout(requestTimeout) .setConnectTimeout(requestTimeout) .setConnectionTtl(requestTimeout) .setPooledConnectionIdleTimeout(requestTimeout) .setEnabledCipherSuites(enabledCipherSuites) .setFollowRedirect(true) .build(); return new DefaultAsyncHttpClient(config); }
/** * DimensionLoaderTask tells all of the {@link DimensionValueLoader}s to update and add values to the dimension * cache. * * @param dimensionRowProviders A Collection of {@link DimensionValueLoader} to initialize dimensions. */ public DimensionValueLoadTask(Collection<DimensionValueLoader> dimensionRowProviders) { super( DimensionValueLoadTask.class.getSimpleName(), SYSTEM_CONFIG.getLongProperty(LOADER_TIMER_DELAY, 0), SYSTEM_CONFIG.getLongProperty( LOADER_TIMER_DURATION, TimeUnit.MINUTES.toMillis(1) ) ); this.dimensionRowProviders = dimensionRowProviders; lastRunTimestamp = new AtomicReference<>(); HttpErrorCallback errorCallback = getErrorCallback(); FailureCallback failureCallback = getFailureCallback(); dimensionRowProviders.forEach(dimensionRowProvider -> { dimensionRowProvider.setErrorCallback(errorCallback); dimensionRowProvider.setFailureCallback(failureCallback); }); }
/** * Get a package scoped variable name. * * @param suffix The variable name of the configuration variable without the package prefix * @return variable name */ default String getPackageVariableName(String suffix) { return getStringProperty("package_name") + "__" + suffix; }
/** * Get an instance of LogFormatter. * * @return an instance of LogFormatter */ public static LogFormatter getInstance() { if (logFormatter == null) { String logFormatterImplementation = SystemConfigProvider.getInstance().getStringProperty( SYSTEM_CONFIG.getPackageVariableName(LOG_FORMATTER_IMPLEMENTATION_SETTING_NAME), DEFAULT_LOG_FORMATTER_IMPL ); try { logFormatter = (LogFormatter) Class.forName(logFormatterImplementation).newInstance(); } catch (Exception exception) { LOG.error("Exception while loading Log formatter: {}", exception); throw new IllegalStateException(exception); } } return logFormatter; } }
@Override public void reset() { SYSTEM_CONFIG.clearProperty(SYSTEM_CONFIG.getPackageVariableName("query_response_caching_strategy")); on = null; } }
/** * Get the Druid response timeout value for the given system property. * * @param timeOutSysProp The system property to read the timeout from * * @return the timeout */ private static Integer fetchDruidResponseTimeOut(String timeOutSysProp) { try { return SYSTEM_CONFIG.getIntProperty(timeOutSysProp, DRUID_REQUEST_TIMEOUT_DEFAULT); } catch (SystemConfigException e) { LOG.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } }
/** * Fetches the URL of the druid coordinator. * * @return druid coordinator URL */ public static String getDruidCoordUrl() { return SYSTEM_CONFIG.getStringProperty(DRUID_COORD_URL_KEY, null); }