Java Code Examples for org.apache.nifi.util.NiFiProperties#getProperty()

The following examples show how to use org.apache.nifi.util.NiFiProperties#getProperty() . 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: ZooKeeperClientConfig.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public static ZooKeeperClientConfig createConfig(final NiFiProperties nifiProperties) {
    final String connectString = nifiProperties.getProperty(NiFiProperties.ZOOKEEPER_CONNECT_STRING);
    if (connectString == null || connectString.trim().isEmpty()) {
        throw new IllegalStateException("The '" + NiFiProperties.ZOOKEEPER_CONNECT_STRING + "' property is not set in nifi.properties");
    }
    final String cleanedConnectString = cleanConnectString(connectString);
    if (cleanedConnectString.isEmpty()) {
        throw new IllegalStateException("The '" + NiFiProperties.ZOOKEEPER_CONNECT_STRING + "' property is set in nifi.properties but needs to be in pairs of host:port separated by commas");
    }
    final long sessionTimeoutMs = getTimePeriod(nifiProperties, NiFiProperties.ZOOKEEPER_SESSION_TIMEOUT, NiFiProperties.DEFAULT_ZOOKEEPER_SESSION_TIMEOUT);
    final long connectionTimeoutMs = getTimePeriod(nifiProperties, NiFiProperties.ZOOKEEPER_CONNECT_TIMEOUT, NiFiProperties.DEFAULT_ZOOKEEPER_CONNECT_TIMEOUT);
    final String rootPath = nifiProperties.getProperty(NiFiProperties.ZOOKEEPER_ROOT_NODE, NiFiProperties.DEFAULT_ZOOKEEPER_ROOT_NODE);

    try {
        PathUtils.validatePath(rootPath);
    } catch (final IllegalArgumentException e) {
        throw new IllegalArgumentException("The '" + NiFiProperties.ZOOKEEPER_ROOT_NODE + "' property in nifi.properties is set to an illegal value: " + rootPath);
    }

    return new ZooKeeperClientConfig(cleanedConnectString, (int) sessionTimeoutMs, (int) connectionTimeoutMs, rootPath);
}
 
Example 2
Source File: ClusterProtocolHeartbeatMonitor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public ClusterProtocolHeartbeatMonitor(final ClusterCoordinator clusterCoordinator, final ProtocolListener protocolListener, final NiFiProperties nifiProperties) {
    super(clusterCoordinator, nifiProperties);

    protocolListener.addHandler(this);

    String hostname = nifiProperties.getProperty(NiFiProperties.CLUSTER_NODE_ADDRESS);
    if (hostname == null || hostname.trim().isEmpty()) {
        hostname = "localhost";
    }

    final String port = nifiProperties.getProperty(NiFiProperties.CLUSTER_NODE_PROTOCOL_PORT);
    if (port == null || port.trim().isEmpty()) {
        throw new RuntimeException("Unable to determine which port Cluster Coordinator Protocol is listening on because the '"
                + NiFiProperties.CLUSTER_NODE_PROTOCOL_PORT + "' property is not set");
    }

    try {
        Integer.parseInt(port);
    } catch (final NumberFormatException nfe) {
        throw new RuntimeException("Unable to determine which port Cluster Coordinator Protocol is listening on because the '"
                + NiFiProperties.CLUSTER_NODE_PROTOCOL_PORT + "' property is set to '" + port + "', which is not a valid port number.");
    }

    heartbeatAddress = hostname + ":" + port;
}
 
Example 3
Source File: VolatileContentRepository.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public VolatileContentRepository(final NiFiProperties nifiProperties) {
    final String maxSize = nifiProperties.getProperty(MAX_SIZE_PROPERTY);
    final String blockSizeVal = nifiProperties.getProperty(BLOCK_SIZE_PROPERTY);

    if (maxSize == null) {
        maxBytes = (long) DataUnit.B.convert(100D, DataUnit.MB);
    } else {
        maxBytes = DataUnit.parseDataSize(maxSize, DataUnit.B).longValue();
    }

    final int blockSize;
    if (blockSizeVal == null) {
        blockSize = (int) DataUnit.B.convert(DEFAULT_BLOCK_SIZE_KB, DataUnit.KB);
    } else {
        blockSize = DataUnit.parseDataSize(blockSizeVal, DataUnit.B).intValue();
    }

    memoryManager = new MemoryManager(maxBytes, blockSize);
}
 
