[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r400524840 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,96 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; + +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.directory", description = "The name of the Azure Directory"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final DataLakeServiceClient storageClient = getStorageClient(context, flowFile); +final DataLakeFileSystemClient dataLakeFileSystemClient = storageClient.getFileSystemClient(fileSystem); +final DataLakeDirectoryClient directoryClient = dataLakeFileSystemClient.getDirectoryClient(directory); +final DataLakeFileClient fileClient = directoryClient.createFile(fileName); +final long length = flowFile.getSize(); +if (length > 0) { +try (final InputStream rawIn = session.read(flowFile); final BufferedInputStream in = new BufferedInputStream(rawIn)) { +fileClient.append(in, 0, length); + +} +} +fileClient.flush(length); +final Map attributes = new HashMap<>(); +attributes.put("azure.filesystem", fileSystem); +attributes.put("azure.directory", directory); +attributes.put("azure.filename",
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r400519009 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,183 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.context.PropertyContext; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; + +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Map; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor PROP_SAS_TOKEN = new PropertyDescriptor.Builder() Review comment: Minor: I overlooked it last
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397945580 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397533817 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397467797 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); Review comment: I'm not sure, but can there be any local specific characters here? As far as I know, Storage account name can only contain numbers and letters from the English alphabet. This is an automated message from the Apache Git Service. To respond to
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397520908 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), Review comment: Directory could also be added to the FF attributes. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397497110 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.build(); + +public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Directory-name")
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397535827 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397537799 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.build(); + +public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Directory-name")
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397489157 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397496187 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.build(); + +public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Directory-name")
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397459434 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397536823 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") Review comment: Typo: `','` at the end of the first sentence. No `'.'` at the end of the second sentence. The same for the Directory property. This is an automated message from the Apache Git Service. To respond to the message,
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397421868 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) Review comment: SeeAlso can be deleted. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397534869 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.build(); + +public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Directory-name")
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397412197 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") Review comment: Could you please use the same scheme for property names: lower case with hyphens like in case of `file-name` and `storage-account-name` The same for `Directory-name` below. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397405548 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/pom.xml ## @@ -92,6 +92,11 @@ nifi-distributed-cache-client-service-api test + +com.azure +azure-storage-file-datalake +12.0.0-beta.12 Review comment: 12.0.1 has been released in the meantime. Please update to this non-beta version. Could you please also move this compile dependency in front of the test dependencies? I would put it before jackson-core beacuse the jackson version override is needed by this dependency. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397416625 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureDataLakeStorageProcessor.java ## @@ -0,0 +1,154 @@ +/* + * 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.processors.azure; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.commons.lang3.StringUtils; + +import static java.util.Arrays.asList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractAzureDataLakeStorageProcessor extends AbstractProcessor { + +public static final PropertyDescriptor ACCOUNT_KEY = new PropertyDescriptor.Builder() +.name("storage-account-key").displayName("Storage Account Key") +.description("The storage account key. This is an admin-like password providing access to every container in this account. It is recommended " + +"one uses Shared Access Signature (SAS) token instead for fine-grained control with policies. " + +"There are certain risks in allowing the account key to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account key to " + +"be fetched dynamically from a flow file attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions.") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(false) +.sensitive(true).build(); + +public static final PropertyDescriptor ACCOUNT_NAME = new PropertyDescriptor.Builder() +.name("storage-account-name").displayName("Storage Account Name") +.description("The storage account name. There are certain risks in allowing the account name to be stored as a flowfile " + +"attribute. While it does provide for a more flexible flow by allowing the account name to " + +"be fetched dynamically from a flowfile attribute, care must be taken to restrict access to " + +"the event provenance data (e.g. by strictly controlling the policies governing provenance for this Processor). " + +"In addition, the provenance repositories may be put on encrypted disk partitions." + +" Instead of defining the Storage Account Name, Storage Account Key and SAS Token properties directly on the processor, " + +"the preferred way is to configure them through a controller service") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.sensitive(true).build(); + +public static final PropertyDescriptor FILESYSTEM = new PropertyDescriptor.Builder().name("Filesystem-name") +.displayName("Filesystem Name") +.description("Name of the Azure Storage File System, It is assumed to be already existing") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) +.required(true) +.build(); + +public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Directory-name")
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397482670 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397458422 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397469864 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new
[GitHub] [nifi] turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2
turcsanyip commented on a change in pull request #4126: NIFI-7103 Adding PutAzureDataLakeStorage Processor to provide native support for Azure Data Lake Storage Gen 2 URL: https://github.com/apache/nifi/pull/4126#discussion_r397462405 ## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/PutAzureDataLakeStorage.java ## @@ -0,0 +1,121 @@ +/* + * 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.processors.azure.storage; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.Locale; + +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.commons.lang3.StringUtils; + +import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.file.datalake.DataLakeDirectoryClient; +import com.azure.storage.file.datalake.DataLakeFileClient; +import com.azure.storage.file.datalake.DataLakeFileSystemClient; +import com.azure.storage.file.datalake.DataLakeServiceClient; +import com.azure.storage.file.datalake.DataLakeServiceClientBuilder; +import org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor; +import com.azure.storage.file.datalake.implementation.models.StorageErrorException; + +@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "datalake"}) +@CapabilityDescription("Puts content into an Azure Data Lake Storage Gen 2") +@SeeAlso({}) +@WritesAttributes({@WritesAttribute(attribute = "azure.filesystem", description = "The name of the Azure File System"), +@WritesAttribute(attribute = "azure.filename", description = "The name of the Azure File Name"), +@WritesAttribute(attribute = "azure.primaryUri", description = "Primary location for file content"), +@WritesAttribute(attribute = "azure.length", description = "Length of the file")}) +@InputRequirement(Requirement.INPUT_REQUIRED) + +public class PutAzureDataLakeStorage extends AbstractAzureDataLakeStorageProcessor { + +@Override +public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { +FlowFile flowFile = session.get(); +if (flowFile == null) { +return; +} +final long startNanos = System.nanoTime(); +try { +final String fileSystem = context.getProperty(FILESYSTEM).evaluateAttributeExpressions(flowFile).getValue(); +final String directory = context.getProperty(DIRECTORY).evaluateAttributeExpressions(flowFile).getValue(); +final String fileName = context.getProperty(FILE).evaluateAttributeExpressions(flowFile).getValue(); +final String accountName = context.getProperty(ACCOUNT_NAME).evaluateAttributeExpressions(flowFile).getValue(); +final String accountKey = context.getProperty(ACCOUNT_KEY).evaluateAttributeExpressions(flowFile).getValue(); +final String sasToken = context.getProperty(PROP_SAS_TOKEN).evaluateAttributeExpressions(flowFile).getValue(); +final String endpoint = String.format(Locale.ROOT, "https://%s.dfs.core.windows.net;, accountName); +DataLakeServiceClient storageClient; +if (StringUtils.isNotBlank(accountKey)) { +final StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, +accountKey); +storageClient = new