Search in sources :

Example 16 with LogMessage

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

the class LogStreamPerfTest method testPerformanceNoFilter.

/**
 * Test performance without filter
 */
@Test
@Ignore
public void testPerformanceNoFilter() throws Exception {
    System.out.println("starting testPerformanceNoFilter");
    String svcName = "bigFile-dbsvc";
    LogRequest req = new LogRequest.Builder().build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream(svcName, new ArrayList<File>(), req, status);
    long startTime = 0;
    long endTime = 0;
    startTime = System.nanoTime();
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            endTime = System.nanoTime();
            break;
        }
    }
    double fileSize = (double) stream.getTotalSizeCount() / (1024L * 1024L);
    double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
    double speed = fileSize / elapsedTime;
    // System.out.println("Total files size(after compressed) is " +
    // fileSize + "MB. Log messages count is "
    // + stream.getTotalLogCount());
    // System.out.println("Speed of LogStream without Filter is: " + speed
    // + " MB/sed");
    System.out.println("Total files size(after decompressing) is 4286.8 MB. Log messages count is " + stream.getTotalLogCount());
    System.out.println("Speed of LogStream without Filter is: " + 4286.8 / elapsedTime + " MB/sec and " + stream.getTotalLogCount() / elapsedTime + " logs/sec");
    System.out.println("done testPerformanceNoFilter");
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with LogMessage

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

the class LogStreamPerfTest method testPerformanceMultipleFilters.

/**
 * Test performance with time, level and pattern filters, the speed should
 * be faster than 50 Mbs
 */
@Test
@Ignore
public void testPerformanceMultipleFilters() throws Exception {
    System.out.println("starting testPerformanceMultipleFilters");
    String svcName = "bigFile-dbsvc";
    String pattern = "Memory";
    Calendar calendar = Calendar.getInstance();
    calendar.set(2013, 10, 20, 16, 38, 16);
    Date startTimeFilter = calendar.getTime();
    calendar.set(2014, 0, 16, 16, 38, 0);
    Date endTimeFilter = calendar.getTime();
    LogRequest req = new LogRequest.Builder().startTime(startTimeFilter).endTime(endTimeFilter).logLevel(7).regex(pattern).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream(svcName, new ArrayList<File>(), req, status);
    long startTime = 0;
    long endTime = 0;
    startTime = System.nanoTime();
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            endTime = System.nanoTime();
            break;
        }
    }
    double fileSize = (double) stream.getTotalSizeCount() / (1024L * 1024L);
    double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
    double speed = fileSize / elapsedTime;
    System.out.println("Total files size is " + fileSize + "MB. Log messages count is " + stream.getTotalLogCount());
    System.out.println("Speed of LogStream with multiple Filters is: " + speed + " Mbs");
    System.out.println("Total files size(after decompressing) is 3436.7 MB. Log messages count is " + stream.getTotalLogCount());
    System.out.println("Speed of LogStream with multiple Filters is: " + 3436.7 / elapsedTime + " MB/sec");
    System.out.println("done testPerformanceMultipleFilters");
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) Calendar(java.util.Calendar) File(java.io.File) Date(java.util.Date) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with LogMessage

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

the class LogStreamPerfTest method testPerformanceTimeFilter.

/**
 * Test performance with time range filter
 */
@Test
@Ignore
public void testPerformanceTimeFilter() throws Exception {
    System.out.println("starting testPerformanceTimeFilter");
    String svcName = "bigFile-dbsvc";
    Calendar calendar = Calendar.getInstance();
    calendar.set(2013, 10, 20, 16, 38, 16);
    Date startTimeFilter = calendar.getTime();
    calendar.set(2014, 0, 16, 16, 38, 0);
    Date endTimeFilter = calendar.getTime();
    LogRequest req = new LogRequest.Builder().startTime(startTimeFilter).endTime(endTimeFilter).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream(svcName, new ArrayList<File>(), req, status);
    long startTime = 0;
    long endTime = 0;
    startTime = System.nanoTime();
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            endTime = System.nanoTime();
            break;
        }
    }
    double fileSize = (double) stream.getTotalSizeCount() / (1024L * 1024L);
    double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
    double speed = fileSize / elapsedTime;
    System.out.println("Total files size is " + fileSize + "MB. Log messages count is " + stream.getTotalLogCount());
    System.out.println("Speed of LogStream with time range Filter is: " + speed + " Mbs");
    System.out.println("Total files size(after decompressing) is 3436.7 MB. Log messages count is " + stream.getTotalLogCount());
    System.out.println("Speed of LogStream with time filter is: " + 3436.7 / elapsedTime + " MB/sec");
    System.out.println("done testPerformanceTimeFilter");
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) Calendar(java.util.Calendar) File(java.io.File) Date(java.util.Date) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with LogMessage

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

