MINIFI-41 - CLI utility for template.xml -> YAML and YAML validation This closes #21
Signed-off-by: Joseph Percivall <joeperciv...@yahoo.com> Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi/commit/2d1e43e7 Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi/tree/2d1e43e7 Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi/diff/2d1e43e7 Branch: refs/heads/master Commit: 2d1e43e73b90df55abc71845160b6422d7a6f03f Parents: 3370cac Author: Bryan Rosander <bryanrosan...@gmail.com> Authored: Mon Jun 20 17:09:19 2016 -0400 Committer: Joseph Percivall <joeperciv...@yahoo.com> Committed: Tue Jul 5 15:16:25 2016 -0400 ---------------------------------------------------------------------- minifi-assembly/NOTICE | 7 + minifi-bootstrap/pom.xml | 5 + .../bootstrap/util/ConfigTransformer.java | 71 +- .../schema/ComponentStatusRepositorySchema.java | 50 -- .../bootstrap/util/schema/ConfigSchema.java | 153 ----- .../bootstrap/util/schema/ConnectionSchema.java | 90 --- .../util/schema/ContentRepositorySchema.java | 57 -- .../util/schema/CorePropertiesSchema.java | 73 --- .../util/schema/FlowControllerSchema.java | 48 -- .../util/schema/FlowFileRepositorySchema.java | 68 -- .../bootstrap/util/schema/ProcessorSchema.java | 124 ---- .../util/schema/ProvenanceReportingSchema.java | 109 ---- .../util/schema/ProvenanceRepositorySchema.java | 43 -- .../util/schema/RemoteInputPortSchema.java | 69 -- .../schema/RemoteProcessingGroupSchema.java | 85 --- .../util/schema/SecurityPropertiesSchema.java | 165 ----- .../util/schema/SensitivePropsSchema.java | 59 -- .../bootstrap/util/schema/SwapSchema.java | 75 --- .../util/schema/common/BaseSchema.java | 142 ---- .../util/schema/common/CommonPropertyKeys.java | 49 -- .../bootstrap/util/TestConfigTransformer.java | 25 +- .../schema/SecurityPropertiesSchemaTest.java | 80 --- minifi-commons/minifi-commons-schema/pom.xml | 38 ++ .../schema/ComponentStatusRepositorySchema.java | 59 ++ .../minifi/commons/schema/ConfigSchema.java | 201 ++++++ .../minifi/commons/schema/ConnectionSchema.java | 111 ++++ .../commons/schema/ContentRepositorySchema.java | 73 +++ .../commons/schema/CorePropertiesSchema.java | 94 +++ .../commons/schema/FlowControllerSchema.java | 55 ++ .../schema/FlowFileRepositorySchema.java | 81 +++ .../minifi/commons/schema/ProcessorSchema.java | 148 +++++ .../schema/ProvenanceReportingSchema.java | 128 ++++ .../schema/ProvenanceRepositorySchema.java | 51 ++ .../commons/schema/RemoteInputPortSchema.java | 85 +++ .../schema/RemoteProcessingGroupSchema.java | 102 +++ .../schema/SecurityPropertiesSchema.java | 177 +++++ .../commons/schema/SensitivePropsSchema.java | 70 ++ .../nifi/minifi/commons/schema/SwapSchema.java | 89 +++ .../commons/schema/common/BaseSchema.java | 200 ++++++ .../schema/common/CommonPropertyKeys.java | 50 ++ .../schema/exception/SchemaLoaderException.java | 24 + .../schema/serialization/ConfigRepresenter.java | 27 + .../schema/serialization/SchemaLoader.java | 53 ++ .../schema/serialization/SchemaSaver.java | 46 ++ .../schema/SecurityPropertiesSchemaTest.java | 80 +++ minifi-commons/pom.xml | 5 +- minifi-toolkit/minifi-toolkit-assembly/LICENSE | 236 +++++++ minifi-toolkit/minifi-toolkit-assembly/NOTICE | 23 + minifi-toolkit/minifi-toolkit-assembly/pom.xml | 68 ++ .../src/main/assembly/dependencies.xml | 58 ++ .../src/main/resources/config.bat | 40 ++ .../src/main/resources/config.sh | 123 ++++ .../minifi-toolkit-configuration/pom.xml | 41 ++ .../toolkit/configuration/ConfigMain.java | 312 +++++++++ .../configuration/PathInputStreamFactory.java | 25 + .../configuration/PathOutputStreamFactory.java | 25 + .../configuration/dto/ConfigSchemaFunction.java | 82 +++ .../dto/ConnectionSchemaFunction.java | 65 ++ .../dto/FlowControllerSchemaFunction.java | 36 ++ .../dto/ProcessorSchemaFunction.java | 62 ++ .../dto/RemoteInputPortSchemaFunction.java | 43 ++ .../RemoteProcessingGroupSchemaFunction.java | 62 ++ .../toolkit/configuration/ConfigMainTest.java | 247 +++++++ .../configuration/dto/BaseSchemaTester.java | 55 ++ .../configuration/dto/ConnectionSchemaTest.java | 162 +++++ .../dto/FlowControllerSchemaTest.java | 70 ++ .../configuration/dto/ProcessorSchemaTest.java | 180 ++++++ .../dto/RemoteInputPortSchemaTest.java | 102 +++ .../dto/RemoteProcessingGroupSchemaTest.java | 140 ++++ .../src/test/resources/CsvToJson.xml | 20 + .../src/test/resources/CsvToJson.yml | 178 +++++ .../resources/DecompressionCircularFlow.xml | 18 + .../resources/DecompressionCircularFlow.yml | 293 +++++++++ .../resources/InvokeHttpMiNiFiTemplateTest.xml | 648 +++++++++++++++++++ .../resources/InvokeHttpMiNiFiTemplateTest.yml | 262 ++++++++ ...aceTextExpressionLanguageCSVReformatting.xml | 20 + ...aceTextExpressionLanguageCSVReformatting.yml | 146 +++++ .../src/test/resources/StressTestFramework.xml | 18 + .../src/test/resources/StressTestFramework.yml | 114 ++++ .../test/resources/config-malformed-field.yml | 109 ++++ .../src/test/resources/config.yml | 111 ++++ minifi-toolkit/pom.xml | 34 + pom.xml | 11 +- 83 files changed, 6330 insertions(+), 1603 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-assembly/NOTICE ---------------------------------------------------------------------- diff --git a/minifi-assembly/NOTICE b/minifi-assembly/NOTICE index e7f6169..e67f7d7 100644 --- a/minifi-assembly/NOTICE +++ b/minifi-assembly/NOTICE @@ -15,6 +15,13 @@ The following binary components are provided under the Apache Software License v Apache NiFi Copyright 2014-2016 The Apache Software Foundation + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + This product includes the following work from the Apache Hadoop project: + + BoundedByteArrayOutputStream.java adapted to SoftLimitBoundedByteArrayOutputStream.java + (ASLv2) Jetty The following NOTICE information applies: Jetty Web Container http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/pom.xml b/minifi-bootstrap/pom.xml index 37a070b..421b390 100644 --- a/minifi-bootstrap/pom.xml +++ b/minifi-bootstrap/pom.xml @@ -58,6 +58,11 @@ limitations under the License. <artifactId>snakeyaml</artifactId> <version>1.17</version> </dependency> + <dependency> + <groupId>org.apache.nifi.minifi</groupId> + <artifactId>minifi-commons-schema</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java index 1a3b1fa..9cac9dc 100644 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java +++ b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java @@ -20,26 +20,26 @@ package org.apache.nifi.minifi.bootstrap.util; import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeException; import org.apache.nifi.minifi.bootstrap.exception.InvalidConfigurationException; -import org.apache.nifi.minifi.bootstrap.util.schema.ComponentStatusRepositorySchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ConfigSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ConnectionSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ContentRepositorySchema; -import org.apache.nifi.minifi.bootstrap.util.schema.CorePropertiesSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.FlowControllerSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.FlowFileRepositorySchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ProcessorSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ProvenanceReportingSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.ProvenanceRepositorySchema; -import org.apache.nifi.minifi.bootstrap.util.schema.RemoteInputPortSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.RemoteProcessingGroupSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.SecurityPropertiesSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.SensitivePropsSchema; -import org.apache.nifi.minifi.bootstrap.util.schema.SwapSchema; +import org.apache.nifi.minifi.commons.schema.ComponentStatusRepositorySchema; +import org.apache.nifi.minifi.commons.schema.ConfigSchema; +import org.apache.nifi.minifi.commons.schema.ConnectionSchema; +import org.apache.nifi.minifi.commons.schema.ContentRepositorySchema; +import org.apache.nifi.minifi.commons.schema.CorePropertiesSchema; +import org.apache.nifi.minifi.commons.schema.FlowControllerSchema; +import org.apache.nifi.minifi.commons.schema.FlowFileRepositorySchema; +import org.apache.nifi.minifi.commons.schema.ProcessorSchema; +import org.apache.nifi.minifi.commons.schema.ProvenanceReportingSchema; +import org.apache.nifi.minifi.commons.schema.ProvenanceRepositorySchema; +import org.apache.nifi.minifi.commons.schema.RemoteInputPortSchema; +import org.apache.nifi.minifi.commons.schema.RemoteProcessingGroupSchema; +import org.apache.nifi.minifi.commons.schema.serialization.SchemaLoader; +import org.apache.nifi.minifi.commons.schema.SecurityPropertiesSchema; +import org.apache.nifi.minifi.commons.schema.SensitivePropsSchema; +import org.apache.nifi.minifi.commons.schema.SwapSchema; import org.apache.nifi.stream.io.ByteArrayOutputStream; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.yaml.snakeyaml.Yaml; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -86,38 +86,21 @@ public final class ConfigTransformer { } public static void transformConfigFile(InputStream sourceStream, String destPath) throws Exception { - try { - Yaml yaml = new Yaml(); - - // Parse the YAML file - final Object loadedObject = yaml.load(sourceStream); - - // Verify the parsed object is a Map structure - if (loadedObject instanceof Map) { - final Map<String, Object> loadedMap = (Map<String, Object>) loadedObject; - ConfigSchema configSchema = new ConfigSchema(loadedMap); - if (!configSchema.isValid()) { - throw new InvalidConfigurationException("Failed to transform config file due to:" + configSchema.getValidationIssuesAsString()); - } + ConfigSchema configSchema = SchemaLoader.loadConfigSchemaFromYaml(sourceStream); + if (!configSchema.isValid()) { + throw new InvalidConfigurationException("Failed to transform config file due to:" + configSchema.getValidationIssuesAsString()); + } - // Create nifi.properties and flow.xml.gz in memory - ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); - writeNiFiProperties(configSchema, nifiPropertiesOutputStream); + // Create nifi.properties and flow.xml.gz in memory + ByteArrayOutputStream nifiPropertiesOutputStream = new ByteArrayOutputStream(); + writeNiFiProperties(configSchema, nifiPropertiesOutputStream); - DOMSource flowXml = createFlowXml(configSchema); + DOMSource flowXml = createFlowXml(configSchema); - // Write nifi.properties and flow.xml.gz - writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); + // Write nifi.properties and flow.xml.gz + writeNiFiPropertiesFile(nifiPropertiesOutputStream, destPath); - writeFlowXmlFile(flowXml, destPath); - } else { - throw new InvalidConfigurationException("Provided YAML configuration is not a Map"); - } - } finally { - if (sourceStream != null) { - sourceStream.close(); - } - } + writeFlowXmlFile(flowXml, destPath); } private static void writeNiFiPropertiesFile(ByteArrayOutputStream nifiPropertiesOutputStream, String destPath) throws IOException { http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ComponentStatusRepositorySchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ComponentStatusRepositorySchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ComponentStatusRepositorySchema.java deleted file mode 100644 index 5b6ac2e..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ComponentStatusRepositorySchema.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMPONENT_STATUS_REPO_KEY; - -/** - * - */ -public class ComponentStatusRepositorySchema extends BaseSchema { - public static final String BUFFER_SIZE_KEY = "buffer size"; - public static final String SNAPSHOT_FREQUENCY_KEY = "snapshot frequency"; - - private Number bufferSize = 1440; - private String snapshotFrequency = "1 min"; - - public ComponentStatusRepositorySchema() { - } - - public ComponentStatusRepositorySchema(Map map) { - bufferSize = getOptionalKeyAsType(map, BUFFER_SIZE_KEY, Number.class, COMPONENT_STATUS_REPO_KEY, 1440); - snapshotFrequency = getOptionalKeyAsType(map, SNAPSHOT_FREQUENCY_KEY, String.class, COMPONENT_STATUS_REPO_KEY, "1 min"); - } - - public Number getBufferSize() { - return bufferSize; - } - - public String getSnapshotFrequency() { - return snapshotFrequency; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConfigSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConfigSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConfigSchema.java deleted file mode 100644 index 5323675..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConfigSchema.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.List; -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMPONENT_STATUS_REPO_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CONNECTIONS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CONTENT_REPO_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CORE_PROPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.FLOWFILE_REPO_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROCESSORS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROVENANCE_REPORTING_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROVENANCE_REPO_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.REMOTE_PROCESSING_GROUPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SECURITY_PROPS_KEY; - -/** - * - */ -public class ConfigSchema extends BaseSchema { - public static String TOP_LEVEL_NAME = "top level"; - - private FlowControllerSchema flowControllerProperties; - private CorePropertiesSchema coreProperties; - private FlowFileRepositorySchema flowfileRepositoryProperties; - private ContentRepositorySchema contentRepositoryProperties; - private ComponentStatusRepositorySchema componentStatusRepositoryProperties; - private SecurityPropertiesSchema securityProperties; - private List<ProcessorSchema> processors; - private List<ConnectionSchema> connections; - private List<RemoteProcessingGroupSchema> remoteProcessingGroups; - private ProvenanceReportingSchema provenanceReportingProperties; - - private ProvenanceRepositorySchema provenanceRepositorySchema; - - public ConfigSchema(Map map) { - flowControllerProperties = getMapAsType(map, FLOW_CONTROLLER_PROPS_KEY, FlowControllerSchema.class, TOP_LEVEL_NAME, true); - - coreProperties = getMapAsType(map, CORE_PROPS_KEY, CorePropertiesSchema.class, TOP_LEVEL_NAME, false); - flowfileRepositoryProperties = getMapAsType(map, FLOWFILE_REPO_KEY, FlowFileRepositorySchema.class, TOP_LEVEL_NAME, false); - contentRepositoryProperties = getMapAsType(map, CONTENT_REPO_KEY, ContentRepositorySchema.class, TOP_LEVEL_NAME, false); - provenanceRepositorySchema = getMapAsType(map, PROVENANCE_REPO_KEY, ProvenanceRepositorySchema.class, TOP_LEVEL_NAME, false); - componentStatusRepositoryProperties = getMapAsType(map, COMPONENT_STATUS_REPO_KEY, ComponentStatusRepositorySchema.class, TOP_LEVEL_NAME, false); - securityProperties = getMapAsType(map, SECURITY_PROPS_KEY, SecurityPropertiesSchema.class, TOP_LEVEL_NAME, false); - - processors = getOptionalKeyAsType(map, PROCESSORS_KEY, List.class, TOP_LEVEL_NAME, null); - if (processors != null) { - transformListToType(processors, "processor", ProcessorSchema.class, PROCESSORS_KEY); - } - - connections = getOptionalKeyAsType(map, CONNECTIONS_KEY, List.class, TOP_LEVEL_NAME, null); - if (connections != null) { - transformListToType(connections, "connection", ConnectionSchema.class, CONNECTIONS_KEY); - } - - remoteProcessingGroups = getOptionalKeyAsType(map, REMOTE_PROCESSING_GROUPS_KEY, List.class, TOP_LEVEL_NAME, null); - if (remoteProcessingGroups != null) { - transformListToType(remoteProcessingGroups, "remote processing group", RemoteProcessingGroupSchema.class, REMOTE_PROCESSING_GROUPS_KEY); - } - - provenanceReportingProperties = getMapAsType(map, PROVENANCE_REPORTING_KEY, ProvenanceReportingSchema.class, TOP_LEVEL_NAME, false, false); - - addIssuesIfNotNull(flowControllerProperties); - addIssuesIfNotNull(coreProperties); - addIssuesIfNotNull(flowfileRepositoryProperties); - addIssuesIfNotNull(contentRepositoryProperties); - addIssuesIfNotNull(componentStatusRepositoryProperties); - addIssuesIfNotNull(securityProperties); - addIssuesIfNotNull(provenanceReportingProperties); - addIssuesIfNotNull(provenanceRepositorySchema); - - if (processors != null) { - for (ProcessorSchema processorSchema : processors) { - addIssuesIfNotNull(processorSchema); - } - } - - if (connections != null) { - for (ConnectionSchema connectionSchema : connections) { - addIssuesIfNotNull(connectionSchema); - } - } - - if (remoteProcessingGroups != null) { - for (RemoteProcessingGroupSchema remoteProcessingGroupSchema : remoteProcessingGroups) { - addIssuesIfNotNull(remoteProcessingGroupSchema); - } - } - } - - public FlowControllerSchema getFlowControllerProperties() { - return flowControllerProperties; - } - - public CorePropertiesSchema getCoreProperties() { - return coreProperties; - } - - public FlowFileRepositorySchema getFlowfileRepositoryProperties() { - return flowfileRepositoryProperties; - } - - public ContentRepositorySchema getContentRepositoryProperties() { - return contentRepositoryProperties; - } - - public SecurityPropertiesSchema getSecurityProperties() { - return securityProperties; - } - - public List<ProcessorSchema> getProcessors() { - return processors; - } - - public List<ConnectionSchema> getConnections() { - return connections; - } - - public List<RemoteProcessingGroupSchema> getRemoteProcessingGroups() { - return remoteProcessingGroups; - } - - public ProvenanceReportingSchema getProvenanceReportingProperties() { - return provenanceReportingProperties; - } - - public ComponentStatusRepositorySchema getComponentStatusRepositoryProperties() { - return componentStatusRepositoryProperties; - } - - public ProvenanceRepositorySchema getProvenanceRepositorySchema() { - return provenanceRepositorySchema; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConnectionSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConnectionSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConnectionSchema.java deleted file mode 100644 index 9ae57d7..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ConnectionSchema.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CONNECTIONS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.NAME_KEY; - -/** - * - */ -public class ConnectionSchema extends BaseSchema { - public static final String SOURCE_NAME_KEY = "source name"; - public static final String SOURCE_RELATIONSHIP_NAME_KEY = "source relationship name"; - public static final String DESTINATION_NAME_KEY = "destination name"; - public static final String MAX_WORK_QUEUE_SIZE_KEY = "max work queue size"; - public static final String MAX_WORK_QUEUE_DATA_SIZE_KEY = "max work queue data size"; - public static final String FLOWFILE_EXPIRATION__KEY = "flowfile expiration"; - public static final String QUEUE_PRIORITIZER_CLASS_KEY = "queue prioritizer class"; - - private String name; - private String sourceName; - private String sourceRelationshipName; - private String destinationName; - private Number maxWorkQueueSize = 0; - private String maxWorkQueueDataSize = "0 MB"; - private String flowfileExpiration = "0 sec"; - private String queuePrioritizerClass = ""; - - public ConnectionSchema(Map map) { - name = getRequiredKeyAsType(map, NAME_KEY, String.class, CONNECTIONS_KEY); - sourceName = getRequiredKeyAsType(map, SOURCE_NAME_KEY, String.class, CONNECTIONS_KEY); - sourceRelationshipName = getRequiredKeyAsType(map, SOURCE_RELATIONSHIP_NAME_KEY, String.class, CONNECTIONS_KEY); - destinationName = getRequiredKeyAsType(map, DESTINATION_NAME_KEY, String.class, CONNECTIONS_KEY); - - maxWorkQueueSize = getOptionalKeyAsType(map, MAX_WORK_QUEUE_SIZE_KEY, Number.class, CONNECTIONS_KEY, 0); - maxWorkQueueDataSize = getOptionalKeyAsType(map, MAX_WORK_QUEUE_DATA_SIZE_KEY, String.class, CONNECTIONS_KEY, "0 MB"); - flowfileExpiration = getOptionalKeyAsType(map, FLOWFILE_EXPIRATION__KEY, String.class, CONNECTIONS_KEY, "0 sec"); - queuePrioritizerClass = getOptionalKeyAsType(map, QUEUE_PRIORITIZER_CLASS_KEY, String.class, CONNECTIONS_KEY, ""); - } - - public String getName() { - return name; - } - - public String getSourceName() { - return sourceName; - } - - public String getSourceRelationshipName() { - return sourceRelationshipName; - } - - public String getDestinationName() { - return destinationName; - } - - public Number getMaxWorkQueueSize() { - return maxWorkQueueSize; - } - - public String getMaxWorkQueueDataSize() { - return maxWorkQueueDataSize; - } - - public String getFlowfileExpiration() { - return flowfileExpiration; - } - - public String getQueuePrioritizerClass() { - return queuePrioritizerClass; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ContentRepositorySchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ContentRepositorySchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ContentRepositorySchema.java deleted file mode 100644 index 1a4d07d..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ContentRepositorySchema.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.ALWAYS_SYNC_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CONTENT_REPO_KEY; - -/** - * - */ -public class ContentRepositorySchema extends BaseSchema { - public static final String CONTENT_CLAIM_MAX_APPENDABLE_SIZE_KEY = "content claim max appendable size"; - public static final String CONTENT_CLAIM_MAX_FLOW_FILES_KEY = "content claim max flow files"; - - private String contentClaimMaxAppendableSize = "10 MB"; - private Number contentClaimMaxFlowFiles = 100; - private Boolean alwaysSync = false; - - public ContentRepositorySchema() { - } - - public ContentRepositorySchema(Map map) { - contentClaimMaxAppendableSize = getOptionalKeyAsType(map, CONTENT_CLAIM_MAX_APPENDABLE_SIZE_KEY, String.class, CONTENT_REPO_KEY, "10 MB"); - contentClaimMaxFlowFiles = getOptionalKeyAsType(map, CONTENT_CLAIM_MAX_FLOW_FILES_KEY, Number.class, CONTENT_REPO_KEY, 100); - alwaysSync = getOptionalKeyAsType(map, ALWAYS_SYNC_KEY, Boolean.class, CONTENT_REPO_KEY, false); - } - - public String getContentClaimMaxAppendableSize() { - return contentClaimMaxAppendableSize; - } - - public Number getContentClaimMaxFlowFiles() { - return contentClaimMaxFlowFiles; - } - - public boolean getAlwaysSync() { - return alwaysSync; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/CorePropertiesSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/CorePropertiesSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/CorePropertiesSchema.java deleted file mode 100644 index d4bae0b..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/CorePropertiesSchema.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.CORE_PROPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.MAX_CONCURRENT_THREADS_KEY; - -/** - * - */ -public class CorePropertiesSchema extends BaseSchema { - - public static final String FLOW_CONTROLLER_SHUTDOWN_PERIOD_KEY = "flow controller graceful shutdown period"; - public static final String FLOW_SERVICE_WRITE_DELAY_INTERVAL_KEY = "flow service write delay interval"; - public static final String ADMINISTRATIVE_YIELD_DURATION_KEY = "administrative yield duration"; - public static final String BORED_YIELD_DURATION_KEY = "bored yield duration"; - - - private String flowControllerGracefulShutdownPeriod = "10 sec"; - private String flowServiceWriteDelayInterval = "500 ms"; - private String administrativeYieldDuration = "30 sec"; - private String boredYieldDuration = "10 millis"; - private Number maxConcurrentThreads = 1; - - public CorePropertiesSchema() { - } - - public CorePropertiesSchema(Map map) { - flowControllerGracefulShutdownPeriod = getOptionalKeyAsType(map, FLOW_CONTROLLER_SHUTDOWN_PERIOD_KEY, String.class, CORE_PROPS_KEY, "10 sec"); - flowServiceWriteDelayInterval = getOptionalKeyAsType(map, FLOW_SERVICE_WRITE_DELAY_INTERVAL_KEY, String.class, CORE_PROPS_KEY, "500 ms"); - administrativeYieldDuration = getOptionalKeyAsType(map, ADMINISTRATIVE_YIELD_DURATION_KEY, String.class, CORE_PROPS_KEY, "30 sec"); - boredYieldDuration = getOptionalKeyAsType(map, BORED_YIELD_DURATION_KEY, String.class, CORE_PROPS_KEY, "10 millis"); - maxConcurrentThreads = getOptionalKeyAsType(map, MAX_CONCURRENT_THREADS_KEY, Number.class, CORE_PROPS_KEY, 1); - } - - public String getFlowControllerGracefulShutdownPeriod() { - return flowControllerGracefulShutdownPeriod; - } - - public String getFlowServiceWriteDelayInterval() { - return flowServiceWriteDelayInterval; - } - - public String getAdministrativeYieldDuration() { - return administrativeYieldDuration; - } - - public String getBoredYieldDuration() { - return boredYieldDuration; - } - - public Number getMaxConcurrentThreads() { - return maxConcurrentThreads; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowControllerSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowControllerSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowControllerSchema.java deleted file mode 100644 index 7c04da0..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowControllerSchema.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMMENT_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.NAME_KEY; - -/** - * - */ -public class FlowControllerSchema extends BaseSchema { - - private String name; - private String comment = ""; - - public FlowControllerSchema(Map map) { - name = getRequiredKeyAsType(map, NAME_KEY, String.class, FLOW_CONTROLLER_PROPS_KEY); - - comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, FLOW_CONTROLLER_PROPS_KEY, ""); - } - - public String getName() { - return name; - } - - public String getComment() { - return comment; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowFileRepositorySchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowFileRepositorySchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowFileRepositorySchema.java deleted file mode 100644 index 10a8c55..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/FlowFileRepositorySchema.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.ALWAYS_SYNC_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.FLOWFILE_REPO_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SWAP_PROPS_KEY; - -/** - * - */ -public class FlowFileRepositorySchema extends BaseSchema { - - public static final String PARTITIONS_KEY = "partitions"; - public static final String CHECKPOINT_INTERVAL_KEY = "checkpoint interval"; - - private Number partitions = 256; - private String checkpointInterval = "2 mins"; - private Boolean alwaysSync = false; - private SwapSchema swapProperties; - - public FlowFileRepositorySchema() { - swapProperties = new SwapSchema(); - } - - public FlowFileRepositorySchema(Map map) { - partitions = getOptionalKeyAsType(map, PARTITIONS_KEY, Number.class, FLOWFILE_REPO_KEY, 256); - checkpointInterval = getOptionalKeyAsType(map, CHECKPOINT_INTERVAL_KEY, String.class, FLOWFILE_REPO_KEY, "2 mins"); - alwaysSync = getOptionalKeyAsType(map, ALWAYS_SYNC_KEY, Boolean.class, FLOWFILE_REPO_KEY, false); - - swapProperties = getMapAsType(map, SWAP_PROPS_KEY, SwapSchema.class, FLOWFILE_REPO_KEY, false); - addIssuesIfNotNull(swapProperties); - } - - public Number getPartitions() { - return partitions; - } - - public String getCheckpointInterval() { - return checkpointInterval; - } - - public boolean getAlwaysSync() { - return alwaysSync; - } - - public SwapSchema getSwapProperties() { - return swapProperties; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProcessorSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProcessorSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProcessorSchema.java deleted file mode 100644 index 622e945..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProcessorSchema.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; -import org.apache.nifi.scheduling.SchedulingStrategy; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.NAME_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROCESSORS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SCHEDULING_PERIOD_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SCHEDULING_STRATEGY_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.YIELD_PERIOD_KEY; - -/** - * - */ -public class ProcessorSchema extends BaseSchema { - public static final String CLASS_KEY = "class"; - public static final String PENALIZATION_PERIOD_KEY = "penalization period"; - public static final String RUN_DURATION_NANOS_KEY = "run duration nanos"; - public static final String AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY = "auto-terminated relationships list"; - public static final String PROCESSOR_PROPS_KEY = "Properties"; - - - private String name; - private String processorClass; - private Number maxConcurrentTasks = 1; - private String schedulingStrategy; - private String schedulingPeriod; - private String penalizationPeriod = "30 sec"; - private String yieldPeriod = "1 sec"; - private Number runDurationNanos = 0; - private List<String> autoTerminatedRelationshipsList = Collections.emptyList(); - private Map<String, Object> properties = Collections.emptyMap(); - - public ProcessorSchema(Map map) { - name = getRequiredKeyAsType(map, NAME_KEY, String.class, PROCESSORS_KEY); - processorClass = getRequiredKeyAsType(map, CLASS_KEY, String.class, PROCESSORS_KEY); - - maxConcurrentTasks = getOptionalKeyAsType(map, MAX_CONCURRENT_TASKS_KEY, Number.class, PROCESSORS_KEY, 1); - - schedulingStrategy = getRequiredKeyAsType(map, SCHEDULING_STRATEGY_KEY, String.class, PROCESSORS_KEY); - try { - SchedulingStrategy.valueOf(schedulingStrategy); - } catch (IllegalArgumentException e) { - addValidationIssue(SCHEDULING_STRATEGY_KEY, PROCESSORS_KEY, "it is not a valid scheduling strategy"); - } - - schedulingPeriod = getRequiredKeyAsType(map, SCHEDULING_PERIOD_KEY, String.class, PROCESSORS_KEY); - - penalizationPeriod = getOptionalKeyAsType(map, PENALIZATION_PERIOD_KEY, String.class, PROCESSORS_KEY, "30 sec"); - - yieldPeriod = getOptionalKeyAsType(map, YIELD_PERIOD_KEY, String.class, PROCESSORS_KEY, "1 sec"); - - runDurationNanos = getOptionalKeyAsType(map, RUN_DURATION_NANOS_KEY, Number.class, PROCESSORS_KEY, 0); - - autoTerminatedRelationshipsList = getOptionalKeyAsType(map, AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, List.class, PROCESSORS_KEY, null); - - properties = getOptionalKeyAsType(map, PROCESSOR_PROPS_KEY, Map.class, PROCESSORS_KEY, null); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getProcessorClass() { - return processorClass; - } - - public Number getMaxConcurrentTasks() { - return maxConcurrentTasks; - } - - public String getSchedulingStrategy() { - return schedulingStrategy; - } - - public String getSchedulingPeriod() { - return schedulingPeriod; - } - - public String getPenalizationPeriod() { - return penalizationPeriod; - } - - public String getYieldPeriod() { - return yieldPeriod; - } - - public Number getRunDurationNanos() { - return runDurationNanos; - } - - public List<String> getAutoTerminatedRelationshipsList() { - return autoTerminatedRelationshipsList; - } - - public Map<String, Object> getProperties() { - return properties; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceReportingSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceReportingSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceReportingSchema.java deleted file mode 100644 index a260916..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceReportingSchema.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; -import org.apache.nifi.scheduling.SchedulingStrategy; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.RemoteProcessingGroupSchema.TIMEOUT_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMMENT_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROVENANCE_REPORTING_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SCHEDULING_PERIOD_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SCHEDULING_STRATEGY_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.USE_COMPRESSION_KEY; - -/** - * - */ -public class ProvenanceReportingSchema extends BaseSchema { - public static final String DESTINATION_URL_KEY = "destination url"; - public static final String PORT_NAME_KEY = "port name"; - public static final String ORIGINATING_URL_KEY = "originating url"; - public static final String BATCH_SIZE_KEY = "batch size"; - - private String comment; - private String schedulingStrategy; - private String schedulingPeriod; - private String destinationUrl; - private String portName; - private String originatingUrl = "http://${hostname(true)}:8080/nifi"; - private Boolean useCompression = true; - private String timeout = "30 secs"; - private Number batchSize = 1000; - - public ProvenanceReportingSchema(Map map) { - comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, PROVENANCE_REPORTING_KEY, null); - - schedulingStrategy = getRequiredKeyAsType(map, SCHEDULING_STRATEGY_KEY, String.class, PROVENANCE_REPORTING_KEY); - try { - SchedulingStrategy.valueOf(schedulingStrategy); - } catch (IllegalArgumentException e) { - addValidationIssue(SCHEDULING_STRATEGY_KEY, PROVENANCE_REPORTING_KEY, "it is not a valid scheduling strategy"); - } - - schedulingPeriod = getRequiredKeyAsType(map, SCHEDULING_PERIOD_KEY, String.class, PROVENANCE_REPORTING_KEY); - - destinationUrl = getRequiredKeyAsType(map, DESTINATION_URL_KEY, String.class, PROVENANCE_REPORTING_KEY); - portName = getRequiredKeyAsType(map, PORT_NAME_KEY, String.class, PROVENANCE_REPORTING_KEY); - - originatingUrl = getOptionalKeyAsType(map, ORIGINATING_URL_KEY, String.class, PROVENANCE_REPORTING_KEY, "http://${hostname(true)}:8080/nifi"); - - useCompression = getOptionalKeyAsType(map, USE_COMPRESSION_KEY, Boolean.class, PROVENANCE_REPORTING_KEY, true); - - timeout = getOptionalKeyAsType(map, TIMEOUT_KEY, String.class, PROVENANCE_REPORTING_KEY, "30 secs"); - - batchSize = getOptionalKeyAsType(map, BATCH_SIZE_KEY, Number.class, PROVENANCE_REPORTING_KEY, 1000); - } - - public String getComment() { - return comment; - } - - public String getSchedulingStrategy() { - return schedulingStrategy; - } - - public String getSchedulingPeriod() { - return schedulingPeriod; - } - - public String getDestinationUrl() { - return destinationUrl; - } - - public String getPortName() { - return portName; - } - - public String getOriginatingUrl() { - return originatingUrl; - } - - public boolean getUseCompression() { - return useCompression; - } - - public String getTimeout() { - return timeout; - } - - public Number getBatchSize() { - return batchSize; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceRepositorySchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceRepositorySchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceRepositorySchema.java deleted file mode 100644 index 4a3b404..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/ProvenanceRepositorySchema.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.PROVENANCE_REPO_KEY; - -public class ProvenanceRepositorySchema extends BaseSchema { - - - public static final String PROVENANCE_REPO_ROLLOVER_TIME_KEY = "provenance rollover time"; - - private String provenanceRepoRolloverTime = "1 min"; - - public ProvenanceRepositorySchema(){ - } - - public ProvenanceRepositorySchema(Map map) { - provenanceRepoRolloverTime = getOptionalKeyAsType(map, PROVENANCE_REPO_ROLLOVER_TIME_KEY, String.class, PROVENANCE_REPO_KEY, "1 min"); - } - - public String getProvenanceRepoRolloverTimeKey() { - return provenanceRepoRolloverTime; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteInputPortSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteInputPortSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteInputPortSchema.java deleted file mode 100644 index 9b0cdc7..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteInputPortSchema.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMMENT_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.ID_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.INPUT_PORTS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.NAME_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.USE_COMPRESSION_KEY; - -/** - * - */ -public class RemoteInputPortSchema extends BaseSchema { - - private String id; - private String name; - private String comment = ""; - private Number maxConcurrentTasks = 1; - private Boolean useCompression = true; - - public RemoteInputPortSchema(Map map) { - id = getRequiredKeyAsType(map, ID_KEY, String.class, INPUT_PORTS_KEY); - name = getRequiredKeyAsType(map, NAME_KEY, String.class, INPUT_PORTS_KEY); - - comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, INPUT_PORTS_KEY, ""); - maxConcurrentTasks = getOptionalKeyAsType(map, MAX_CONCURRENT_TASKS_KEY, Number.class, INPUT_PORTS_KEY, 1); - useCompression = getOptionalKeyAsType(map, USE_COMPRESSION_KEY, Boolean.class, INPUT_PORTS_KEY, true); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getComment() { - return comment; - } - - public Number getMax_concurrent_tasks() { - return maxConcurrentTasks; - } - - public boolean getUseCompression() { - return useCompression; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteProcessingGroupSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteProcessingGroupSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteProcessingGroupSchema.java deleted file mode 100644 index 7c32183..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/RemoteProcessingGroupSchema.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.List; -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.COMMENT_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.INPUT_PORTS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.NAME_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.REMOTE_PROCESSING_GROUPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.YIELD_PERIOD_KEY; - -/** - * - */ -public class RemoteProcessingGroupSchema extends BaseSchema { - public static final String URL_KEY = "url"; - public static final String TIMEOUT_KEY = "timeout"; - - private String name; - private String comment = ""; - private String url; - private String timeout = "30 secs"; - private String yieldPeriod = "10 sec"; - private List<RemoteInputPortSchema> inputPorts; - - public RemoteProcessingGroupSchema(Map map) { - name = getRequiredKeyAsType(map, NAME_KEY, String.class, REMOTE_PROCESSING_GROUPS_KEY); - url = getRequiredKeyAsType(map, URL_KEY, String.class, REMOTE_PROCESSING_GROUPS_KEY); - - comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, REMOTE_PROCESSING_GROUPS_KEY, ""); - timeout = getOptionalKeyAsType(map, TIMEOUT_KEY, String.class, REMOTE_PROCESSING_GROUPS_KEY, "30 secs"); - yieldPeriod = getOptionalKeyAsType(map, YIELD_PERIOD_KEY, String.class, REMOTE_PROCESSING_GROUPS_KEY, "10 sec"); - - inputPorts = getRequiredKeyAsType(map, INPUT_PORTS_KEY, List.class, REMOTE_PROCESSING_GROUPS_KEY); - if (inputPorts != null) { - transformListToType(inputPorts, "input port", RemoteInputPortSchema.class, INPUT_PORTS_KEY); - - for (RemoteInputPortSchema remoteInputPortSchema: inputPorts) { - addIssuesIfNotNull(remoteInputPortSchema); - } - } - } - - public String getName() { - return name; - } - - public String getComment() { - return comment; - } - - public String getUrl() { - return url; - } - - public String getTimeout() { - return timeout; - } - - public String getYieldPeriod() { - return yieldPeriod; - } - - public List<RemoteInputPortSchema> getInputPorts() { - return inputPorts; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SecurityPropertiesSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SecurityPropertiesSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SecurityPropertiesSchema.java deleted file mode 100644 index b6a47a3..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SecurityPropertiesSchema.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SECURITY_PROPS_KEY; -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SENSITIVE_PROPS_KEY; - -/** - * - */ -public class SecurityPropertiesSchema extends BaseSchema { - - public static final String KEYSTORE_KEY = "keystore"; - public static final String KEYSTORE_TYPE_KEY = "keystore type"; - public static final String KEYSTORE_PASSWORD_KEY = "keystore password"; - public static final String KEY_PASSWORD_KEY = "key password"; - public static final String TRUSTSTORE_KEY = "truststore"; - public static final String TRUSTSTORE_TYPE_KEY = "truststore type"; - public static final String TRUSTSTORE_PASSWORD_KEY = "truststore password"; - public static final String SSL_PROTOCOL_KEY = "ssl protocol"; - - private String keystore = ""; - private String keystoreType = ""; - private String keystorePassword = ""; - private String keyPassword = ""; - private String truststore = ""; - private String truststoreType = ""; - private String truststorePassword = ""; - private String sslProtocol = ""; - private SensitivePropsSchema sensitiveProps; - - public SecurityPropertiesSchema() { - sensitiveProps = new SensitivePropsSchema(); - } - - public SecurityPropertiesSchema(Map map) { - keystore = getOptionalKeyAsType(map, KEYSTORE_KEY, String.class, SECURITY_PROPS_KEY, ""); - - keystoreType = getOptionalKeyAsType(map, KEYSTORE_TYPE_KEY, String.class, SECURITY_PROPS_KEY, ""); - if (!isNullOrEmpty(keystoreType)) { - if (validateStoreType(keystoreType)) { - addValidationIssue(KEYSTORE_TYPE_KEY, SECURITY_PROPS_KEY, "it is not a supported type (must be either PKCS12 or JKS format)"); - } - } - - keystorePassword = getOptionalKeyAsType(map, KEYSTORE_PASSWORD_KEY, String.class, SECURITY_PROPS_KEY, ""); - - keyPassword = getOptionalKeyAsType(map, KEY_PASSWORD_KEY, String.class, SECURITY_PROPS_KEY, ""); - - truststore = getOptionalKeyAsType(map, TRUSTSTORE_KEY, String.class, SECURITY_PROPS_KEY, ""); - - truststoreType = getOptionalKeyAsType(map, TRUSTSTORE_TYPE_KEY, String.class, SECURITY_PROPS_KEY, ""); - if (!isNullOrEmpty(truststoreType)) { - if (validateStoreType(truststoreType)) { - addValidationIssue(TRUSTSTORE_TYPE_KEY, SECURITY_PROPS_KEY, "it is not a supported type (must be either PKCS12 or JKS format)"); - } - } - - truststorePassword = getOptionalKeyAsType(map, TRUSTSTORE_PASSWORD_KEY, String.class, SECURITY_PROPS_KEY, ""); - - sslProtocol = getOptionalKeyAsType(map, SSL_PROTOCOL_KEY, String.class, SECURITY_PROPS_KEY, ""); - if (!isNullOrEmpty(sslProtocol)) { - switch (sslProtocol) { - case "SSL": - break; - case "SSLv2Hello": - break; - case "SSLv3": - break; - case "TLS": - break; - case "TLSv1": - break; - case "TLSv1.1": - break; - case "TLSv1.2": - break; - default: - addValidationIssue(SSL_PROTOCOL_KEY, SECURITY_PROPS_KEY, "it is not an allowable value of SSL protocol"); - break; - } - if (isNullOrEmpty(keystore)) { - validationIssues.add("When the '" + SSL_PROTOCOL_KEY + "' key of '" + SECURITY_PROPS_KEY + "' is set, the '" + KEYSTORE_KEY + "' must also be set"); - } else if (isNullOrEmpty(keystoreType) || isNullOrEmpty(keystorePassword) || isNullOrEmpty(keyPassword)) { - validationIssues.add("When the '" + KEYSTORE_KEY + "' key of '" + SECURITY_PROPS_KEY + "' is set, the '" + KEYSTORE_TYPE_KEY + "', '" + KEYSTORE_PASSWORD_KEY + - "' and '" + KEY_PASSWORD_KEY + "' all must also be set"); - } - - if (!isNullOrEmpty(truststore) && (isNullOrEmpty(truststoreType) || isNullOrEmpty(truststorePassword))) { - validationIssues.add("When the '" + TRUSTSTORE_KEY + "' key of '" + SECURITY_PROPS_KEY + "' is set, the '" + TRUSTSTORE_TYPE_KEY + "' and '" + - TRUSTSTORE_PASSWORD_KEY + "' must also be set"); - } - } - - sensitiveProps = getMapAsType(map, SENSITIVE_PROPS_KEY, SensitivePropsSchema.class, SECURITY_PROPS_KEY, false); - - addIssuesIfNotNull(sensitiveProps); - } - - private boolean validateStoreType(String store) { - return !store.isEmpty() && !(store.equalsIgnoreCase("JKS") || store.equalsIgnoreCase("PKCS12")); - } - - public boolean useSSL() { - return !isNullOrEmpty(sslProtocol); - } - - public String getKeystore() { - return keystore; - } - - public String getKeystoreType() { - return keystoreType; - } - - public String getKeystorePassword() { - return keystorePassword; - } - - public String getKeyPassword() { - return keyPassword; - } - - public String getTruststore() { - return truststore; - } - - public String getTruststoreType() { - return truststoreType; - } - - public String getTruststorePassword() { - return truststorePassword; - } - - public String getSslProtocol() { - return sslProtocol; - } - - public SensitivePropsSchema getSensitiveProps() { - return sensitiveProps; - } - - private static boolean isNullOrEmpty(final String string) { - return string == null || string.isEmpty(); - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SensitivePropsSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SensitivePropsSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SensitivePropsSchema.java deleted file mode 100644 index 36cd07a..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SensitivePropsSchema.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SENSITIVE_PROPS_KEY; - -/** - * - */ -public class SensitivePropsSchema extends BaseSchema { - public static final String SENSITIVE_PROPS_KEY_KEY = "key"; - public static final String SENSITIVE_PROPS_ALGORITHM_KEY = "algorithm"; - public static final String SENSITIVE_PROPS_PROVIDER_KEY = "provider"; - - private String key = ""; - private String algorithm = "PBEWITHMD5AND256BITAES-CBC-OPENSSL"; - private String provider = "BC"; - - public SensitivePropsSchema() { - } - - public SensitivePropsSchema(Map map) { - key = getOptionalKeyAsType(map, SENSITIVE_PROPS_KEY_KEY, String.class, SENSITIVE_PROPS_KEY, ""); - - algorithm = getOptionalKeyAsType(map, SENSITIVE_PROPS_ALGORITHM_KEY, String.class, SENSITIVE_PROPS_KEY, "PBEWITHMD5AND256BITAES-CBC-OPENSSL"); - - provider = getOptionalKeyAsType(map, SENSITIVE_PROPS_PROVIDER_KEY, String.class, SENSITIVE_PROPS_KEY, "BC"); - } - - public String getKey() { - return key; - } - - public String getAlgorithm() { - return algorithm; - } - - public String getProvider() { - return provider; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SwapSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SwapSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SwapSchema.java deleted file mode 100644 index ec6563f..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/SwapSchema.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.bootstrap.util.schema; - -import org.apache.nifi.minifi.bootstrap.util.schema.common.BaseSchema; - -import java.util.Map; - -import static org.apache.nifi.minifi.bootstrap.util.schema.common.CommonPropertyKeys.SWAP_PROPS_KEY; - -/** - * - */ -public class SwapSchema extends BaseSchema { - public static final String THRESHOLD_KEY = "threshold"; - public static final String IN_PERIOD_KEY = "in period"; - public static final String IN_THREADS_KEY = "in threads"; - public static final String OUT_PERIOD_KEY = "out period"; - public static final String OUT_THREADS_KEY = "out threads"; - - private Number threshold = 20000; - private String inPeriod = "5 sec"; - private Number inThreads = 1; - private String outPeriod = "5 sec"; - private Number outThreads = 4; - - public SwapSchema() { - } - - public SwapSchema(Map map) { - threshold = getOptionalKeyAsType(map, THRESHOLD_KEY, Number.class, SWAP_PROPS_KEY, 20000); - - inPeriod = getOptionalKeyAsType(map, IN_PERIOD_KEY, String.class, SWAP_PROPS_KEY, "5 sec"); - - inThreads = getOptionalKeyAsType(map, IN_THREADS_KEY, Number.class, SWAP_PROPS_KEY, 1); - - outPeriod = getOptionalKeyAsType(map, OUT_PERIOD_KEY, String.class, SWAP_PROPS_KEY, "5 sec"); - - outThreads = getOptionalKeyAsType(map, OUT_THREADS_KEY, Number.class, SWAP_PROPS_KEY, 4); - } - - public Number getThreshold() { - return threshold; - } - - public String getInPeriod() { - return inPeriod; - } - - public Number getInThreads() { - return inThreads; - } - - public String getOutPeriod() { - return outPeriod; - } - - public Number getOutThreads() { - return outThreads; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/BaseSchema.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/BaseSchema.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/BaseSchema.java deleted file mode 100644 index ec670c4..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/BaseSchema.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.bootstrap.util.schema.common; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class BaseSchema { - - /******* Validation Issue helper methods *******/ - public List<String> validationIssues = new LinkedList<>(); - - public boolean isValid() { - return validationIssues.isEmpty(); - } - - public List<String> getValidationIssues() { - return validationIssues; - } - - public String getValidationIssuesAsString() { - StringBuilder stringBuilder = new StringBuilder(); - boolean first = true; - for (String validationIssue : validationIssues) { - if (!first) { - stringBuilder.append(", "); - } - stringBuilder.append("["); - stringBuilder.append(validationIssue); - stringBuilder.append("]"); - first = false; - } - return stringBuilder.toString(); - } - - public void addValidationIssue(String keyName, String wrapperName, String reason) { - validationIssues.add("'" + keyName + "' in section '" + wrapperName + "' because " + reason); - } - - public void addIssuesIfNotNull(BaseSchema baseSchema) { - if (baseSchema != null) { - validationIssues.addAll(baseSchema.getValidationIssues()); - } - } - - /******* Value Access/Interpretation helper methods *******/ - public <T> T getOptionalKeyAsType(Map valueMap, String key, Class targetClass, String wrapperName, T defaultValue) { - return getKeyAsType(valueMap, key, targetClass, wrapperName, false, defaultValue); - } - - public <T> T getRequiredKeyAsType(Map valueMap, String key, Class targetClass, String wrapperName) { - return getKeyAsType(valueMap, key, targetClass, wrapperName, true, null); - } - - <T> T getKeyAsType(Map valueMap, String key, Class targetClass, String wrapperName, boolean required, T defaultValue) { - Object value = valueMap.get(key); - if (value == null) { - if (defaultValue != null) { - return defaultValue; - } else if(required) { - addValidationIssue(key, wrapperName, "it was not found and it is required"); - } - } else { - if (targetClass.isInstance(value)) { - return (T) value; - } else { - addValidationIssue(key, wrapperName, "it is found but could not be parsed as a " + targetClass.getSimpleName()); - } - } - return null; - } - - - public <T> T getMapAsType(Map valueMap, String key, Class targetClass, String wrapperName, boolean required) { - Object obj = valueMap.get(key); - return interpretValueAsType(obj, key, targetClass, wrapperName, required, true); - } - - public <T> T getMapAsType(Map valueMap, String key, Class targetClass, String wrapperName, boolean required, boolean instantiateIfNull) { - Object obj = valueMap.get(key); - return interpretValueAsType(obj, key, targetClass, wrapperName, required, instantiateIfNull); - } - - public void transformListToType(List list, String simpleListType, Class targetClass, String wrapperName){ - for (int i = 0; i < list.size(); i++) { - Object obj = interpretValueAsType(list.get(i), simpleListType + " number " + i, targetClass, wrapperName, false, false); - if (obj != null) { - list.set(i, obj); - } - } - } - - private <T> T interpretValueAsType(Object obj, String key, Class targetClass, String wrapperName, boolean required, boolean instantiateIfNull) { - if (obj == null) { - if (required){ - addValidationIssue(key, wrapperName, "it is a required property but was not found"); - } else { - if(instantiateIfNull) { - try { - return (T) targetClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - addValidationIssue(key, wrapperName, "no value was given, and it is supposed to be created with default values as a default, and when attempting to create it the following " + - "exception was thrown:" + e.getMessage()); - } - } - } - } else if (obj instanceof Map) { - Constructor<?> constructor; - try { - constructor = targetClass.getConstructor(Map.class); - return (T) constructor.newInstance((Map) obj); - } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - addValidationIssue(key, wrapperName, "it is found as a map and when attempting to interpret it the following exception was thrown:" + e.getMessage()); - } - } else { - try { - return (T) obj; - } catch (ClassCastException e) { - addValidationIssue(key, wrapperName, "it is found but could not be parsed as a map"); - } - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/CommonPropertyKeys.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/CommonPropertyKeys.java b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/CommonPropertyKeys.java deleted file mode 100644 index fc0a681..0000000 --- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/schema/common/CommonPropertyKeys.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.bootstrap.util.schema.common; - -public class CommonPropertyKeys { - public static final String CORE_PROPS_KEY = "Core Properties"; - public static final String FLOWFILE_REPO_KEY = "FlowFile Repository"; - public static final String SWAP_PROPS_KEY = "Swap"; - public static final String FLOW_CONTROLLER_PROPS_KEY = "Flow Controller"; - public static final String CONTENT_REPO_KEY = "Content Repository"; - public static final String COMPONENT_STATUS_REPO_KEY = "Component Status Repository"; - public static final String SECURITY_PROPS_KEY = "Security Properties"; - public static final String SENSITIVE_PROPS_KEY = "Sensitive Props"; - public static final String PROCESSORS_KEY = "Processors"; - public static final String CONNECTIONS_KEY = "Connections"; - public static final String PROVENANCE_REPORTING_KEY = "Provenance Reporting"; - public static final String REMOTE_PROCESSING_GROUPS_KEY = "Remote Processing Groups"; - public static final String INPUT_PORTS_KEY = "Input Ports"; - public static final String PROVENANCE_REPO_KEY = "Provenance Repository"; - - - public static final String NAME_KEY = "name"; - public static final String COMMENT_KEY = "comment"; - public static final String ALWAYS_SYNC_KEY = "always sync"; - public static final String YIELD_PERIOD_KEY = "yield period"; - public static final String MAX_CONCURRENT_THREADS_KEY = "max concurrent threads"; - public static final String MAX_CONCURRENT_TASKS_KEY = "max concurrent tasks"; - public static final String ID_KEY = "id"; - public static final String SCHEDULING_STRATEGY_KEY = "scheduling strategy"; - public static final String SCHEDULING_PERIOD_KEY = "scheduling period"; - public static final String USE_COMPRESSION_KEY = "use compression"; - - private CommonPropertyKeys() { - } -} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/2d1e43e7/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/util/TestConfigTransformer.java ---------------------------------------------------------------------- diff --git a/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/util/TestConfigTransformer.java b/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/util/TestConfigTransformer.java index cb373bf..51072a5 100644 --- a/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/util/TestConfigTransformer.java +++ b/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/util/TestConfigTransformer.java @@ -17,15 +17,16 @@ package org.apache.nifi.minifi.bootstrap.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.nifi.minifi.bootstrap.exception.InvalidConfigurationException; +import org.apache.nifi.minifi.commons.schema.exception.SchemaLoaderException; +import org.junit.Test; import java.io.File; import java.io.FileInputStream; -import org.apache.nifi.minifi.bootstrap.exception.InvalidConfigurationException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class TestConfigTransformer { @@ -153,8 +154,8 @@ public class TestConfigTransformer { public void handleTransformInvalidFile() throws Exception { try { ConfigTransformer.transformConfigFile("./src/test/resources/config-invalid.yml", "./target/"); - Assert.fail("Invalid configuration file was not detected."); - } catch (InvalidConfigurationException e){ + fail("Invalid configuration file was not detected."); + } catch (SchemaLoaderException e){ assertEquals("Provided YAML configuration is not a Map", e.getMessage()); } } @@ -163,7 +164,7 @@ public class TestConfigTransformer { public void handleTransformMalformedField() throws Exception { try { ConfigTransformer.transformConfigFile("./src/test/resources/config-malformed-field.yml", "./target/"); - Assert.fail("Invalid configuration file was not detected."); + fail("Invalid configuration file was not detected."); } catch (InvalidConfigurationException e){ assertEquals("Failed to transform config file due to:['threshold' in section 'Swap' because it is found but could not be parsed as a Number]", e.getMessage()); } @@ -173,8 +174,8 @@ public class TestConfigTransformer { public void handleTransformEmptyFile() throws Exception { try { ConfigTransformer.transformConfigFile("./src/test/resources/config-empty.yml", "./target/"); - Assert.fail("Invalid configuration file was not detected."); - } catch (InvalidConfigurationException e){ + fail("Invalid configuration file was not detected."); + } catch (SchemaLoaderException e){ assertEquals("Provided YAML configuration is not a Map", e.getMessage()); } } @@ -183,7 +184,7 @@ public class TestConfigTransformer { public void handleTransformFileMissingRequiredField() throws Exception { try { ConfigTransformer.transformConfigFile("./src/test/resources/config-missing-required-field.yml", "./target/"); - Assert.fail("Invalid configuration file was not detected."); + fail("Invalid configuration file was not detected."); } catch (InvalidConfigurationException e){ assertEquals("Failed to transform config file due to:['class' in section 'Processors' because it was not found and it is required]", e.getMessage()); } @@ -193,7 +194,7 @@ public class TestConfigTransformer { public void handleTransformFileMultipleProblems() throws Exception { try { ConfigTransformer.transformConfigFile("./src/test/resources/config-multiple-problems.yml", "./target/"); - Assert.fail("Invalid configuration file was not detected."); + fail("Invalid configuration file was not detected."); } catch (InvalidConfigurationException e){ assertEquals("Failed to transform config file due to:['scheduling strategy' in section 'Provenance Reporting' because it is not a valid scheduling strategy], ['class' in section " + "'Processors' because it was not found and it is required], ['source name' in section 'Connections' because it was not found and it is required]", e.getMessage());