Example 4
Source File: TlsConfiguration.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a {@link TlsConfiguration} instantiated from the relevant {@link NiFiProperties} properties.
 *
 * @param niFiProperties the NiFi properties
 * @return a populated TlsConfiguration container object
 */
public static TlsConfiguration fromNiFiProperties(NiFiProperties niFiProperties) {
    if (niFiProperties == null) {
        throw new IllegalArgumentException("The NiFi properties cannot be null");
    }

    String keystorePath = niFiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE);
    String keystorePassword = niFiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE_PASSWD);
    String keyPassword = niFiProperties.getProperty(NiFiProperties.SECURITY_KEY_PASSWD);
    String keystoreType = niFiProperties.getProperty(NiFiProperties.SECURITY_KEYSTORE_TYPE);
    String truststorePath = niFiProperties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE);
    String truststorePassword = niFiProperties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD);
    String truststoreType = niFiProperties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE_TYPE);
    String protocol = TLS_PROTOCOL_VERSION;

    final TlsConfiguration tlsConfiguration = new TlsConfiguration(keystorePath, keystorePassword, keyPassword,
            keystoreType, truststorePath, truststorePassword,
            truststoreType, protocol);
    if (logger.isDebugEnabled()) {
        logger.debug("Instantiating TlsConfiguration from NiFi properties: {}, {}, {}, {}, {}, {}, {}, {}",
                keystorePath, tlsConfiguration.getKeystorePasswordForLogging(), tlsConfiguration.getKeyPasswordForLogging(), keystoreType,
                truststorePath, tlsConfiguration.getTruststorePasswordForLogging(), truststoreType, protocol);
    }

    return tlsConfiguration;
}
 
Example 5
Source File: HttpRemoteSiteListener.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private HttpRemoteSiteListener(final NiFiProperties nifiProperties) {
    super();
    taskExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() {
        private final ThreadFactory defaultFactory = Executors.defaultThreadFactory();

        @Override
        public Thread newThread(final Runnable r) {
            final Thread thread = defaultFactory.newThread(r);
            thread.setName("Http Site-to-Site Transaction Maintenance");
            thread.setDaemon(true);
            return thread;
        }
    });

    int txTtlSec;
    try {
        final String snapshotFrequency = nifiProperties.getProperty(SITE_TO_SITE_HTTP_TRANSACTION_TTL, DEFAULT_SITE_TO_SITE_HTTP_TRANSACTION_TTL);
        txTtlSec = (int) FormatUtils.getTimeDuration(snapshotFrequency, TimeUnit.SECONDS);
    } catch (final Exception e) {
        txTtlSec = (int) FormatUtils.getTimeDuration(DEFAULT_SITE_TO_SITE_HTTP_TRANSACTION_TTL, TimeUnit.SECONDS);
        logger.warn("Failed to parse {} due to {}, use default as {} secs.",
                SITE_TO_SITE_HTTP_TRANSACTION_TTL, e.getMessage(), txTtlSec);
    }
    transactionTtlSec = txTtlSec;
}
 
Example 6
Source File: Cluster.java    From nifi with Apache License 2.0 6 votes vote down vote up
public Node createNode() {
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, getZooKeeperConnectString());
    addProps.put(NiFiProperties.CLUSTER_IS_NODE, "true");

    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties("src/test/resources/conf/nifi.properties", addProps);

    final String algorithm = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_ALGORITHM);
    final String provider = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_PROVIDER);
    final String password = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_KEY);
    final StringEncryptor encryptor = StringEncryptor.createEncryptor(algorithm, provider, password);
    final ExtensionDiscoveringManager extensionManager = new StandardExtensionDiscoveringManager();
    final FingerprintFactory fingerprintFactory = new FingerprintFactory(encryptor, extensionManager);
    final FlowElection flowElection = new PopularVoteFlowElection(flowElectionTimeoutMillis, TimeUnit.MILLISECONDS, flowElectionMaxNodes, fingerprintFactory);

    final Node node = new Node(nifiProperties, extensionManager, flowElection);
    node.start();
    nodes.add(node);

    return node;
}
 
Example 7
Source File: StatusAnalyticsModelMapFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Create a connection model instance  using configurations set in NiFi properties
 * @param extensionManager Extension Manager object for instantiating classes
 * @param nifiProperties NiFi Properties object
 * @return statusAnalyticsModel
 */
