Component family |
MapReduce/Output |
|
Function |
tGlobalVarLoad defines variables |
|
Purpose |
tGlobalVarLoad sets variables |
|
Basic settings |
Schema and Edit |
A schema is a row description. It defines the number of fields to be processed and passed on The columns of the schema are set to be variable keys and the data |
Built-In: You create and store the schema locally for this |
||
Repository: You have already created the schema and |
||
Click Edit schema to make changes to the schema. If the
|
||
Global Variables |
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
Usage |
This component is placed at the end of a process. It generates |
|
Limitation |
n/a |
In this scenario, a six-component Job is created to calculate the average salary of a
set of sample data and select the salaries above the average.
The sample data to be used is already stored in the HDFS system to be used and read as
follows:
1 2 3 4 5 6 7 8 9 10 |
1 Lyndon 1200 2 Ronald 3500 3 Ulysses 5000 4 Harry 2000 5 Garfield 1800 6 James 3300 7 Chester 4200 8 Dwight 2200 9 Jimmy 2800 10 Herbert 3500 |
You can read that the separator between the fields is /t
and the three columns of the sample data are id,
name and salary.
You can use the tHDFSOutput component to write the
sample data in the HDFS system to be used. For further information, see tHDFSOutput.
-
In the Integration perspective
of the Studio, create an empty Map/Reduce Job from the
Job Designs node in the Repository tree view.For further information about how to create a Map/Reduce Job, see
Talend Big Data Getting Started Guide. -
In the workspace, enter the name of the component to be used and select this component
from the list that appears. In this scenario, the components are tAggregateRow, tGlobalVarLoad, tMap,
tLogRow and two tHDFSInput (labelled customer in this scenario) components. -
Connect one of the tHDFSInput components
to tAggregateRow using the Row > Main link and then do the same to link
tAggregateRow to tGlobalVarLoad.This subjob is used to calculate the average salary and set this average into a reusable
variable. -
Connect the same tHDFSInput component to
the other tHDFSInput component using the
Trigger > On Subjob Ok link. -
Connect this second tHDFSInput component
to tMap using the Row
> Main link, then do the same to connect tMap to tLogRow
and in the popup dialog box, give this link a name you want to use.This subjob is used to select the salaries above the average.
-
Click Run to open its view and then click the
Hadoop Configuration tab to display its
view for configuring the Hadoop connection for this Job.This view looks like the image below:
-
From the Property type list, select Built-in. If you have created the connection to be
used in Repository, then select Repository and thus the Studio will reuse that set of
connection information for this Job.For further information about how to create an Hadoop connection in
Repository, see the chapter describing the Hadoop
cluster node of the Talend Big Data Getting Started Guide. -
In the Version area, select the Hadoop
distribution to be used and its version. If you cannot find from the list the
distribution corresponding to yours, select Custom so as to connect to a Hadoop distribution not officially
supported in the Studio.For a step-by-step example about how to use this Custom option, see Connecting to a custom Hadoop distribution.
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 with the path
value explicitly pointing to the MapReduce framework archive of your
cluster. For
example:1mapreduce.application.framework.path=/hdp/apps/2.2.0.0-2041/mapreduce/mapreduce.tar.gz#mr-framework -
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. For
further information about Talend Jobserver, see
Talend
Installation and Upgrade Guide.
-
-
In the Name node field, enter the location of
the master node, the NameNode, of the distribution to be used. For example,
hdfs://tal-qa113.talend.lan:8020.If you are using a MapR distribution, you can simply leave maprfs:/// as it is in this field; then the MapR
client will take care of the rest on the fly for creating the connection. The
MapR client must be properly installed. For further information about how to set
up a MapR client, see the following link in MapR’s documentation: http://doc.mapr.com/display/MapR/Setting+Up+the+Client -
In the Job tracker field, enter the location
of the JobTracker of your distribution. For example, tal-qa114.talend.lan:8050.Note that the notion Job in this term JobTracker designates the MR or the
MapReduce jobs described in Apache’s documentation on http://hadoop.apache.org/.If you use YARN in your Hadoop cluster such as Hortonworks Data Platform V2.0.0 or Cloudera CDH4.3 + (YARN mode), you need to specify the location
of the Resource Manager instead of the
Jobtracker. Then you can continue to set the following parameters depending on
the configuration of the Hadoop cluster to be used (if you leave the check box
of a parameter clear, then at runtime, the configuration about this parameter in
the Hadoop cluster to be used will be ignored ):-
Select the Set resourcemanager scheduler
address check box and enter the Scheduler address in
the field that appears. -
Select the Set jobhistory address
check box and enter the location of the JobHistory server of the
Hadoop cluster to be used. This allows the metrics information of
the current Job to be stored in that JobHistory server. -
Select the Set staging directory
check box and enter this directory defined in your Hadoop cluster
for temporary files created by running programs. Typically, this
directory can be found under the yarn.app.mapreduce.am.staging-dir property in the
configuration files such as yarn-site.xml or mapred-site.xml of your distribution. -
Select the Use datanode hostname
check box to allow the Job to access datanodes via their hostnames.
This actually sets the dfs.client.use.datanode.hostname property to
true. When connecting to a
S3N filesystem, you must select this check box.
-
-
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.In addition, since this component performs Map/Reduce computations, you also need to
authenticate the related services such as the Job history server and the Resource manager or
Jobtracker depending on your distribution in the corresponding field. These principals can
be found in the configuration files of your distribution. For example, in a CDH4
distribution, the Resource manager principal is set in the yarn-site.xml file and the Job history principal in the mapred-site.xml file.If you need to use a Kerberos keytab file to log in, select Use a
keytab to authenticate. 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.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. -
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. -
In the Temp folder field, enter the path in
HDFS to the folder where you store the temporary files generated during
Map/Reduce computations. -
Leave the default value of the Path separator in server as
it is, unless you have changed the separator used by your Hadoop distribution’s host machine
for its PATH variable or in other words, that separator is not a colon (:). In that
situation, you must change this value to the one you are using in that host. -
Leave the Clear temporary folder check box
selected, unless you want to keep those temporary files. -
Leave the Compress intermediate map output to reduce
network traffic check box selected, so as to spend shorter time
to transfer the mapper task partitions to the multiple reducers.However, if the data transfer in the Job is negligible, it is recommended to
clear this check box to deactivate the compression step, because this
compression consumes extra CPU resources. -
If you need to use custom Hadoop properties, complete the Hadoop properties table with the property or
properties to be customized. Then at runtime, these changes will override the
corresponding default properties used by the Studio for its Hadoop
engine.For further information about the properties required by Hadoop, see Apache’s
Hadoop documentation on http://hadoop.apache.org, or
the documentation of the Hadoop distribution you need to use. -
If the Hadoop distribution to be used is Hortonworks Data Platform V1.2 or Hortonworks
Data Platform V1.3, you need to set proper memory allocations for the map and reduce
computations to be performed by the Hadoop system.In that situation, you need to enter the values you need in the Mapred
job map memory mb and the Mapred job reduce memory
mb fields, respectively. By default, the values are both 1000 which are normally appropriate for running the
computations.If the distribution is YARN, then the memory parameters to be set become Map (in Mb), Reduce (in Mb) and
ApplicationMaster (in Mb), accordingly. These fields
allow you to dynamically allocate memory to the map and the reduce computations and the
ApplicationMaster of YARN.
For further information about this Hadoop
Configuration tab, see the section describing how to configure the Hadoop
connection for a Talend Map/Reduce Job of the Talend Big Data Getting Started Guide.
For further information about the Resource Manager, its scheduler and the
ApplicationMaster, see YARN’s documentation such as http://hortonworks.com/blog/apache-hadoop-yarn-concepts-and-applications/.
For further information about how to determine YARN and MapReduce memory configuration
settings, see the documentation of the distribution you are using, such as the following
link provided by Hortonworks: http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.0.6.0/bk_installing_manually_book/content/rpm-chap1-11.html.
-
Double-click either of the two tHDFSInput
components to display its Basic settings
view.Since these two tHDFSInput components are used to read
the same source data and are configured the same way. You need to configure
both of them using the procedure explained in this section. -
Click the […] button next to Edit schema to open the schema editor.
-
Click the [+] button three times to add
three rows and in the Column column, rename
them to id, name and salary,
respectively. -
In the Type column of the salary row, select Double.
-
Click OK to validate these changes and
accept the propagation prompted by the pop-up dialog box. -
In the Folder/File field, browse to the
sample data to be processed in the HDFS system. -
In the File type area, select Text file from the Type list.
-
In the Field separator field, enter
.
-
Double-click tAggregateRow to open its
Component view. -
Click the […] button next to Edit schema to open the schema editor.
-
In the table of the tAggregateRow schema,
click the [+] button once to add one row
and in the Column column, rename it to
avg. -
In the Type column of the salary row, select Double.
-
Click OK to validate these changes and
accept the propagation prompted by the pop-up dialog box. -
Under the Operations table, click the
[+] button to add one row and configure
the following columns of this row to define the calculation of the average salary.-
Output column: select the
column of the output schema in which the average salary is
stored. In this scenario, it is avg. -
Function: select the
avg function to calculate
the average. -
Input column position: select
the column of the input schema used to provide the source data
of the calculation.
-
-
Double-click tGlobalVarLoad to open its
Component view. -
Click the Sync columns button to ensure
that this component retrieves the avg
column of the tAggregateRow component’s
schema. This way the tGlobalVarLoad
component defines the avg variable using
the calculated average salary.
-
Double-click tMap to open the map
editor.Note that the tHDFSInput component linked
to this tMap has been configured along with
the other tHDFSInput component linked to
tAggregateRow. -
From the table representing the input flow (on the left side), select all
the three columns and drop them to the table representing the output flow
(on the right side). -
On the table of the input flow, click the
button to display the filter
expression panel. -
In this filter expression panel, enter
1row5.salary > Double.valueOf(String.valueOf(globalMap.get("avg")))This expression allows the tMap component
to select only the salaries above the average calculated by tAggregateRow.Note that the row5 in this expression
is the ID of the input row to the tMap
component and therefore, it might be another value in your scenario. -
Click Apply and then OK to validate these changes.
Then you can run this Job.
The tLogRow component is used to present the
execution result of the Job.
-
If you want to configure the presentation mode on its Component view, double-click the tLogRow component to open the Component view and then in the Mode area, select the Table (print
values in cells of a table) option. -
Press F6 to run this Job.
Once done, the Run view is opened automatically,
where you can check the execution result.
As presented at the beginning of this scenario, the average salary of the sample data is
2950, and you can read that the salary
records above the average have been filtered from the sample data.