Search in sources :

Example 6 with XMLEventMarshaller

use of com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller in project coprhd-controller by CoprHD.

the class DbEventRetriever method getBulkEvents.

@Override
public void getBulkEvents(DateTime time, TimeSeriesMetadata.TimeBucket bucket, MediaType type, Writer writer) throws MarshallingExcetion {
    if (dbClient == null) {
        throw APIException.internalServerErrors.noDBClient();
    }
    EventMarshaller marshaller = null;
    if (type.equals(MediaType.APPLICATION_XML_TYPE)) {
        marshaller = new XMLEventMarshaller();
        log.debug("Parser type: {}", type.toString());
    } else if (type.equals(MediaType.APPLICATION_JSON_TYPE)) {
        marshaller = new JSONEventMarshaller();
        log.debug("Parser type: {}", type.toString());
    } else {
        log.warn("unsupported type: {}, use XML", type.toString());
        marshaller = new XMLEventMarshaller();
    }
    MonitoringEventQueryResult result = new MonitoringEventQueryResult(marshaller, writer);
    marshaller.header(writer);
    log.info("Query time bucket {}", time.toString());
    dbClient.queryTimeSeries(EventTimeSeries.class, time, bucket, result, getThreadPool());
    marshaller.tailer(writer);
}
Also used : MonitoringEventQueryResult(com.emc.storageos.api.service.impl.resource.utils.MonitoringEventQueryResult) XMLEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller) JSONEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.JSONEventMarshaller) JSONEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.JSONEventMarshaller) XMLEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller)

Aggregations

XMLEventMarshaller (com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller)6 Event (com.emc.storageos.db.client.model.Event)5 BufferedWriter (java.io.BufferedWriter)4 OutputStream (java.io.OutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 Test (org.junit.Test)4 File (java.io.File)3 URISyntaxException (java.net.URISyntaxException)3 JAXBContext (javax.xml.bind.JAXBContext)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 JSONEventMarshaller (com.emc.storageos.api.service.impl.resource.utils.JSONEventMarshaller)2 IOException (java.io.IOException)2 URI (java.net.URI)2 JAXBException (javax.xml.bind.JAXBException)2 EventMarshaller (com.emc.storageos.api.service.impl.resource.utils.EventMarshaller)1 MarshallingExcetion (com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion)1 MonitoringEventQueryResult (com.emc.storageos.api.service.impl.resource.utils.MonitoringEventQueryResult)1 FileWriter (java.io.FileWriter)1