@Override public void run() { for (int i = 1; i <= 100; i++) { listGauge.add(i); } } });
@Override public void run() { for (int i = 1; i <= 100; i++) { listGauge.add(i); } } });
@Override protected void append(LoggingEvent loggingEvent) { try { // if an event with a non-null throwable is received => exception event if (loggingEvent.getThrowableInformation() != null) { DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(loggingEvent.timeStamp, loggingEvent.getThrowableInformation().getThrowable(), loggingEvent.getProperties()); samzaContainerExceptionMetric.add(diagnosticsExceptionEvent); LOG.debug("Received DiagnosticsExceptionEvent " + diagnosticsExceptionEvent); } else { LOG.debug("Received non-exception event with message " + loggingEvent.getMessage()); } } catch (Exception e) { // blanket catch of all exceptions so as to not impact any job LOG.error("Exception in logging event parsing", e); } }
@Override public void append(LogEvent logEvent) { try { // if an event with a non-null throwable is received => exception event if (logEvent.getThrown() != null) { DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(logEvent.getTimeMillis(), logEvent.getThrown(), logEvent.getContextData().toMap()); samzaContainerExceptionMetric.add(diagnosticsExceptionEvent); LOG.debug("Received DiagnosticsExceptionEvent " + diagnosticsExceptionEvent); } else { LOG.debug("Received non-exception event with message " + logEvent.getMessage()); } } catch (Exception e) { // blanket catch of all exceptions so as to not impact any job LOG.error("Exception in logevent parsing", e); } } }
@Test public void testSizeEnforcement() { ListGauge listGauge = getListGaugeForTest(); for (int i = 15; i > 0; i--) { listGauge.add("v" + i); } Assert.assertEquals("List sizes should be as configured at creation time", listGauge.getValues().size(), 10); int valueIndex = 10; Collection<String> currentList = listGauge.getValues(); Iterator iterator = currentList.iterator(); while (iterator.hasNext()) { String gaugeValue = (String) iterator.next(); Assert.assertTrue(gaugeValue.equals("v" + valueIndex)); valueIndex--; } }
@Test public void basicTest() { ListGauge<String> listGauge = getListGaugeForTest(); listGauge.add("sampleValue"); Assert.assertEquals("Names should be the same", listGauge.getName(), "sampleListGauge"); Assert.assertEquals("List sizes should match", listGauge.getValues().size(), 1); Assert.assertEquals("ListGauge should contain sampleGauge", listGauge.getValues().contains("sampleValue"), true); }
new HashMap()); listGauge.add(diagnosticsExceptionEvent1);