Class PutAzureDataLakeStorage
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor
org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@Tags({"azure","microsoft","cloud","storage","adlsgen2","datalake"})
@SeeAlso({DeleteAzureDataLakeStorage.class,FetchAzureDataLakeStorage.class,ListAzureDataLakeStorage.class})
@CapabilityDescription("Writes the contents of a FlowFile as a file on Azure Data Lake Storage Gen 2")
@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") @WritesAttribute(attribute="azure.primaryUri",description="Primary location for file content") @WritesAttribute(attribute="azure.length",description="The length of the Azure File")
@InputRequirement(INPUT_REQUIRED)
public class PutAzureDataLakeStorage
extends AbstractAzureDataLakeStorageProcessor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic longprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final Stringprotected static final org.apache.nifi.components.PropertyDescriptorFields inherited from class org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor
REL_FAILURE, REL_SUCCESS, TEMP_FILE_DIRECTORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAttributeMap(String fileSystem, String originalDirectory, String fileName, String fileUrl, long length) private voidcreateDirectoryIfNotExists(com.azure.storage.file.datalake.DataLakeDirectoryClient directoryClient) private com.azure.storage.file.datalake.DataLakeFileClientcreateFile(com.azure.storage.file.datalake.DataLakeDirectoryClient directoryClient, String fileName, String conflictResolution) Creates the file on Azure for 'Simple Write' strategy.private StringcreatePath(String baseDirectory, String path) private com.azure.storage.file.datalake.DataLakeFileSystemClientgetFileSystemClient(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, String fileSystem) protected List<org.apache.nifi.components.PropertyDescriptor> private com.azure.storage.file.datalake.DataLakeFileClienthandleDataLakeStorageException(com.azure.storage.file.datalake.models.DataLakeStorageException dataLakeStorageException, String destinationPath, String conflictResolution) voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) private voidremoveFile(com.azure.storage.file.datalake.DataLakeFileClient fileClient) (package private) com.azure.storage.file.datalake.DataLakeFileClientrenameFile(com.azure.storage.file.datalake.DataLakeFileClient sourceFileClient, String destinationDirectory, String destinationFileName, String conflictResolution) This method serves as a "commit" for the upload process in case of 'Write and Rename' strategy.private static voiduploadContent(com.azure.storage.file.datalake.DataLakeFileClient fileClient, InputStream in, long length) private voiduploadFile(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, Optional<FileResource> fileResourceFound, long transferSize, com.azure.storage.file.datalake.DataLakeFileClient fileClient) Methods inherited from class org.apache.nifi.processors.azure.AbstractAzureDataLakeStorageProcessor
getRelationships, getStorageClient, onScheduled, onStoppedMethods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateProperties, migrateRelationships
-
Field Details
-
FAIL_RESOLUTION
- See Also:
-
REPLACE_RESOLUTION
- See Also:
-
IGNORE_RESOLUTION
- See Also:
-
MAX_CHUNK_SIZE
public static long MAX_CHUNK_SIZE -
CONFLICT_RESOLUTION
public static final org.apache.nifi.components.PropertyDescriptor CONFLICT_RESOLUTION -
WRITING_STRATEGY
protected static final org.apache.nifi.components.PropertyDescriptor WRITING_STRATEGY -
BASE_TEMPORARY_PATH
public static final org.apache.nifi.components.PropertyDescriptor BASE_TEMPORARY_PATH -
PROPERTIES
-
-
Constructor Details
-
PutAzureDataLakeStorage
public PutAzureDataLakeStorage()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor- Throws:
org.apache.nifi.processor.exception.ProcessException
-
getFileSystemClient
private com.azure.storage.file.datalake.DataLakeFileSystemClient getFileSystemClient(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, String fileSystem) -
createAttributeMap
-
createDirectoryIfNotExists
private void createDirectoryIfNotExists(com.azure.storage.file.datalake.DataLakeDirectoryClient directoryClient) -
uploadFile
private void uploadFile(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, Optional<FileResource> fileResourceFound, long transferSize, com.azure.storage.file.datalake.DataLakeFileClient fileClient) throws Exception - Throws:
Exception
-
uploadContent
private static void uploadContent(com.azure.storage.file.datalake.DataLakeFileClient fileClient, InputStream in, long length) throws IOException - Throws:
IOException
-
createFile
private com.azure.storage.file.datalake.DataLakeFileClient createFile(com.azure.storage.file.datalake.DataLakeDirectoryClient directoryClient, String fileName, String conflictResolution) Creates the file on Azure for 'Simple Write' strategy. Upon upload, a 0-byte file is created, then the payload is appended to it. Because of that, a work-in-progress file is available for readers before the upload is complete.- Parameters:
directoryClient- directory client of the uploaded file's parent directoryfileName- name of the uploaded fileconflictResolution- conflict resolution strategy- Returns:
- the file client of the uploaded file or
nullif the file already exists and conflict resolution strategy is 'ignore' - Throws:
org.apache.nifi.processor.exception.ProcessException- if the file already exists and the conflict resolution strategy is 'fail'; also in case of other errors
-
renameFile
com.azure.storage.file.datalake.DataLakeFileClient renameFile(com.azure.storage.file.datalake.DataLakeFileClient sourceFileClient, String destinationDirectory, String destinationFileName, String conflictResolution) This method serves as a "commit" for the upload process in case of 'Write and Rename' strategy. In order to prevent work-in-progress files from being available for readers, a temporary file is written first, and then renamed/moved to its final destination. It is not an efficient approach in case of conflicts because FlowFiles are uploaded unnecessarily, but it is a calculated risk because consistency is more important for 'Write and Rename' strategy.Visible for testing
- Parameters:
sourceFileClient- file client of the temporary filedestinationDirectory- final location of the uploaded filedestinationFileName- final name of the uploaded fileconflictResolution- conflict resolution strategy- Returns:
- the file client of the uploaded file or
nullif the file already exists and conflict resolution strategy is 'ignore' - Throws:
org.apache.nifi.processor.exception.ProcessException- if the file already exists and the conflict resolution strategy is 'fail'; also in case of other errors
-
handleDataLakeStorageException
-
createPath
-
removeFile
private void removeFile(com.azure.storage.file.datalake.DataLakeFileClient fileClient)
-