Search in sources :

Example 6 with LogStatusInfo

use of com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo 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 7 with LogStatusInfo

use of com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo 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 8 with LogStatusInfo

use of com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo 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 9 with LogStatusInfo

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

the class ParserTest method testNginxAccessLog.

@Test
public void testNginxAccessLog() throws Exception {
    LogReader reader = null;
    String regexStr = ".*login HTTP.*";
    Calendar calendar = Calendar.getInstance();
    calendar.set(2014, 1, 20, 16, 38, 16);
    Date startTimeFilter = calendar.getTime();
    calendar.set(2014, 6, 16, 16, 38, 0);
    Date endTimeFilter = calendar.getTime();
    LogRequest request = new LogRequest.Builder().regex(regexStr).startTime(startTimeFilter).endTime(endTimeFilter).build();
    LogStatusInfo status = new LogStatusInfo();
    // "/opt/storageos/logs/nginx_access.log";
    String filePath = nginxAccessLogPath;
    String baseName = "nginx";
    reader = new LogReader(filePath, request, status, baseName);
    final LogMessage log = reader.readNextLogMessage();
    assertTrue("log is null", log != null);
    assertTrue("log message is null", !new String(log.getLogContent()).equals("null"));
    assertTrue("log message does not match regex", Pattern.compile(regexStr, Pattern.DOTALL | Pattern.MULTILINE).matcher(LogUtil.bytesToString(log.getLogContent())).matches());
    assertTrue("log time does not fit time filter", log.getTime() >= startTimeFilter.getTime() && log.getTime() <= endTimeFilter.getTime());
    assertTrue("log file name is not null", new String(log.getFileName()).equals("null"));
    assertTrue("log thread name not is null", new String(log.getThreadName()).equals("null"));
    assertTrue("log level is not null", new String(log.getLevel()).equals("null"));
    assertTrue("log line is not -1", new String(log.getLineNumber()).equals("-1"));
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) Calendar(java.util.Calendar) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) Date(java.util.Date) Test(org.junit.Test)

Example 10 with LogStatusInfo

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

the class ParserTest method testParticularLog.

@Test
public void testParticularLog() throws Exception {
    LogReader reader = null;
    LogRequest request = new LogRequest.Builder().build();
    LogStatusInfo status = new LogStatusInfo();
    String filePath = particularLogPath;
    String baseName = "log";
    reader = new LogReader(filePath, request, status, baseName);
    final LogMessage log = reader.readNextLogMessage();
    assertTrue("log is null", log != null);
    // assertTrue("log message is null", log.getLogContent() != null);
    assertTrue("log message is null", log.getLogContent() != null);
    assertTrue("log file name is null", log.getFileName() != null);
    assertTrue("log thread name is null", log.getThreadName() != null);
    assertTrue("log level is not Error", new String(log.getLevel()).equals("ERROR"));
    assertTrue("log line is null", log.getLineNumber() != null);
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) Test(org.junit.Test)

Aggregations

LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)12 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)12 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)12 Test (org.junit.Test)12 LogReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogReader)7 File (java.io.File)5 LogFileStream (com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream)4 Calendar (java.util.Calendar)4 Date (java.util.Date)4 Ignore (org.junit.Ignore)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 ArrayList (java.util.ArrayList)2 LogNetworkWriter (com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter)1 LogNetworkReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1