HDFS ZipFile Writer

The HDFS ZipFile Writer Snap reads in-coming data and writes it to a ZIP file in an HDFS directory.

Overview

Use the HDFS ZipFile Writer Snap to read in-coming data and write it to a ZIP file in an HDFS directory. This Snap also enables you to specify file access permissions for the new ZIP file. You can also configure how the Snap handles the new ZIP file if the destination directory already has another ZIP file with the same name.

For the HDFS protocol, use a SnapLogic on-premises Groundplex and ensure that its instance is within the Hadoop cluster and that SSH authentication is established.

Note: The HDFS protocol supported by this Snap is HDFS 2.4.0. This Snap supports both HDFS & ABFS (Azure Data Lake Storage Gen 2) protocols.


Prerequisites

The user executing the Snap must have Write permissions on the concerned directory.

Configuring Accounts

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Configuring Hadoop Accounts for information on setting up this type of account.

Snap views

Type Format Number of Views Examples of Upstream and Downstream Snaps Description
Input Binary Min: 1

Max: 1

  • JSON Formatter
  • HDFS Reader
  • File Reader
Binary data stream containing documents to be written to a ZIP file.
Output Document Min: 0

Max: 1

  • Mapper
  • HDFS Reader
Zipped file containing the incoming documents.
Error Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:
  • Stop Pipeline Execution: Stops the current pipeline execution if the Snap encounters an error.
  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Modes

Snap settings

Note: Learn about the common controls in the Snap settings dialog.
Field/Field set Description
Label

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: HDFS ZipFile Writer

Example: HDFS ZipFile Writer

Directory

The URL for the data source (directory). The Snap supports both HDFS and ABFS(S) protocols.

Syntax for a typical HDFS URL:

hdfs://hadoopcluster.domain.com:8020/<user>/<folder_details>

Syntax for a typical ABFS and an ABFSS URL:

abfs:///<filesystem>/<path>/
abfs://<filesystem>@<accountname>.<endpoint>/<path>
abfss:///<filesystem>/<path>/
abfss://<filesystem>@<accountname>.<endpoint>/<path>

When you use the ABFS protocol to connect to an endpoint, the account name and endpoint details provided in the URL override the corresponding values in the Account Settings fields.

Note: With the ABFS protocol, SnapLogic creates a temporary file to store the incoming data. Therefore, the hard drive where the JCC is running should have enough space to temporarily store all the account data coming in from ABFS.

Default value: [None]

File

The relative path and name of the file that must be created post execution.

  • sample.zip
  • tmp/another.zip
  • $filename

Example:

Default value: [None]

User Impersonation

Select this check box to enable user impersonation.

Note: For encryption zones, use user impersonation.

Default value: Not selected

File Action

Required. Use this field to specify what you want the Snap to do if the file you want it to create already exists. Available options are: Overwrite, Ignore, and Error.

  • Overwrite: If the target file exists, the Snap overwrites the file.
  • Ignore: If the file already exists, the Snap neither throws an exception nor does it overwrite the file, but creates an output document indicating that the new data has been ignored.
  • Error: The error displays in the Pipeline Run Log if the file already exists.

Default value: Overwrite

File Permissions

File permission sets to be assigned to the file. To assign file permissions:

  1. Click the + button against File permissions. This adds a row to the fieldset.
  2. Click the Suggestible icon in the User type field and select the user type for which you want to enable access. This drop-down offers the following options:
    • Owner: This is the user account under whose name the new file will be created.
    • Group: This is the user group to which the user being impersonated belongs.
    • Others: These are all other users who have at least Read access to the concerned directory.
  3. Click the Suggestible icon in the File permissions field and select the permission you want to enable for the user type selected in the User type field.
Base directory Enter here the name of the root directory in the ZIP file.
Use input view label

If selected, the input view label is used for all names of the files added to the zip file. Otherwise, the input view ID is used instead, when input the binary stream does not have its content-location in its header. When this option is selected, if there are more than one binary input streams in an input view, for the second input stream and after, the file names will be the input view label appended with '_n'. If the label is in the format of 'name.ext', '_n' will be append to the 'name', e.g. name_2.ext for the second input stream.

Example: If this option is selected, if Base directory is testFolder and the input view label is test.csv, the file name for the first binary input stream in that input view will be testFolder/test.csv, and the second, testFolder/test_2.csv, and the third, testFolder/test_3.csv, and so on.

Default value: Not selected

Snap Execution
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute. Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only. Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled. Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

Example: Validate & Execute

Note: The binary document header content-location of the HDFS ZipFile Writer input is the name within the ZIP file. (Example: foo.txt). The Snap does not include the 'base directory'. It could contain subdirectories though. On the other hand, the binary document header content-location of the output of the HDFS ZipFile Reader is the name of the ZIP file, the base directory, and the content location provided to the writer. Thus, while each Snap works well independent of each other, it's currently not possible to have a Reader > Writer > Reader combination in a pipeline without using other intermediate Snaps to provide the binary document header information.

Troubleshooting

Writing to S3 files with HDFS version CDH 5.8 or later

When running HDFS version later than CDH 5.8, the Hadoop Snap Pack may fail to write to S3 files. To overcome this, make the following changes in the Cloudera manager:

  1. Go to HDFS configuration.
  2. In Cluster-wide Advanced Configuration Snippet (Safety Valve) for core-site.xml, add an entry with the following details:
    • Name: fs.s3a.threads.max
    • Value: 15
  3. Click Save.
  4. Restart all the nodes.
  5. Under Restart Stale Services, select Re-deploy client configuration.
  6. Click Restart Now.