the class AbstractLogStreamMerger method readNextMergedLogMessage.

/**
 * This is the routine handles the request, sends back the response(outputstream)
 *
 * @throws java.io.IOException
 * @throws org.apache.commons.compress.compressors.CompressorException
 */
public LogMessage readNextMergedLogMessage() throws IOException, CompressorException {
    LogMessage oldestResult = null;
    LogMessage oldest = null;
    int index = -1;
    if (finishedCount == logStreamList.length) {
        setFinished(true);
        return null;
    }
    // poll the streams to get the oldest log message
    for (int i = 0; i < logStreamList.length; i++) {
        if (finishedList.contains(i)) {
            continue;
        }
        if (logHeads[i] == null) {
            logHeads[i] = logStreamList[i].readNextLogMessage();
            if (logHeads[i] == null) {
                // finished
                addFinishedStream(i);
                finishedCount++;
                logger.debug("merger counter={}", logCounter);
                continue;
            }
        }
        // logs[i] should not be null now
        if (oldest == null || logHeads[i].getTime() < oldest.getTime()) {
            oldest = logHeads[i];
            index = i;
        }
    }
    if (oldest != null) {
        logHeads[index] = null;
        logCounter.addAndGet(1);
        if (LogUtil.permitCurrentLog(request.getMaxCount(), logCounter.get(), oldest.getTime(), prevLogTime)) {
            oldestResult = oldest;
        }
        prevLogTime = oldest.getTime();
    }
    return oldestResult;
}
Also used : LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage)

Example 20 with LogMessage

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

the class LogNginxErrorParser method parseLine.

@Override
public LogMessage parseLine(String line, LogRequest info) {
    Date date = null;
    String msg = null;
    int lineLength = line.length();
    if (lineLength <= TIME_LENGTH || line.charAt(4) != '/' || line.charAt(7) != '/' || line.charAt(10) != ' ' || line.charAt(13) != ':' || line.charAt(16) != ':' || line.charAt(19) != ' ') {
        return LogMessage.CONTINUATION_LOGMESSAGE;
    }
    String timeStr = line.substring(0, TIME_LENGTH);
    DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    try {
        date = format.parse(timeStr);
    } catch (Exception e) {
        return LogMessage.CONTINUATION_LOGMESSAGE;
    }
    int inTime = inTimeRange(date, info);
    if (inTime < 0) {
        // too early
        return LogMessage.REJECTED_LOGMESSAGE;
    } else if (inTime > 0) {
        // too late
        return LogMessage.REJECTED_LAST_LOGMESSAGE;
    }
    int levelStartIndex = line.indexOf("[", TIME_LENGTH) + 1;
    if (levelStartIndex >= lineLength || levelStartIndex > Short.MAX_VALUE) {
        return LogMessage.CONTINUATION_LOGMESSAGE;
    }
    int levelEndIndex = line.indexOf("]", levelStartIndex);
    if (levelEndIndex < 0 || levelEndIndex - levelStartIndex > Short.MAX_VALUE) {
        return LogMessage.CONTINUATION_LOGMESSAGE;
    }
    final String levelString = line.substring(levelStartIndex, levelEndIndex);
    final int level = LogSeverity.toLevel(levelString);
    if (level < 0) {
        return LogMessage.CONTINUATION_LOGMESSAGE;
    }
    int matchLevel = matchLevelFilter(level, info);
    if (matchLevel > 0) {
        // level value bigger than request
        return LogMessage.REJECTED_LOGMESSAGE;
    }
    LogMessage log = new LogMessage(date.getTime(), line.getBytes());
    log.setLogOffset(TIME_LENGTH + 1);
    log.setTimeBytes(0, TIME_LENGTH);
    log.setLevel(level);
    return log;
}
Also used : LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)25 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)15 Test (org.junit.Test)15 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)12 Date (java.util.Date)9 LogReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogReader)7 ArrayList (java.util.ArrayList)7 Calendar (java.util.Calendar)6 File (java.io.File)5 Ignore (org.junit.Ignore)5 LogFileStream (com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream)4 LogStreamMerger (com.emc.storageos.systemservices.impl.logsvc.merger.LogStreamMerger)3 IOException (java.io.IOException)3 BufferedOutputStream (java.io.BufferedOutputStream)2 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1