Search in sources :

Example 1 with LogNetworkWriter

use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.

the class LogNetworkReaderPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    List<String> svcs = new ArrayList<String>() {

        {
            add("controllersvc");
            add("coordinatorsvc");
            add("apisvc");
        }
    };
    int bufSize = 1024 * 64;
    LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
    final LogNetworkWriter writer = new LogNetworkWriter(req, propertiesLoader);
    try (final PipedOutputStream out = new PipedOutputStream();
        final BufferedOutputStream outputStream = new BufferedOutputStream(out, bufSize);
        final PipedInputStream inputStream = new PipedInputStream(out)) {
        LogNetworkReader reader = new LogNetworkReader("vipr1", "vipr1", inputStream, new LogStatusInfo());
        long totalSize = 0;
        long startTime = System.nanoTime();
        new Thread(new Runnable() {

            public void run() {
                try {
                    writer.write(outputStream);
                } catch (Exception e) {
                    // NOSONAR
                    e.printStackTrace();
                // ("squid:S1148 suppress sonar warning on printStackTrace. It's a test case and exceptions are meant to be printed to stdout/stderr")
                }
            }
        }).start();
        LogMessage log = null;
        while ((log = reader.readNextLogMessage()) != null) {
            totalSize += log.toStringOriginalFormat().getBytes().length;
        }
        long endTime = System.nanoTime();
        totalSize /= (1024L * 1024L);
        double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
        System.out.println("Total read " + totalSize + " MB;" + " Used " + elapsedTime + " sec; Average " + (totalSize / elapsedTime) + " MB/sec.");
    }
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogNetworkReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader) ArrayList(java.util.ArrayList) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogNetworkWriter(com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) BufferedOutputStream(java.io.BufferedOutputStream) Test(org.junit.Test)

Example 2 with LogNetworkWriter

use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.

the class LogNetworkWriterPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    List<String> svcs = new ArrayList<String>() {

        {
            add("controllersvc");
            add("coordinatorsvc");
            add("apisvc");
        }
    };
    LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
    LogNetworkWriter writer = new LogNetworkWriter(req, propertiesLoader);
    ByteCountingOutputStream outputStream = new ByteCountingOutputStream();
    long startTime = System.nanoTime();
    writer.write(outputStream);
    long endTime = System.nanoTime();
    long totalSize = outputStream.getSize() / (1024L * 1024L);
    double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
    System.out.println("Total read " + totalSize + " MB;" + " Used " + elapsedTime + " sec; Average " + (totalSize / elapsedTime) + " MB/sec.");
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogNetworkWriter(com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with LogNetworkWriter

use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.

the class LogService method getNodeLogs.

/**
 * Internal Use
 * <p/>
 * Gets a chunk of the log data from the Bourne node to which the request is directed that is filtered, merged, and sorted based on the
 * passed request parameters. The log messages are returned as a JSON formatted string.
 *
 * @return A Response containing the log messages as a JSON formatted
 *         string.
 */
@POST
@Path("internal/node-logs/")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response getNodeLogs(LogRequest logReqInfo) {
    _log.trace("Enter into getNodeLogs()");
    if (logReqInfo.isDryRun()) {
        return Response.ok().build();
    }
    final LogNetworkWriter logRequestMgr = new LogNetworkWriter(logReqInfo, _logSvcPropertiesLoader);
    StreamingOutput logMsgStream = new StreamingOutput() {

        @Override
        public void write(OutputStream outputStream) throws IOException, WebApplicationException {
            logRequestMgr.write(outputStream);
        }
    };
    return Response.ok(logMsgStream).build();
}
Also used : LogNetworkWriter(com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter) OutputStream(java.io.OutputStream) StreamingOutput(javax.ws.rs.core.StreamingOutput) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

LogNetworkWriter (com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter)3 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)1 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)1 LogNetworkReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 OutputStream (java.io.OutputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1