rmatharu commented on a change in pull request #1083: SAMZA-2251: Minor
diagnostics manager change to emit additional job details
URL: https://github.com/apache/samza/pull/1083#discussion_r296362118
##########
File path:
samza-core/src/test/java/org/apache/samza/serializers/model/serializers/TestMetricsSnapshotSerdeV2.java
##########
@@ -19,26 +19,64 @@
package org.apache.samza.serializers.model.serializers;
+import java.io.IOException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
+import org.apache.samza.Partition;
import org.apache.samza.SamzaException;
-import org.apache.samza.diagnostics.DiagnosticsExceptionEvent;
+import org.apache.samza.container.TaskName;
import org.apache.samza.diagnostics.BoundedList;
+import org.apache.samza.diagnostics.DiagnosticsExceptionEvent;
+import org.apache.samza.job.model.ContainerModel;
+import org.apache.samza.job.model.TaskModel;
import org.apache.samza.metrics.reporter.Metrics;
import org.apache.samza.metrics.reporter.MetricsHeader;
import org.apache.samza.metrics.reporter.MetricsSnapshot;
import org.apache.samza.serializers.MetricsSnapshotSerdeV2;
+import org.apache.samza.system.SystemStreamPartition;
+import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
public class TestMetricsSnapshotSerdeV2 {
+ @Test
+ public void testSerdeOfMessagesWithoutContainerModel() throws IOException {
+ MetricsHeader metricsHeader =
+ new MetricsHeader("jobName", "i001", "container 0", "test container
ID", "source", "300.14.25.1", "1", "1",
+ System.currentTimeMillis(), System.currentTimeMillis());
+
+ BoundedList boundedList = new
BoundedList<DiagnosticsExceptionEvent>("exceptions");
+ DiagnosticsExceptionEvent diagnosticsExceptionEvent1 =
+ new DiagnosticsExceptionEvent(1, new SamzaException("this is a samza
exception", new RuntimeException("cause")),
+ new HashMap());
+
+ boundedList.add(diagnosticsExceptionEvent1);
+
+ String samzaContainerMetricsGroupName =
"org.apache.samza.container.SamzaContainerMetrics";
+ Map<String, Map<String, Object>> metricMessage = new HashMap<>();
+ metricMessage.put(samzaContainerMetricsGroupName, new HashMap<>());
+ metricMessage.get(samzaContainerMetricsGroupName).put("exceptions",
boundedList.getValues());
+ metricMessage.get(samzaContainerMetricsGroupName).put("commit-calls", 0);
+ MetricsSnapshot metricsSnapshot = new MetricsSnapshot(metricsHeader, new
Metrics(metricMessage));
+
+ ObjectMapper test = new ObjectMapper();
+
test.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);
+ byte[] testBytes =
test.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8");
Review comment:
Added
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services