Search in sources :

Example 1 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class RrdMetricsRetrieverTest method testMetricsPptReport.

@Test
public void testMetricsPptReport() throws Exception {
    String rrdFilename = TEST_DIR + "queryCount_Counter" + RRD_FILE_EXTENSION;
    new RrdFileBuilder().rrdFileName(rrdFilename).build();
    rrdFilename = TEST_DIR + "queryCount_Gauge" + RRD_FILE_EXTENSION;
    long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).dsType(DsType.GAUGE).build();
    List<String> metricNames = new ArrayList<String>();
    metricNames.add("queryCount_Counter");
    metricNames.add("queryCount_Gauge");
    MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
    OutputStream os = metricsRetriever.createPptReport(metricNames, TEST_DIR, START_TIME, endTime);
    InputStream is = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
    assertThat(is, not(nullValue()));
    SlideShow ppt = new SlideShow(is);
    Slide[] slides = ppt.getSlides();
    assertThat(slides.length, equalTo(2));
    verifySlide(slides[0], "queryCount_Counter", true);
    verifySlide(slides[1], "queryCount_Gauge", false);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) ByteArrayInputStream(java.io.ByteArrayInputStream) Slide(org.apache.poi.hslf.model.Slide) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) MetricsRetriever(ddf.metrics.reporting.internal.MetricsRetriever) Test(org.junit.Test)

Example 2 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class RrdMetricsRetrieverTest method testMetricsPptDataWithGauge.

@Test
public void testMetricsPptDataWithGauge() throws Exception {
    String rrdFilename = TEST_DIR + "queryCount_Gauge" + RRD_FILE_EXTENSION;
    long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).dsType(DsType.GAUGE).build();
    MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
    OutputStream os = metricsRetriever.createPptData("queryCount", rrdFilename, START_TIME, endTime);
    InputStream is = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
    assertThat(is, not(nullValue()));
    SlideShow ppt = new SlideShow(is);
    Slide[] slides = ppt.getSlides();
    assertThat(slides.length, equalTo(1));
    verifySlide(slides[0], "queryCount", false);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Slide(org.apache.poi.hslf.model.Slide) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) MetricsRetriever(ddf.metrics.reporting.internal.MetricsRetriever) Test(org.junit.Test)

Example 3 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class RrdMetricsRetriever method createPptData.

@Override
public OutputStream createPptData(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException {
    LOGGER.trace("ENTERING: createPptData");
    SlideShow ppt = new SlideShow();
    byte[] graph = createGraph(metricName, rrdFilename, startTime, endTime);
    MetricData metricData = getMetricData(rrdFilename, startTime, endTime);
    createSlide(ppt, metricName, graph, metricData);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ppt.write(bos);
    bos.close();
    LOGGER.trace("EXITING: createPptData");
    return bos;
}
Also used : SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 4 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class RrdMetricsRetriever method createPptReport.

@Override
public OutputStream createPptReport(List<String> metricNames, String metricsDir, long startTime, long endTime) throws IOException, MetricsGraphException {
    LOGGER.trace("ENTERING: createPptReport");
    SlideShow ppt = new SlideShow();
    Collections.sort(metricNames);
    for (String metricName : metricNames) {
        String rrdFilename = getRrdFilename(metricsDir, metricName);
        byte[] graph = createGraph(metricName, rrdFilename, startTime, endTime);
        MetricData metricData = getMetricData(rrdFilename, startTime, endTime);
        createSlide(ppt, metricName, graph, metricData);
    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ppt.write(bos);
    bos.close();
    LOGGER.trace("EXITING: createPptReport");
    return bos;
}
Also used : SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 5 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class RrdMetricsRetrieverTest method testMetricsPptDataWithCounter.

@Test
public void testMetricsPptDataWithCounter() throws Exception {
    String rrdFilename = TEST_DIR + "queryCount_Counter" + RRD_FILE_EXTENSION;
    long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).build();
    MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
    OutputStream os = metricsRetriever.createPptData("queryCount", rrdFilename, START_TIME, endTime);
    InputStream is = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
    assertThat(is, not(nullValue()));
    SlideShow ppt = new SlideShow(is);
    Slide[] slides = ppt.getSlides();
    assertThat(slides.length, equalTo(1));
    verifySlide(slides[0], "queryCount", true);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Slide(org.apache.poi.hslf.model.Slide) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) MetricsRetriever(ddf.metrics.reporting.internal.MetricsRetriever) Test(org.junit.Test)

Aggregations

SlideShow (org.apache.poi.hslf.usermodel.SlideShow)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 InputStream (java.io.InputStream)5 Slide (org.apache.poi.hslf.model.Slide)5 Test (org.junit.Test)5 MetricsRetriever (ddf.metrics.reporting.internal.MetricsRetriever)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 OutputStream (java.io.OutputStream)3 Response (javax.ws.rs.core.Response)2 UriInfo (javax.ws.rs.core.UriInfo)2 ArrayList (java.util.ArrayList)1 JSONObject (org.json.simple.JSONObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1