MRJobEntityCreationHandler { public void add(TaggedLogAPIEntity entity) { entities.add(entity); List<GenericMetricEntity> metricEntities; if (entity instanceof JobExecutionAPIEntity) { metricEntities = jobMetricsListener.generateMetrics((JobExecutionAPIEntity) entity); entities.addAll(metricEntities); } if (entities.size() >= MAX_FLUSH_NUM) { this.flush(); } } MRJobEntityCreationHandler(MRRunningJobConfig.EagleServiceConfig eagleServiceConfig); void add(TaggedLogAPIEntity entity); boolean flush();  }
@Test public void testMRJobEntityCreationHandlerAdd() throws IOException, NoSuchFieldException, IllegalAccessException { mockStatic(System.class); when(System.currentTimeMillis()).thenReturn(1479863033310l); MRJobEntityCreationHandler mrJobEntityCreationHandler = new MRJobEntityCreationHandler(null); mrJobEntityCreationHandler.add(makeJobExecutionAPIEntity()); Field entities = MRJobEntityCreationHandler.class.getDeclaredField("entities"); entities.setAccessible(true); List<TaggedLogAPIEntity> entityList = (ArrayList<TaggedLogAPIEntity>) entities.get(mrJobEntityCreationHandler); Assert.assertEquals(4, entityList.size()); Assert.assertEquals("[prefix:null, timestamp:1479328221694, humanReadableDate:2016-11-16 20:30:21,694, tags: , encodedRowkey:null, prefix:hadoop.job.allocatedmb, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.allocatedvcores, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.runningcontainers, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null]", entityList.toString()); }
@Test public void testMRJobEntityCreationHandlerWithCounts() throws IOException, NoSuchFieldException, IllegalAccessException { mockStatic(System.class); when(System.currentTimeMillis()).thenReturn(1479863033310l); MRJobEntityCreationHandler mrJobEntityCreationHandler = new MRJobEntityCreationHandler(null); mrJobEntityCreationHandler.add(makeJobExecutionAPIEntityWithCounts()); Field entities = MRJobEntityCreationHandler.class.getDeclaredField("entities"); entities.setAccessible(true); List<TaggedLogAPIEntity> entityList = (ArrayList<TaggedLogAPIEntity>) entities.get(mrJobEntityCreationHandler); Assert.assertEquals(62, entityList.size()); Assert.assertEquals("[prefix:null, timestamp:1479328221694, humanReadableDate:2016-11-16 20:30:21,694, tags: , encodedRowkey:null, prefix:hadoop.job.allocatedmb, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.allocatedvcores, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.runningcontainers, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.viewfs_large_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.file_bytes_written, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.file_large_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.file_write_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.viewfs_bytes_read, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.viewfs_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.hdfs_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.viewfs_write_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.hdfs_bytes_read, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.hdfs_large_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.file_read_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.file_bytes_read, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.hdfs_write_ops, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.viewfs_bytes_written, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.hdfs_bytes_written, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.deserialize_errors, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.records_out_intermediate, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.records_in, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.bytes_written, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.bytes_read, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.total_launched_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.vcores_millis_reduces, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.mb_millis_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.total_launched_reduces, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.slots_millis_reduces, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.vcores_millis_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.mb_millis_reduces, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.slots_millis_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.rack_local_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.millis_reduces, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.other_local_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.millis_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.map_output_materialized_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.reduce_input_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.spilled_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.merged_map_outputs, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.virtual_memory_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.map_input_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.split_raw_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.failed_shuffle, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.map_output_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.reduce_shuffle_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.physical_memory_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.gc_time_millis, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.reduce_input_groups, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.combine_output_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.shuffled_maps, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.reduce_output_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.map_output_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.combine_input_records, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.cpu_milliseconds, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.committed_heap_bytes, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.connection, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.wrong_length, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.bad_id, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.wrong_map, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.wrong_reduce, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null, prefix:hadoop.job.io_error, timestamp:1479863033310, humanReadableDate:2016-11-23 01:03:53,310, tags: , encodedRowkey:null]", entityList.toString()); }