private StatusAnalyticsModel createModelInstance(ExtensionManager extensionManager, NiFiProperties nifiProperties) {
    final String implementationClassName = nifiProperties.getProperty(NiFiProperties.ANALYTICS_CONNECTION_MODEL_IMPLEMENTATION, NiFiProperties.DEFAULT_ANALYTICS_CONNECTION_MODEL_IMPLEMENTATION);
    if (implementationClassName == null) {
        throw new RuntimeException("Cannot create Analytics Model because the NiFi Properties is missing the following property: "
                + NiFiProperties.ANALYTICS_CONNECTION_MODEL_IMPLEMENTATION);
    }
    try {
        return NarThreadContextClassLoader.createInstance(extensionManager, implementationClassName, StatusAnalyticsModel.class, nifiProperties);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: TestFlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method which accepts {@link NiFiProperties} object but calls {@link StringEncryptor#createEncryptor(String, String, String)} with extracted properties.
 *
 * @param nifiProperties the NiFiProperties object
 * @return the StringEncryptor
 */
private StringEncryptor createEncryptorFromProperties(NiFiProperties nifiProperties) {
    final String algorithm = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_ALGORITHM);
    final String provider = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_PROVIDER);
    final String password = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_KEY);
    return StringEncryptor.createEncryptor(algorithm, provider, password);
}
 
Example 9
Source File: FlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private static FlowFileSwapManager createSwapManager(final NiFiProperties properties) {
    final String implementationClassName = properties.getProperty(NiFiProperties.FLOWFILE_SWAP_MANAGER_IMPLEMENTATION, DEFAULT_SWAP_MANAGER_IMPLEMENTATION);
    if (implementationClassName == null) {
        return null;
    }

    try {
        return NarThreadContextClassLoader.createInstance(implementationClassName, FlowFileSwapManager.class, properties);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: StandardProcessScheduler.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StandardProcessScheduler(final FlowEngine componentLifecycleThreadPool, final FlowController flowController, final StringEncryptor encryptor,
    final StateManagerProvider stateManagerProvider, final NiFiProperties nifiProperties) {
    this.componentLifeCycleThreadPool = componentLifecycleThreadPool;
    this.flowController = flowController;
    this.encryptor = encryptor;
    this.stateManagerProvider = stateManagerProvider;

    administrativeYieldDuration = nifiProperties.getAdministrativeYieldDuration();
    administrativeYieldMillis = FormatUtils.getTimeDuration(administrativeYieldDuration, TimeUnit.MILLISECONDS);

    final String timeoutString = nifiProperties.getProperty(NiFiProperties.PROCESSOR_SCHEDULING_TIMEOUT);
    processorStartTimeoutMillis = timeoutString == null ? 60000 : FormatUtils.getTimeDuration(timeoutString.trim(), TimeUnit.MILLISECONDS);

    frameworkTaskExecutor = new FlowEngine(4, "Framework Task Thread");
}
 
Example 11
Source File: RocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @param niFiProperties The Properties file
 * @return The property value as a number of bytes
 */
long getByteCountValue(NiFiProperties niFiProperties) {
    long returnValue = 0L;
    String propertyValue = niFiProperties.getProperty(this.propertyName, this.defaultValue);
    try {
        double writeBufferDouble = DataUnit.parseDataSize(propertyValue, DataUnit.B);
        returnValue = (long) (writeBufferDouble < Long.MAX_VALUE ? writeBufferDouble : Long.MAX_VALUE);
    } catch (IllegalArgumentException e) {
        this.generateIllegalArgumentException(propertyValue, e);
    }
    return returnValue;
}
 
Example 12
Source File: RepositoryEncryptorUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Returns {@code true} if the provenance repository is correctly configured for an
 * encrypted implementation. Requires the repository implementation to support encryption
 * and at least one valid key to be configured.
 *
 * @param niFiProperties the {@link NiFiProperties} instance to validate
 * @return true if encryption is successfully configured for the provenance repository
 */
static boolean isProvenanceRepositoryEncryptionConfigured(NiFiProperties niFiProperties) {
    final String implementationClassName = niFiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS);
    // Referencing EWAPR.class.getName() would require a dependency on the module
    boolean encryptedRepo = EWAPR_CLASS_NAME.equals(implementationClassName);
    if (encryptedRepo) {
        return isValidKeyProvider(
                niFiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_ENCRYPTION_KEY_PROVIDER_IMPLEMENTATION_CLASS),
                niFiProperties.getProperty(NiFiProperties.PROVENANCE_REPO_ENCRYPTION_KEY_PROVIDER_LOCATION),
                niFiProperties.getProvenanceRepoEncryptionKeyId(),
                niFiProperties.getProvenanceRepoEncryptionKeys());
    } else {
        return false;
    }
}
 
