August 15, 2023

tHDFSExist – Docs for ESB 6.x

tHDFSExist

Checks whether a file exists in a specific directory in HDFS.

tHDFSExist Standard properties

These properties are used to configure tHDFSExist running in the Standard Job framework.

The Standard
tHDFSExist component belongs to the Big Data and the File families.

The component in this framework is available when you are using one of the Talend solutions with Big Data.

Basic settings

Property type

Either Built-in or Repository

Built-in: No property data stored
centrally.

Repository: Select the repository
file in which the properties are stored. The fields that follow are
completed automatically using the data retrieved.

Use an existing connection

Select this check box and in the Component
List
click the relevant connection component to reuse the connection
details you already defined.

Note that when a Job contains the parent Job and the child Job, Component List presents only the connection components in the same
Job level.

Distribution

Select the cluster you are using from the drop-down list. The options in the
list vary depending on the component you are using. Among these options, the following
ones requires specific configuration:

  • If available in this Distribution drop-down list, the Microsoft HD Insight option allows you to
    use a Microsoft HD Insight cluster. For this purpose, you need to configure
    the connections to the WebHCat service, the HD Insight service and the
    Windows Azure Storage service of that cluster in the areas that are
    displayed. A demonstration video about how to configure this connection is
    available in the following link: https://www.youtube.com/watch?v=A3QTT6VsNoM.

  • If you select Amazon
    EMR
    , you can find more details about how
    to configure an Amazon EMR cluster in Talend Help Center (https://help.talend.com)
    .

  • The Custom option
    allows you to connect to a cluster different from any of the distributions
    given in this list, that is to say, to connect to a cluster not officially
    supported by
    Talend
    .

  1. Select Import from existing
    version
    to import an officially supported distribution as base
    and then add other required jar files which the base distribution does not
    provide.

  2. Select Import from zip to
    import the configuration zip for the custom distribution to be used. This zip
    file should contain the libraries of the different Hadoop elements and the index
    file of these libraries.

    In
    Talend

    Exchange, members of
    Talend
    community have shared some ready-for-use configuration zip files
    which you can download from this Hadoop configuration
    list and directly use them in your connection accordingly. However, because of
    the ongoing evolution of the different Hadoop-related projects, you might not be
    able to find the configuration zip corresponding to your distribution from this
    list; then it is recommended to use the Import from
    existing version
    option to take an existing distribution as base
    to add the jars required by your distribution.

    Note that custom versions are not officially supported by

    Talend
    .
    Talend
    and its community provide you with the opportunity to connect to
    custom versions from the Studio but cannot guarantee that the configuration of
    whichever version you choose will be easy, due to the wide range of different
    Hadoop distributions and versions that are available. As such, you should only
    attempt to set up such a connection if you have sufficient Hadoop experience to
    handle any issues on your own.

    Note:

    In this dialog box, the active check box must be kept
    selected so as to import the jar files pertinent to the connection to be
    created between the custom distribution and this component.

    For a step-by-step example about how to connect to a custom
    distribution and share this connection, see Connecting to a custom Hadoop distribution.

Hadoop version

Select the version of the Hadoop distribution you are using. The available
options vary depending on the component you are using. Along with the evolution of
Hadoop, please note the following changes:

  • If you use Hortonworks Data
    Platform V2.2
    , the configuration files of your cluster might
    be using environment variables such as ${hdp.version}. If this is your situation, you need to set the mapreduce.application.framework.path property in
    the Hadoop properties table of this
    component with the path value explicitly pointing to the MapReduce framework
    archive of your cluster. For
    example:
  • If you use Hortonworks Data
    Platform V2.0.0
    , the type of the operating system for
    running the distribution and a
    Talend
    Job must be the same, such as Windows or Linux. Otherwise, you
    have to use
    Talend
    Jobserver to execute the Job in the same type of operating
    system in which the Hortonworks Data Platform
    V2.0.0
    distribution you are using is run.

Use kerberos authentication

If you are accessing the Hadoop cluster running
with Kerberos security, select this check box, then, enter the Kerberos
principal name for the NameNode in the field displayed. This enables you to use
your user name to authenticate against the credentials stored in Kerberos.

  • If this cluster is a MapR cluster of the version 4.0.1 or later, you can set the MapR
    ticket authentication configuration in addition or as an alternative by following the
    explanation in Connecting to a security-enabled MapR.

    Keep in mind that this configuration generates a new MapR security ticket for the username
    defined in the Job in each execution. If you need to reuse an existing ticket issued for the
    same username, leave both the Force MapR ticket
    authentication
    check box and the Use Kerberos
    authentication
    check box clear, and then MapR should be able to automatically
    find that ticket on the fly.

This check box is available depending on the Hadoop distribution you are
connecting to.

Use a keytab to authenticate

Select the Use a keytab to authenticate
check box to log into a Kerberos-enabled system using a given keytab file. A keytab
file contains pairs of Kerberos principals and encrypted keys. You need to enter the
principal to be used in the Principal field and
the access path to the keytab file itself in the Keytab field. This keytab file must be stored in the machine in
which your Job actually runs, for example, on a Talend Jobserver.

Note that the user that executes a keytab-enabled Job is not necessarily
the one a principal designates but must have the right to read the keytab file being
used. For example, the user name you are using to execute a Job is user1 and the principal to be used is guest; in this
situation, ensure that user1 has the right to read the keytab
file to be used.

NameNode URI

Type in the URI of the Hadoop NameNode, the master node of a Hadoop system. For
example, we assume that you have chosen a machine called masternode as the NameNode, then the location is hdfs://masternode:portnumber. If you are using WebHDFS, the location should be
webhdfs://masternode:portnumber; if this WebHDFS is secured
with SSL, the scheme should be swebhdfs and you need to use
a tLibraryLoad in the Job to load the library required by
the secured WebHDFS.

User name

The User name field is available when you are not using
Kerberos to authenticate. In the User name field, enter the
login user name for your distribution. If you leave it empty, the user name of the machine
hosting the Studio will be used.

Group

Enter the membership including the authentication user under which the HDFS instances were
started. This field is available depending on the distribution you are using.

HDFS directory

Browse to, or enter the path pointing to the data to be used in the file system.

File name or relative path

Enter the name of the file you want to check whether this file
exists. Or if needs be, browse to the file or enter the path to the
file, relative to the directory you entered in HDFS directory.

Advanced settings

Hadoop properties


Talend Studio
uses a default configuration for its engine to perform
operations in a Hadoop distribution. If you need to use a custom configuration in a specific
situation, complete this table with the property or properties to be customized. Then at
runtime, the customized property or properties will override those default ones.

  • Note that if you are using the centrally stored metadata from the Repository, this table automatically inherits the
    properties defined in that metadata and becomes uneditable unless you change the
    Property type from Repository to Built-in.

For further information about the properties required by Hadoop and its related systems such
as HDFS and Hive, see the documentation of the Hadoop distribution you
are using or see Apache’s Hadoop documentation on http://hadoop.apache.org/docs and then select the version of the documentation you want. For demonstration purposes, the links to some properties are listed below:

tStatCatcher Statistics

Select this check box to gather the Job processing
metadata at a Job level as well as at each component level.

Global Variables

Global Variables

EXISTS: the result of whether a specified file exists.
This is a Flow variable and it returns a boolean.

FILENAME: the name of the file processed. This is an
After variable and it returns a string.

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see
Talend Studio

User Guide.

Usage

Usage rule

tHDFSExist is a standalone
component.

Dynamic settings

Click the [+] button to add a row in the
table and fill the Code field with a context variable
to choose your HDFS connection dynamically from multiple connections planned in your
Job. This feature is useful when you need to access files in different HDFS systems or
different distributions, especially when you are working in an environment where you
cannot change your Job settings, for example, when your Job has to be deployed and
executed independent of
Talend Studio
.

The Dynamic settings table is
available only when the Use an existing
connection
check box is selected in the Basic settings view. Once a dynamic parameter is
defined, the Component List box in the
Basic settings view becomes unusable.

For examples on using dynamic parameters, see Scenario: Reading data from databases through context-based dynamic connections and Scenario: Reading data from different MySQL databases using dynamically loaded connection parameters. For more information on Dynamic
settings
and context variables, see
Talend Studio User Guide
.

Prerequisites

The Hadoop distribution must be properly installed, so as to guarantee the interaction
with
Talend Studio
. The following list presents MapR related information for
example.

  • Ensure that you have installed the MapR client in the machine where the Studio is,
    and added the MapR client library to the PATH variable of that machine. According
    to MapR’s documentation, the library or libraries of a MapR client corresponding to
    each OS version can be found under MAPR_INSTALL
    hadoophadoop-VERSIONlib
    ative
    . For example, the library for
    Windows is lib
    ativeMapRClient.dll
    in the MapR
    client jar file. For further information, see the following link from MapR: http://www.mapr.com/blog/basic-notes-on-configuring-eclipse-as-a-hadoop-development-environment-for-mapr.

    Without adding the specified library or libraries, you may encounter the following
    error: no MapRClient in java.library.path.

  • Set the -Djava.library.path argument, for example, in the Job Run VM arguments area
    of the Run/Debug view in the [Preferences] dialog box in the Window menu. This argument provides to the Studio the path to the
    native library of that MapR client. This allows the subscription-based users to make
    full use of the Data viewer to view locally in the
    Studio the data stored in MapR.

For further information about how to install a Hadoop distribution, see the manuals
corresponding to the Hadoop distribution you are using.

Limitation

JRE 1.6+ is required.

Scenario: Checking the existence of a file in HDFS

This scenario applies only to a Talend solution with Big Data.

In this scenario, the two-component Job checks whether a specific file exists in HDFS
and returns a message to indicate the result of the verification.

In the real-world practice, you can take further action to process the file checked
according to the verification result, using the other HDFS components provided with the
Studio.

use_case-thdfsexist1.png

Launch the Hadoop distribution in which you want to check the existence of a
particular file. Then, proceed as follows:

Linking the components

  1. In the
    Integration
    perspective of

    Talend Studio
    , create an empty Job, named hdfsexist_file for example, from the
    Job Designs
    node in the Repository tree view.

    For further information about how to create a Job, see the
    Talend Studio

    User
    Guide
    .
  2. Drop tHDFSExist and tMsgBox onto the workspace.
  3. Connect them using the Trigger > Run if
    link.

Configuring the connection to HDFS

  1. Double-click tHDFSExist to open its
    Component view.

    use_case-thdfsexist2.png

  2. In the Version area, select the Hadoop
    distribution you are connecting to and its version.
  3. In the Connection area, enter the values
    of the parameters required to connect to the HDFS.

    In the real-world practice, you may use tHDFSConnection to create a connection and reuse it from the
    current component. For further information, see tHDFSConnection.
  4. In the HDFS Directory field, browse to,
    or enter the path to the folder where the file to be checked is. In this
    example, browse to /user/ychen/data/hdfs/out/dest.
  5. In the File name or relative path field,
    enter the name of the file you want to check the existence. For example,
    output.csv.

Defining the message to be returned

  1. Double-click tMsgBox to open its
    Component view.

    use_case-thdfsexist3.png

  2. In the Title field, enter the title to be
    used for the pop-up message box to be created.
  3. In the Buttons list, select OK. This defines the button to be displayed on
    the message box.
  4. In the Icon list, select Icon information.
  5. In the Message field, enter the message
    you want to displayed once the file checking is done. In this example, enter
    “This file does not exist!”.

Defining the condition

  1. Click the If link to open the Basic settings view, where you are able to define
    the condition for checking the existence of this file.

    use_case-thdfsexist4.png

  2. In the Condition box, press Ctrl+Space to access the variable list and select
    the global variable EXISTS. Type an
    exclamation mark before the variable to negate the meaning of the
    variable.

Executing the Job

Press F6 to execute this Job.

Once done, a message box pops up to indicate that this file called output.csv does not exist in the directory you defined
earlier.

use_case-thdfsexist5.png

In the HDFS we check the existence of the file, browse to this directory
specified, you can see that this file does not exist.

use_case-thdfsexist6.png


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x