public Slf4jJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) { this.queryExecutionTimeLoggingThreshold = runtimeProperties.getLong( Constants.QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY, 0); }
protected JettyHttpROPConnector createJettyHttpRopConnector() { String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY); if (url == null) { throw new ConfigurationException( "No property defined for '%s', can't initialize connection", ClientConstants.ROP_SERVICE_URL_PROPERTY); } String username = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY); long readTimeout = runtimeProperties.getLong( ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY, -1L); HttpClient httpClient = initJettyHttpClient(); addBasicAuthentication(httpClient, url, username); JettyHttpROPConnector result = new JettyHttpROPConnector(httpClient, url, username); if (readTimeout > 0) { result.setReadTimeout(readTimeout); } return result; }
@Override public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception { DataSourceInfo descriptor = nodeDescriptor.getDataSourceDescriptor(); if (descriptor == null) { String message = "Null dataSourceDescriptor for nodeDescriptor '" + nodeDescriptor.getName() + "'"; logger.info(message); throw new ConfigurationException(message); } long maxQueueWaitTime = properties.getLong(Constants.JDBC_MAX_QUEUE_WAIT_TIME, UnmanagedPoolingDataSource.MAX_QUEUE_WAIT_DEFAULT); Driver driver = objectFactory.newInstance(Driver.class, descriptor.getJdbcDriver()); return DataSourceBuilder.url(descriptor.getDataSourceUrl()).driver(driver).userName(descriptor.getUserName()) .password(descriptor.getPassword()) .pool(descriptor.getMinConnections(), descriptor.getMaxConnections()) .maxQueueWaitTime(maxQueueWaitTime).build(); }
@Override public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception { String suffix = "." + nodeDescriptor.getDataChannelDescriptor().getName() + "." + nodeDescriptor.getName(); String driverClass = getProperty(Constants.JDBC_DRIVER_PROPERTY, suffix); String url = getProperty(Constants.JDBC_URL_PROPERTY, suffix); String username = getProperty(Constants.JDBC_USERNAME_PROPERTY, suffix); String password = getProperty(Constants.JDBC_PASSWORD_PROPERTY, suffix); int minConnections = getIntProperty(Constants.JDBC_MIN_CONNECTIONS_PROPERTY, suffix, 1); int maxConnections = getIntProperty(Constants.JDBC_MAX_CONNECTIONS_PROPERTY, suffix, 1); long maxQueueWaitTime = properties.getLong(Constants.JDBC_MAX_QUEUE_WAIT_TIME, UnmanagedPoolingDataSource.MAX_QUEUE_WAIT_DEFAULT); String validationQuery = properties.get(Constants.JDBC_VALIDATION_QUERY_PROPERTY); Driver driver = objectFactory.newInstance(Driver.class, driverClass); return DataSourceBuilder.url(url).driver(driver).userName(username).password(password) .pool(minConnections, maxConnections).maxQueueWaitTime(maxQueueWaitTime) .validationQuery(validationQuery).build(); }