Example 13
Source File: WriteAheadFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
public WriteAheadFlowFileRepository(final NiFiProperties nifiProperties) {
    alwaysSync = Boolean.parseBoolean(nifiProperties.getProperty(NiFiProperties.FLOWFILE_REPOSITORY_ALWAYS_SYNC, "false"));
    this.nifiProperties = nifiProperties;

    // determine the database file path and ensure it exists
    String writeAheadLogImpl = nifiProperties.getProperty(WRITE_AHEAD_LOG_IMPL);
    if (writeAheadLogImpl == null) {
        writeAheadLogImpl = DEFAULT_WAL_IMPLEMENTATION;
    }
    this.walImplementation = writeAheadLogImpl;

    // We used to use one implementation (minimal locking) of the write-ahead log, but we now want to use the other
    // (sequential access), we must address this. Since the MinimalLockingWriteAheadLog supports multiple partitions,
    // we need to ensure that we recover records from all partitions, so we build up a List of Files for the
    // recovery files.
    for (final String propertyName : nifiProperties.getPropertyKeys()) {
        if (propertyName.startsWith(FLOWFILE_REPOSITORY_DIRECTORY_PREFIX)) {
            final String dirName = nifiProperties.getProperty(propertyName);
            recoveryFiles.add(new File(dirName));
        }
    }

    if (isSequentialAccessWAL(walImplementation)) {
        final String directoryName = nifiProperties.getProperty(FLOWFILE_REPOSITORY_DIRECTORY_PREFIX);
        flowFileRepositoryPaths.add(new File(directoryName));
    } else {
        flowFileRepositoryPaths.addAll(recoveryFiles);
    }


    numPartitions = nifiProperties.getFlowFileRepositoryPartitions();
    checkpointDelayMillis = FormatUtils.getTimeDuration(nifiProperties.getFlowFileRepositoryCheckpointInterval(), TimeUnit.MILLISECONDS);

    checkpointExecutor = Executors.newSingleThreadScheduledExecutor();
}
 
Example 14
Source File: RocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @param niFiProperties The Properties file
 * @return The path of the repo
 */
static Path getFlowFileRepoPath(NiFiProperties niFiProperties) {
    for (final String propertyName : niFiProperties.getPropertyKeys()) {
        if (propertyName.startsWith(FLOWFILE_REPOSITORY_DIRECTORY_PREFIX)) {
            final String dirName = niFiProperties.getProperty(propertyName);
            return Paths.get(dirName);
        }
    }
    return null;
}
 
Example 15
Source File: StringEncryptor.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of the nifi sensitive property encryptor. Validates
 * that the encryptor is actually working.
 *
 * @param niFiProperties properties
 * @return encryptor
 * @throws EncryptionException if any issues arise initializing or
 * validating the encryptor
 */
public static StringEncryptor createEncryptor(final NiFiProperties niFiProperties) throws EncryptionException {

    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

    final String sensitivePropAlgorithmVal = niFiProperties.getProperty(NF_SENSITIVE_PROPS_ALGORITHM);
    final String sensitivePropProviderVal = niFiProperties.getProperty(NF_SENSITIVE_PROPS_PROVIDER);
    final String sensitivePropValueNifiPropVar = niFiProperties.getProperty(NF_SENSITIVE_PROPS_KEY, DEFAULT_SENSITIVE_PROPS_KEY);

    if (StringUtils.isBlank(sensitivePropAlgorithmVal)) {
        throw new EncryptionException(NF_SENSITIVE_PROPS_ALGORITHM + "must bet set");
    }

    if (StringUtils.isBlank(sensitivePropProviderVal)) {
        throw new EncryptionException(NF_SENSITIVE_PROPS_PROVIDER + "must bet set");
    }

    if (StringUtils.isBlank(sensitivePropValueNifiPropVar)) {
        throw new EncryptionException(NF_SENSITIVE_PROPS_KEY + "must bet set");
    }

    final StringEncryptor nifiEncryptor;
    try {
        nifiEncryptor = new StringEncryptor(sensitivePropAlgorithmVal, sensitivePropProviderVal, sensitivePropValueNifiPropVar);
        //test that we can infact encrypt and decrypt something
        if (!nifiEncryptor.decrypt(nifiEncryptor.encrypt(TEST_PLAINTEXT)).equals(TEST_PLAINTEXT)) {
            throw new EncryptionException("NiFi property encryptor does appear to be working - decrypt/encrypt return invalid results");
        }

    } catch (final EncryptionInitializationException | EncryptionOperationNotPossibleException ex) {
        throw new EncryptionException("Cannot initialize sensitive property encryptor", ex);

    }
    return nifiEncryptor;
}
 
