198 lines
5.3 KiB
Plaintext
198 lines
5.3 KiB
Plaintext
<%@ jet
|
|
package="org.talend.designer.codegen.translators"
|
|
imports="
|
|
org.talend.core.model.process.INode
|
|
org.talend.core.model.temp.ECodePart
|
|
org.talend.core.model.process.IConnection
|
|
org.talend.core.model.metadata.IMetadataTable
|
|
org.talend.core.model.process.EConnectionType
|
|
org.talend.core.model.process.ElementParameterParser
|
|
org.talend.designer.codegen.config.CodeGeneratorArgument
|
|
java.util.List
|
|
"
|
|
class="ComponentPartHeader"
|
|
%>
|
|
|
|
<%
|
|
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
|
INode node = (INode)codeGenArgument.getArgument();
|
|
String cid = node.getUniqueName();
|
|
ECodePart codePart = codeGenArgument.getCodePart();
|
|
boolean stat = codeGenArgument.isStatistics();
|
|
|
|
String currentIncomingName = (String)codeGenArgument.getIncomingName();
|
|
%>
|
|
# +-------------------------------------------------------------------------+
|
|
# | [<%=node.getUniqueName() %> <%=codePart %> ] start
|
|
# +-------------------------------------------------------------------------+
|
|
|
|
$current_component="<%=node.getUniqueName() %>";
|
|
|
|
|
|
<%
|
|
if (codePart.equals(ECodePart.BEGIN)) {
|
|
%>
|
|
|
|
=head1 <%=ElementParameterParser.getValue(node, "__COMPONENT_NAME__") %> <%=node.getUniqueName() %>
|
|
<%=ElementParameterParser.getValue(node, "__COMMENT__") %>
|
|
=cut
|
|
|
|
$_globals{<%=node.getUniqueName() %>}{OK} = false;
|
|
$_globals{<%=node.getUniqueName() %>}{start} = [gettimeofday];
|
|
|
|
<%
|
|
if (stat) {
|
|
for (IConnection conn : node.getIncomingConnections()) {
|
|
EConnectionType lineStyle = conn.getLineStyle();
|
|
|
|
if (EConnectionType.FLOW_MAIN == lineStyle
|
|
|| (EConnectionType.FLOW_MERGE == lineStyle
|
|
&& conn.getName().equals(currentIncomingName))) {
|
|
%>
|
|
$count_<%=conn.getName() %> = 0;
|
|
$last_stat_update_of_<%=conn.getName() %> = time();
|
|
SendStat(
|
|
'<%=conn.getName() %>'.(defined $exec_number ? '.'.$exec_number : ''),
|
|
$count_<%=conn.getName() %>,
|
|
0,
|
|
'start'
|
|
);
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
|
|
String statCatcherEnabled = ElementParameterParser.getValue(
|
|
node,
|
|
"__TSTATCATCHER_STATS__"
|
|
);
|
|
|
|
if (statCatcherEnabled.equals("true")) {
|
|
for (INode statCatcher : node.getProcess().getNodesOfType("tStatCatcher")) {
|
|
%>
|
|
<%=statCatcher.getUniqueName()%>_subprocess(
|
|
message_type => 'begin',
|
|
origin => '<%=node.getUniqueName() %>',
|
|
);
|
|
|
|
$current_component="<%=node.getUniqueName() %>";
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
|
|
if (codePart.equals(ECodePart.MAIN)) {
|
|
for (IConnection conn : node.getIncomingConnections()) {
|
|
EConnectionType lineStyle = conn.getLineStyle();
|
|
|
|
if (EConnectionType.FLOW_MAIN == lineStyle
|
|
|| (EConnectionType.FLOW_MERGE == lineStyle
|
|
&& conn.getName().equals(currentIncomingName))) {
|
|
if (conn.isUseByMetter()) {
|
|
%>
|
|
$_globals{count_<%=conn.getName()%>}++;
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
|
|
if (stat) {
|
|
for (IConnection conn : node.getIncomingConnections()) {
|
|
EConnectionType lineStyle = conn.getLineStyle();
|
|
|
|
if (EConnectionType.FLOW_MAIN == lineStyle
|
|
|| (EConnectionType.FLOW_MERGE == lineStyle
|
|
&& conn.getName().equals(currentIncomingName))) {
|
|
%>
|
|
$now = time();
|
|
$count_<%=conn.getName() %>++;
|
|
if ($now - $last_stat_update_of_<%=conn.getName() %> >= 2) {
|
|
$last_stat_update_of_<%=conn.getName() %> = $now;
|
|
my $duration = int(
|
|
1000 * tv_interval(
|
|
$_globals{<%=node.getUniqueName() %>}{start},
|
|
[gettimeofday]
|
|
)
|
|
);
|
|
SendStat(
|
|
'<%=conn.getName() %>'.(defined $exec_number ? '.'.$exec_number : ''),
|
|
$count_<%=conn.getName() %>,
|
|
$duration
|
|
);
|
|
}
|
|
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
|
|
if (node.getComponent().isDataAutoPropagated()) {
|
|
List<IMetadataTable> metadatas = node.getMetadataList();
|
|
if ((metadatas!=null)&&(metadatas.size()>0)) {
|
|
IMetadataTable metadata = metadatas.get(0);
|
|
if (metadata!=null) {
|
|
List< ? extends IConnection> conns =
|
|
node.getIncomingConnections();
|
|
|
|
for (IConnection conn : conns) {
|
|
if (conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
|
|
%>
|
|
my $<%=node.getUniqueName() %> = $<%=conn.getName() %>;
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (codePart.equals(ECodePart.END)) {
|
|
if (stat) {
|
|
for (IConnection conn : node.getIncomingConnections()) {
|
|
if (EConnectionType.FLOW_MAIN == conn.getLineStyle()) {
|
|
%>
|
|
$duration = int(
|
|
1000 * tv_interval(
|
|
$_globals{<%=node.getUniqueName() %>}{start},
|
|
[gettimeofday]
|
|
)
|
|
);
|
|
SendStat(
|
|
'<%=conn.getName() %>'.(defined $exec_number ? '.'.$exec_number : ''),
|
|
$count_<%=conn.getName() %>,
|
|
$duration,
|
|
'stop'
|
|
);
|
|
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
|
|
for (IConnection conn : node.getOutgoingConnections()) {
|
|
if (conn.getLineStyle().equals(EConnectionType.ITERATE)) {
|
|
boolean parallelIterate = "true".equals(ElementParameterParser.getValue(conn, "__ENABLE_PARALLEL__"));
|
|
if (parallelIterate) {
|
|
%>
|
|
# end of the child process
|
|
<%
|
|
if (stat) {
|
|
%>
|
|
SendStat(
|
|
'<%=conn.getUniqueName() %>',
|
|
'exec'.$exec_number,
|
|
'stop'
|
|
);
|
|
<%
|
|
}
|
|
%>
|
|
|
|
exit();
|
|
}
|
|
<%
|
|
}
|
|
}
|
|
}
|
|
}
|
|
%>
|