[GitHub] nifi-minifi pull request #119: MINIFI-447 - Adding FlowMapper and FlowRetrie...
Github user bbende closed the pull request at: https://github.com/apache/nifi-minifi/pull/119 ---
[GitHub] nifi-minifi pull request #119: MINIFI-447 - Adding FlowMapper and FlowRetrie...
Github user kevdoran commented on a diff in the pull request: https://github.com/apache/nifi-minifi/pull/119#discussion_r176803697 --- Diff: minifi-c2/minifi-c2-framework/src/main/java/org/apache/nifi/minifi/c2/core/service/flow/client/NiFiRegistryClientFactory.java --- @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.minifi.c2.core.service.flow.client; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.nifi.minifi.c2.properties.C2Properties; +import org.apache.nifi.registry.client.NiFiRegistryClient; +import org.apache.nifi.registry.client.NiFiRegistryClientConfig; +import org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient; +import org.apache.nifi.registry.security.util.KeystoreType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class does not follow the typical "factory bean" pattern of having a method annotated with @Bean because + * we want to support running a C2 server that may not be configured to do flow deployments, which means we don't want + * to create a NiFiRegistryClient during start-up because the registry URL may not be populated. + * + * An instance of this class can be injected into other services that need a NiFiRegistryClient, and if those services + * get called then they can use this class to lazily obtain an instance, which can then throw an exception if the + * appropriate configuration is not provided. + */ +@Component +public class NiFiRegistryClientFactory { + +private volatile NiFiRegistryClient client; + +private final C2Properties c2Properties; + +@Autowired +public NiFiRegistryClientFactory(final C2Properties c2Properties) { +this.c2Properties = c2Properties; +Validate.notNull(this.c2Properties); --- End diff -- This is minor, but I think \@ Autowired beans are validated to be not null by default, unless annotated with \@ Nullable, right? ---
[GitHub] nifi-minifi pull request #119: MINIFI-447 - Adding FlowMapper and FlowRetrie...
Github user kevdoran commented on a diff in the pull request: https://github.com/apache/nifi-minifi/pull/119#discussion_r176815905 --- Diff: minifi-c2/minifi-c2-framework/src/main/java/org/apache/nifi/minifi/c2/core/service/flow/mapping/FlowMapper.java --- @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.minifi.c2.core.service.flow.mapping; + +import org.apache.nifi.minifi.c2.model.FlowUri; + +import java.util.Optional; + +/** + * Provides mappings from an agent class to the URI of a versioned flow. + */ +public interface FlowMapper { + +/** + * Gets the flow mapping information for the given agent class. + * + * @param agentClassName the name of an agent class + * @return the flow mapping information for the given agent class + * @throws FlowMapperException if an error occurs getting the mapping + */ +Optional getFlowMapping(String agentClassName) throws FlowMapperException; --- End diff -- Nice, I like where you landed on this interface; that will work nicely. ---
[GitHub] nifi-minifi pull request #119: MINIFI-447 - Adding FlowMapper and FlowRetrie...
GitHub user bbende opened a pull request: https://github.com/apache/nifi-minifi/pull/119 MINIFI-447 - Adding FlowMapper and FlowRetrievalService Thank you for submitting a contribution to Apache NiFi - MiNiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi-minifi folder? - [ ] Have you written or updated unit tests to verify your changes? - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under minifi-assembly? - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under minifi-assembly? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/bbende/nifi-minifi flow-service Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi/pull/119.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #119 commit 3789fbdaa79cf390ef2a07d02a89261453bc24da Author: Bryan BendeDate: 2018-03-16T15:08:16Z MINIFI-447 - Adding FlowMapper and FlowRetrievalService ---