Example 16
Source File: RocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @param niFiProperties The Properties file
 * @return The property value as a long
 */
long getLongValue(NiFiProperties niFiProperties) {
    String propertyValue = niFiProperties.getProperty(this.propertyName, this.defaultValue);
    long returnValue = 0L;
    try {
        returnValue = Long.parseLong(propertyValue);
    } catch (NumberFormatException e) {
        this.generateIllegalArgumentException(propertyValue, e);
    }
    return returnValue;
}
 
Example 17
Source File: OcspCertificateValidator.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Loads the trusted certificate authorities according to the specified properties.
 *
 * @param properties properties
 * @return map of certificate authorities
 */
private Map<String, X509Certificate> getTrustedCAs(final NiFiProperties properties) {
    final Map<String, X509Certificate> certificateAuthorities = new HashMap<>();

    // get the path to the truststore
    final String truststorePath = properties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE);
    if (truststorePath == null) {
        throw new IllegalArgumentException("The truststore path is required.");
    }

    // get the truststore password
    final char[] truststorePassword;
    final String rawTruststorePassword = properties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD);
    if (rawTruststorePassword == null) {
        truststorePassword = new char[0];
    } else {
        truststorePassword = rawTruststorePassword.toCharArray();
    }

    // load the configured truststore
    try (final FileInputStream fis = new FileInputStream(truststorePath)) {
        final KeyStore truststore = KeyStoreUtils.getTrustStore(KeyStore.getDefaultType());
        truststore.load(fis, truststorePassword);

        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        trustManagerFactory.init(truststore);

        // consider any certificates in the truststore as a trusted ca
        for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) {
            if (trustManager instanceof X509TrustManager) {
                for (X509Certificate ca : ((X509TrustManager) trustManager).getAcceptedIssuers()) {
                    certificateAuthorities.put(ca.getSubjectX500Principal().getName(), ca);
                }
            }
        }
    } catch (final Exception e) {
        throw new IllegalStateException("Unable to load the configured truststore: " + e);
    }

    return certificateAuthorities;
}
 
Example 18
Source File: OneWaySslAccessControlHelper.java    From nifi with Apache License 2.0 4 votes vote down vote up
public OneWaySslAccessControlHelper(final String nifiPropertiesPath) throws Exception {
    // configure the location of the nifi properties
    File nifiPropertiesFile = new File(nifiPropertiesPath);
    System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, nifiPropertiesFile.getAbsolutePath());

    NiFiProperties props = NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath);
    flowXmlPath = props.getProperty(NiFiProperties.FLOW_CONFIGURATION_FILE);

    // delete the database directory to avoid issues with re-registration in testRequestAccessUsingToken
    FileUtils.deleteDirectory(props.getDatabaseRepositoryPath().toFile());

    final File libTargetDir = new File("target/test-classes/access-control/lib");
    libTargetDir.mkdirs();

    final File libSourceDir = new File("src/test/resources/lib");
    for (final File libFile : libSourceDir.listFiles()) {
        final File libDestFile = new File(libTargetDir, libFile.getName());
        Files.copy(libFile.toPath(), libDestFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    }

    final Bundle systemBundle = SystemBundle.create(props);
    NarUnpacker.unpackNars(props, systemBundle);
    NarClassLoadersHolder.getInstance().init(props.getFrameworkWorkingDirectory(), props.getExtensionsWorkingDirectory());

    // load extensions
    final ExtensionDiscoveringManager extensionManager = new StandardExtensionDiscoveringManager();
    extensionManager.discoverExtensions(systemBundle, NarClassLoadersHolder.getInstance().getBundles());
    ExtensionManagerHolder.init(extensionManager);

    // start the server
    server = new NiFiTestServer("src/main/webapp", CONTEXT_PATH, props);
    server.startServer();
    server.loadFlow();

    // get the base url
    baseUrl = server.getBaseUrl() + CONTEXT_PATH;

    // Create a TlsConfiguration for the truststore properties only
    TlsConfiguration trustOnlyTlsConfiguration = TlsConfiguration.fromNiFiPropertiesTruststoreOnly(props);

    // create the user
    final Client client = WebUtils.createClient(null, SslContextFactory.createSslContext(trustOnlyTlsConfiguration));
    user = new NiFiTestUser(client, null);
}
 
