Search in sources :

Example 16 with LogRequest

use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.

the class LogAnalyser method getNodeErrorLogs.

/*
     * get error logs from the given service
     */
private LogNetworkStreamMerger getNodeErrorLogs() {
    endTime = new DateTime();
    if (startTime == null) {
        startTime = endTime.minusMinutes(15);
    }
    String nodeId = service.getNodeId();
    List<String> nodeIds = new ArrayList<String>();
    nodeIds.add(nodeId);
    LogRequest logReqInfo = new LogRequest.Builder().nodeIds(nodeIds).baseNames(svcNames).logLevel(logLevel).startTime(startTime.toDate()).endTime(endTime.toDate()).regex(msgRegex).maxCont(maxCount).build();
    _log.info("Diagnostics scheduler: log request info is {}", logReqInfo.toString());
    LogNetworkStreamMerger logRequestMgr = new LogNetworkStreamMerger(logReqInfo, MediaType.TEXT_PLAIN_TYPE, logSvcPropertiesLoader);
    // Then it will be start with next log.
    startTime = endTime.plusSeconds(1);
    return logRequestMgr;
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) ArrayList(java.util.ArrayList) LogNetworkStreamMerger(com.emc.storageos.systemservices.impl.logsvc.merger.LogNetworkStreamMerger) DateTime(org.joda.time.DateTime)

Example 17 with LogRequest

use of com.emc.vipr.model.sys.logging.LogRequest 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 18 with LogRequest

use of com.emc.vipr.model.sys.logging.LogRequest 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 19 with LogRequest

use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.

the class LogReaderPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    LogStatusInfo status = new LogStatusInfo();
    String filePath = PATH;
    File file = new File(filePath);
    double fileSize = (double) file.length() / (1024L * 1024L);
    LogRequest req = new LogRequest.Builder().build();
    // empty service list
    LogReader reader = new LogReader(filePath, req, status, null);
    long startTime = System.nanoTime();
    while (true) {
        LogMessage log = reader.readNextLogMessage();
        if (log == null) {
            break;
        }
    }
    double elapsedTime = (double) (System.nanoTime() - startTime) / 1000000000.0;
    double speed = fileSize / elapsedTime;
    System.out.println("Performance for LogReader");
    System.out.println("Total read " + fileSize + " MB;" + " Used " + elapsedTime + " sec; Average " + speed + " MB/sec.");
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) File(java.io.File) Test(org.junit.Test)

Example 20 with LogRequest

use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.

the class LogStreamMergerPerfTest method testMergePerformance.

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

        {
            add("controllersvc");
            add("coordinatorsvc");
            add("apisvc");
        }
    };
    LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
    LogStreamMerger merger = new LogStreamMerger(req, propertiesLoader);
    long startTime = System.nanoTime();
    while (true) {
        LogMessage log = merger.readNextMergedLogMessage();
        if (log == null) {
            break;
        }
    }
    long endTime = System.nanoTime();
    int num = merger.getStreamList().length;
    long totalSize = 0;
    for (int i = 0; i < num; i++) {
        totalSize += merger.getStreamList()[i].getTotalSizeCount();
    }
    totalSize = 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 : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) ArrayList(java.util.ArrayList) LogStreamMerger(com.emc.storageos.systemservices.impl.logsvc.merger.LogStreamMerger) Test(org.junit.Test)

Aggregations

LogRequest (com.emc.vipr.model.sys.logging.LogRequest)38 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)21 File (java.io.File)17 LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)15 LogFileStream (com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream)13 Calendar (java.util.Calendar)13 Date (java.util.Date)13 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)12 Ignore (org.junit.Ignore)12 LogReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogReader)10 LogStreamMerger (com.emc.storageos.systemservices.impl.logsvc.merger.LogStreamMerger)4 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 SysClientFactory (com.emc.storageos.systemservices.impl.client.SysClientFactory)2 LogNetworkWriter (com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter)2 LogNetworkStreamMerger (com.emc.storageos.systemservices.impl.logsvc.merger.LogNetworkStreamMerger)2 LogNetworkReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader)2 NodeInfo (com.emc.storageos.systemservices.impl.resource.util.NodeInfo)2 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2