Java Code Examples for org.apache.nifi.util.FormatUtils#getPreciseTimeDuration()
The following examples show how to use
org.apache.nifi.util.FormatUtils#getPreciseTimeDuration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OkHttpReplicationClient.java From nifi with Apache License 2.0 | 6 votes |
private OkHttpClient createOkHttpClient(final NiFiProperties properties) { final String connectionTimeout = properties.getClusterNodeConnectionTimeout(); final long connectionTimeoutMs = (long) FormatUtils.getPreciseTimeDuration(connectionTimeout, TimeUnit.MILLISECONDS); final String readTimeout = properties.getClusterNodeReadTimeout(); final long readTimeoutMs = (long) FormatUtils.getPreciseTimeDuration(readTimeout, TimeUnit.MILLISECONDS); OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient().newBuilder(); okHttpClientBuilder.connectTimeout(connectionTimeoutMs, TimeUnit.MILLISECONDS); okHttpClientBuilder.readTimeout(readTimeoutMs, TimeUnit.MILLISECONDS); okHttpClientBuilder.followRedirects(true); final int connectionPoolSize = properties.getClusterNodeMaxConcurrentRequests(); okHttpClientBuilder.connectionPool(new ConnectionPool(connectionPoolSize, 5, TimeUnit.MINUTES)); // Apply the TLS configuration, if present try { TlsConfiguration tlsConfiguration = TlsConfiguration.fromNiFiProperties(properties); tlsConfigured = OkHttpClientUtils.applyTlsToOkHttpClientBuilder(tlsConfiguration, okHttpClientBuilder); } catch (Exception e) { // Legacy expectations around this client are that it does not throw an exception on invalid TLS configuration // TODO: The only current use of this class is ThreadPoolRequestReplicatorFactoryBean#getObject() which should be evaluated to see if that can change tlsConfigured = false; } return okHttpClientBuilder.build(); }
Example 2
Source File: ServerSocketConfigurationFactoryBean.java From nifi with Apache License 2.0 | 6 votes |
@Override public ServerSocketConfiguration getObject() throws Exception { if (configuration == null) { configuration = new ServerSocketConfiguration(); configuration.setNeedClientAuth(true); final int timeout = (int) FormatUtils.getPreciseTimeDuration(properties.getClusterNodeReadTimeout(), TimeUnit.MILLISECONDS); configuration.setSocketTimeout(timeout); configuration.setReuseAddress(true); // If the cluster protocol is marked as secure if (Boolean.parseBoolean(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { // Parse the TLS configuration from the properties configuration.setTlsConfiguration(TlsConfiguration.fromNiFiProperties(properties)); } } return configuration; }
Example 3
Source File: SocketConfigurationFactoryBean.java From nifi with Apache License 2.0 | 6 votes |
@Override public SocketConfiguration getObject() throws Exception { if (configuration == null) { configuration = new SocketConfiguration(); final int timeout = (int) FormatUtils.getPreciseTimeDuration(properties.getClusterNodeReadTimeout(), TimeUnit.MILLISECONDS); configuration.setSocketTimeout(timeout); configuration.setReuseAddress(true); // If the cluster protocol is marked as secure if (Boolean.parseBoolean(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) { // Parse the TLS configuration from the properties configuration.setTlsConfiguration(TlsConfiguration.fromNiFiProperties(properties)); } } return configuration; }
Example 4
Source File: LdapProvider.java From nifi with Apache License 2.0 | 5 votes |
private void setTimeout(final LoginIdentityProviderConfigurationContext configurationContext, final Map<String, Object> baseEnvironment, final String configurationProperty, final String environmentKey) { final String rawTimeout = configurationContext.getProperty(configurationProperty); if (StringUtils.isNotBlank(rawTimeout)) { try { final long timeout = (long) FormatUtils.getPreciseTimeDuration(rawTimeout, TimeUnit.MILLISECONDS); baseEnvironment.put(environmentKey, String.valueOf(timeout)); } catch (final IllegalArgumentException iae) { throw new ProviderCreationException(String.format("The %s '%s' is not a valid time duration", configurationProperty, rawTimeout)); } } }