Example 19
Source File: StandardHttpResponseMapper.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
public StandardHttpResponseMapper(final NiFiProperties nifiProperties) {
    final String snapshotFrequency = nifiProperties.getProperty(NiFiProperties.COMPONENT_STATUS_SNAPSHOT_FREQUENCY, NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY);
    long snapshotMillis;
    try {
        snapshotMillis = FormatUtils.getTimeDuration(snapshotFrequency, TimeUnit.MILLISECONDS);
    } catch (final Exception e) {
        snapshotMillis = FormatUtils.getTimeDuration(NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY, TimeUnit.MILLISECONDS);
    }
    endpointMergers.add(new ControllerStatusEndpointMerger());
    endpointMergers.add(new ControllerBulletinsEndpointMerger());
    endpointMergers.add(new GroupStatusEndpointMerger());
    endpointMergers.add(new ProcessorStatusEndpointMerger());
    endpointMergers.add(new ConnectionStatusEndpointMerger());
    endpointMergers.add(new PortStatusEndpointMerger());
    endpointMergers.add(new RemoteProcessGroupStatusEndpointMerger());
    endpointMergers.add(new ProcessorEndpointMerger());
    endpointMergers.add(new ProcessorsEndpointMerger());
    endpointMergers.add(new ConnectionEndpointMerger());
    endpointMergers.add(new ConnectionsEndpointMerger());
    endpointMergers.add(new PortEndpointMerger());
    endpointMergers.add(new InputPortsEndpointMerger());
    endpointMergers.add(new OutputPortsEndpointMerger());
    endpointMergers.add(new RemoteProcessGroupEndpointMerger());
    endpointMergers.add(new RemoteProcessGroupsEndpointMerger());
    endpointMergers.add(new ProcessGroupEndpointMerger());
    endpointMergers.add(new ProcessGroupsEndpointMerger());
    endpointMergers.add(new FlowSnippetEndpointMerger());
    endpointMergers.add(new ProvenanceQueryEndpointMerger());
    endpointMergers.add(new ProvenanceEventEndpointMerger());
    endpointMergers.add(new ControllerServiceEndpointMerger());
    endpointMergers.add(new ControllerServicesEndpointMerger());
    endpointMergers.add(new ControllerServiceReferenceEndpointMerger());
    endpointMergers.add(new ReportingTaskEndpointMerger());
    endpointMergers.add(new ReportingTasksEndpointMerger());
    endpointMergers.add(new DropRequestEndpointMerger());
    endpointMergers.add(new ListFlowFilesEndpointMerger());
    endpointMergers.add(new ComponentStateEndpointMerger());
    endpointMergers.add(new BulletinBoardEndpointMerger());
    endpointMergers.add(new StatusHistoryEndpointMerger(snapshotMillis));
    endpointMergers.add(new SystemDiagnosticsEndpointMerger());
    endpointMergers.add(new CountersEndpointMerger());
    endpointMergers.add(new FlowMerger());
    endpointMergers.add(new ControllerConfigurationEndpointMerger());
    endpointMergers.add(new CurrentUserEndpointMerger());
    endpointMergers.add(new FlowConfigurationEndpointMerger());
    endpointMergers.add(new TemplatesEndpointMerger());
    endpointMergers.add(new LabelEndpointMerger());
    endpointMergers.add(new LabelsEndpointMerger());
    endpointMergers.add(new FunnelEndpointMerger());
    endpointMergers.add(new FunnelsEndpointMerger());
    endpointMergers.add(new ControllerEndpointMerger());
}
 
Example 20
Source File: NarThreadContextClassLoaderTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
public WithPropertiesConstructor(NiFiProperties properties) {
    if (properties.getProperty("fail") != null) {
        throw new RuntimeException("Intentional failure");
    }
    this.properties = properties;
}