Skip to content

Commit

Permalink
tKarafServiceMetricInput option added to suppress totals metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlolling committed Sep 22, 2017
1 parent 74ed7ec commit 94feb6a
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>de.jlo.talendcomp</groupId>
<artifactId>jlo-talendcomp-karaf-jmx</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>

<name>jlo-karaf-jmx</name>
Expand Down
30 changes: 25 additions & 5 deletions src/main/java/de/jlo/talendcomp/karaf/jmx/CXFMetricsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class CXFMetricsCollector {
private long lastExecutionTime = 0l;
private long interval = 1000l;
private List<ServiceMetric> lastListServiceMetrics = new ArrayList<ServiceMetric>();
private boolean ignoreSummaryMetrics = false;

public CXFMetricsCollector(BaseClient baseClient) {
if (baseClient == null || baseClient.isConnected() == false) {
Expand Down Expand Up @@ -79,11 +80,15 @@ private String getArtifactIdFromObjectName(ObjectName name) {
return artifactId;
}

public ServiceMetric fetchServiceMetric(ObjectName objectName) throws Exception {
public ServiceMetric fetchServiceMetric(ObjectName objectName, String operation) throws Exception {
String name = getArtifactIdFromObjectName(objectName);
String op = objectName.getKeyProperty("Operation");
if (op != null && op.trim().isEmpty() == false) {
name = name + "." + op;
if (operation != null && operation.trim().isEmpty() == false) {
name = name + "." + operation;
} else {
String op = objectName.getKeyProperty("Operation");
if (op != null && op.trim().isEmpty() == false) {
name = name + "." + op;
}
}
ServiceMetric metric = new ServiceMetric();
metric.setServiceName(name);
Expand All @@ -106,7 +111,14 @@ private void setupDiffToLastMeasurement(ServiceMetric metric) {
public List<ServiceMetric> fetchServiceMetrics() throws Exception {
List<ServiceMetric> listServiceMetrics = new ArrayList<ServiceMetric>();
for (ObjectName on : listMetricObjectNames) {
listServiceMetrics.add(fetchServiceMetric(on));
if (ignoreSummaryMetrics) {
String op = on.getKeyProperty("Operation");
if (op != null && op.trim().isEmpty() == false) {
listServiceMetrics.add(fetchServiceMetric(on, op));
}
} else {
listServiceMetrics.add(fetchServiceMetric(on, null));
}
}
lastListServiceMetrics = listServiceMetrics;
return listServiceMetrics;
Expand Down Expand Up @@ -137,4 +149,12 @@ public void setInterval(int interval) {
this.interval = interval * 1000l;
}

public boolean isIgnoreSummaryMetrics() {
return ignoreSummaryMetrics;
}

public void setIgnoreSummaryMetrics(boolean ignoreSummaryMetrics) {
this.ignoreSummaryMetrics = ignoreSummaryMetrics;
}

}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.0" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="cimt AG" RELEASE_DATE="20170913" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.1" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="cimt AG" RELEASE_DATE="20170922" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -55,13 +55,13 @@
</PARAMETER>
</PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER NAME="RELEASE_LABEL_20170913" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.0 build at: 20170913</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20170922" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.1 build at: 20170922</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.0.jar" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.1.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions talend_component/tKarafServiceList/tKarafServiceList_java.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.0" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="cimt AG" RELEASE_DATE="20170913" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.1" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="cimt AG" RELEASE_DATE="20170922" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -58,13 +58,13 @@
</PARAMETER>
</PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER NAME="RELEASE_LABEL_20170913" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.0 build at: 20170913</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20170922" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.1 build at: 20170922</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.0.jar" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.1.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
if (filter == null || filter.trim().isEmpty()) {
filter = "null";
}
boolean ignoreSummaryMetrics = "true".equals(ElementParameterParser.getValue(node, "__FEATURE_FILTER_IS_OPERATION__"));
String interval = ElementParameterParser.getValue(node, "__TIME_INTERVAL__");
%>
de.jlo.talendcomp.karaf.jmx.KarafClient client_<%=cid%> = new de.jlo.talendcomp.karaf.jmx.KarafClient();
Expand All @@ -60,6 +61,7 @@
<% if (interval != null && interval.trim().isEmpty() == false) { %>
<%=cid%>.setInterval(<%=interval%>);
<% } %>
<%=cid%>.setIgnoreSummaryMetrics(<%=ignoreSummaryMetrics%>);
java.util.List<de.jlo.talendcomp.karaf.jmx.ServiceMetric> list_<%=cid%> = new java.util.ArrayList<de.jlo.talendcomp.karaf.jmx.ServiceMetric>();
try {
<%=cid%>.setupCXFTotalsMetricObjectNames(<%=filter%>);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.0" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20170913" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="2.1" STATUS="PROD" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20170922" HAS_CONDITIONAL_OUTPUTS="true" STARTABLE="true">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -64,18 +64,21 @@
<PARAMETER FIELD="TEXT" NAME="FEATURE_FILTER_REGEX" NUM_ROW="70">
<DEFAULT/>
</PARAMETER>
<PARAMETER FIELD="CHECK" NAME="FEATURE_FILTER_IS_OPERATION" NUM_ROW="75">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER FIELD="TEXT" NAME="TIME_INTERVAL" NUM_ROW="80">
<DEFAULT>1</DEFAULT>
</PARAMETER>
</PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER NAME="RELEASE_LABEL_20170913" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.0 build at: 20170913</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20170922" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 2.1 build at: 20170922</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.0.jar" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-karaf-jmx" MODULE="jlo-talendcomp-karaf-jmx-2.1.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ KARAF_INSTANCE.NAME=Instance Name
JMX_PORT.NAME=RMI-Registry Port
JSTATD_PORT.NAME=RMI Port
FEATURE_FILTER_REGEX.NAME=Filter features with regex
FEATURE_FILTER_IS_OPERATION.NAME=Ignore summary metrics
TIME_INTERVAL.NAME=Time Interval in s

NB_LINE.NAME=Number Records
Expand Down

0 comments on commit 94feb6a

Please sign in to comment.