Java Code Examples for org.apache.nifi.util.NiFiProperties#getProvenanceRepositoryPaths()
The following examples show how to use
org.apache.nifi.util.NiFiProperties#getProvenanceRepositoryPaths() .
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: RepositoryConfiguration.java From localization_nifi with Apache License 2.0 | 4 votes |
public static RepositoryConfiguration create(final NiFiProperties nifiProperties) { final Map<String, Path> storageDirectories = nifiProperties.getProvenanceRepositoryPaths(); if (storageDirectories.isEmpty()) { storageDirectories.put("provenance_repository", Paths.get("provenance_repository")); } final String storageTime = nifiProperties.getProperty(NiFiProperties.PROVENANCE_MAX_STORAGE_TIME, "24 hours"); final String storageSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_MAX_STORAGE_SIZE, "1 GB"); final String rolloverTime = nifiProperties.getProperty(NiFiProperties.PROVENANCE_ROLLOVER_TIME, "5 mins"); final String rolloverSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_ROLLOVER_SIZE, "100 MB"); final String shardSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEX_SHARD_SIZE, "500 MB"); final int queryThreads = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_QUERY_THREAD_POOL_SIZE, 2); final int indexThreads = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_INDEX_THREAD_POOL_SIZE, 2); final int journalCount = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_JOURNAL_COUNT, 16); final int concurrentMergeThreads = nifiProperties.getIntegerProperty(CONCURRENT_MERGE_THREADS, 2); final String warmCacheFrequency = nifiProperties.getProperty(WARM_CACHE_FREQUENCY); final long storageMillis = FormatUtils.getTimeDuration(storageTime, TimeUnit.MILLISECONDS); final long maxStorageBytes = DataUnit.parseDataSize(storageSize, DataUnit.B).longValue(); final long rolloverMillis = FormatUtils.getTimeDuration(rolloverTime, TimeUnit.MILLISECONDS); final long rolloverBytes = DataUnit.parseDataSize(rolloverSize, DataUnit.B).longValue(); final boolean compressOnRollover = Boolean.parseBoolean(nifiProperties.getProperty(NiFiProperties.PROVENANCE_COMPRESS_ON_ROLLOVER)); final String indexedFieldString = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEXED_FIELDS); final String indexedAttrString = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEXED_ATTRIBUTES); final Boolean alwaysSync = Boolean.parseBoolean(nifiProperties.getProperty("nifi.provenance.repository.always.sync", "false")); final int defaultMaxAttrChars = 65536; final String maxAttrLength = nifiProperties.getProperty("nifi.provenance.repository.max.attribute.length", String.valueOf(defaultMaxAttrChars)); int maxAttrChars; try { maxAttrChars = Integer.parseInt(maxAttrLength); // must be at least 36 characters because that's the length of the uuid attribute, // which must be kept intact if (maxAttrChars < 36) { maxAttrChars = 36; logger.warn("Found max attribute length property set to " + maxAttrLength + " but minimum length is 36; using 36 instead"); } } catch (final Exception e) { maxAttrChars = defaultMaxAttrChars; } final List<SearchableField> searchableFields = SearchableFieldParser.extractSearchableFields(indexedFieldString, true); final List<SearchableField> searchableAttributes = SearchableFieldParser.extractSearchableFields(indexedAttrString, false); // We always want to index the Event Time. if (!searchableFields.contains(SearchableFields.EventTime)) { searchableFields.add(SearchableFields.EventTime); } final RepositoryConfiguration config = new RepositoryConfiguration(); for (final Map.Entry<String, Path> entry : storageDirectories.entrySet()) { config.addStorageDirectory(entry.getKey(), entry.getValue().toFile()); } config.setCompressOnRollover(compressOnRollover); config.setSearchableFields(searchableFields); config.setSearchableAttributes(searchableAttributes); config.setMaxEventFileCapacity(rolloverBytes); config.setMaxEventFileLife(rolloverMillis, TimeUnit.MILLISECONDS); config.setMaxRecordLife(storageMillis, TimeUnit.MILLISECONDS); config.setMaxStorageCapacity(maxStorageBytes); config.setQueryThreadPoolSize(queryThreads); config.setIndexThreadPoolSize(indexThreads); config.setJournalCount(journalCount); config.setMaxAttributeChars(maxAttrChars); config.setConcurrentMergeThreads(concurrentMergeThreads); if (warmCacheFrequency != null && !warmCacheFrequency.trim().equals("")) { config.setWarmCacheFrequencyMinutes((int) FormatUtils.getTimeDuration(warmCacheFrequency, TimeUnit.MINUTES)); } if (shardSize != null) { config.setDesiredIndexSize(DataUnit.parseDataSize(shardSize, DataUnit.B).longValue()); } config.setAlwaysSync(alwaysSync); return config; }
Example 2
Source File: RepositoryConfiguration.java From nifi with Apache License 2.0 | 4 votes |
public static RepositoryConfiguration create(final NiFiProperties nifiProperties) { final Map<String, Path> storageDirectories = nifiProperties.getProvenanceRepositoryPaths(); if (storageDirectories.isEmpty()) { storageDirectories.put("provenance_repository", Paths.get("provenance_repository")); } final String storageTime = nifiProperties.getProperty(NiFiProperties.PROVENANCE_MAX_STORAGE_TIME, "24 hours"); final String storageSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_MAX_STORAGE_SIZE, "1 GB"); final String rolloverTime = nifiProperties.getProperty(NiFiProperties.PROVENANCE_ROLLOVER_TIME, "5 mins"); final String rolloverSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_ROLLOVER_SIZE, "100 MB"); final int rolloverEventCount = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_ROLLOVER_EVENT_COUNT, Integer.MAX_VALUE); final String shardSize = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEX_SHARD_SIZE, "500 MB"); final int queryThreads = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_QUERY_THREAD_POOL_SIZE, 2); final int indexThreads = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_INDEX_THREAD_POOL_SIZE, 2); final int journalCount = nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_JOURNAL_COUNT, 16); final int concurrentMergeThreads = nifiProperties.getIntegerProperty(CONCURRENT_MERGE_THREADS, 2); final String warmCacheFrequency = nifiProperties.getProperty(WARM_CACHE_FREQUENCY); final String maintenanceFrequency = nifiProperties.getProperty(MAINTENACE_FREQUENCY); final long storageMillis = FormatUtils.getTimeDuration(storageTime, TimeUnit.MILLISECONDS); final long maxStorageBytes = DataUnit.parseDataSize(storageSize, DataUnit.B).longValue(); final long rolloverMillis = FormatUtils.getTimeDuration(rolloverTime, TimeUnit.MILLISECONDS); final long rolloverBytes = DataUnit.parseDataSize(rolloverSize, DataUnit.B).longValue(); final boolean compressOnRollover = Boolean.parseBoolean(nifiProperties.getProperty(NiFiProperties.PROVENANCE_COMPRESS_ON_ROLLOVER)); final String indexedFieldString = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEXED_FIELDS); final String indexedAttrString = nifiProperties.getProperty(NiFiProperties.PROVENANCE_INDEXED_ATTRIBUTES); final Boolean alwaysSync = Boolean.parseBoolean(nifiProperties.getProperty("nifi.provenance.repository.always.sync", "false")); final int defaultMaxAttrChars = 65536; final String maxAttrLength = nifiProperties.getProperty("nifi.provenance.repository.max.attribute.length", String.valueOf(defaultMaxAttrChars)); int maxAttrChars; try { maxAttrChars = Integer.parseInt(maxAttrLength); // must be at least 36 characters because that's the length of the uuid attribute, // which must be kept intact if (maxAttrChars < 36) { maxAttrChars = 36; logger.warn("Found max attribute length property set to " + maxAttrLength + " but minimum length is 36; using 36 instead"); } } catch (final Exception e) { maxAttrChars = defaultMaxAttrChars; } final List<SearchableField> searchableFields = SearchableFieldParser.extractSearchableFields(indexedFieldString, true); final List<SearchableField> searchableAttributes = SearchableFieldParser.extractSearchableFields(indexedAttrString, false); // We always want to index the Event Time. if (!searchableFields.contains(SearchableFields.EventTime)) { searchableFields.add(SearchableFields.EventTime); } final RepositoryConfiguration config = new RepositoryConfiguration(); for (final Map.Entry<String, Path> entry : storageDirectories.entrySet()) { config.addStorageDirectory(entry.getKey(), entry.getValue().toFile()); } config.setCompressOnRollover(compressOnRollover); config.setSearchableFields(searchableFields); config.setSearchableAttributes(searchableAttributes); config.setMaxEventFileCapacity(rolloverBytes); config.setMaxEventFileCount(rolloverEventCount); config.setMaxEventFileLife(rolloverMillis, TimeUnit.MILLISECONDS); config.setMaxRecordLife(storageMillis, TimeUnit.MILLISECONDS); config.setMaxStorageCapacity(maxStorageBytes); config.setQueryThreadPoolSize(queryThreads); config.setIndexThreadPoolSize(indexThreads); config.setJournalCount(journalCount); config.setMaxAttributeChars(maxAttrChars); config.setConcurrentMergeThreads(concurrentMergeThreads); if (warmCacheFrequency != null && !warmCacheFrequency.trim().equals("")) { config.setWarmCacheFrequencyMinutes((int) FormatUtils.getTimeDuration(warmCacheFrequency, TimeUnit.MINUTES)); } if (shardSize != null) { config.setDesiredIndexSize(DataUnit.parseDataSize(shardSize, DataUnit.B).longValue()); } if (maintenanceFrequency != null && !maintenanceFrequency.trim().equals("")) { final long millis = FormatUtils.getTimeDuration(maintenanceFrequency.trim(), TimeUnit.MILLISECONDS); config.setMaintenanceFrequency(millis, TimeUnit.MILLISECONDS); } config.setAlwaysSync(alwaysSync); config.setDebugFrequency(nifiProperties.getIntegerProperty(NiFiProperties.PROVENANCE_REPO_DEBUG_FREQUENCY, config.getDebugFrequency())); // TODO: Check for multiple key loading (NIFI-6617) // Encryption values may not be present but are only required for EncryptedWriteAheadProvenanceRepository final String implementationClassName = nifiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS); if (EncryptedWriteAheadProvenanceRepository.class.getName().equals(implementationClassName)) { config.setEncryptionKeys(nifiProperties.getProvenanceRepoEncryptionKeys()); config.setKeyId(nifiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_ENCRYPTION_KEY_ID)); config.setKeyProviderImplementation(nifiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_ENCRYPTION_KEY_PROVIDER_IMPLEMENTATION_CLASS)); config.setKeyProviderLocation(nifiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_ENCRYPTION_KEY_PROVIDER_LOCATION)); } return config; }