Search in sources :

Example 1 with SequentialLogFileReader

use of org.eclipse.titan.log.viewer.readers.SequentialLogFileReader in project titan.EclipsePlug-ins by eclipse.

the class LogSearchQuery method run.

@Override
public IStatus run(final IProgressMonitor monitor) {
    result.removeAll();
    int numOfRecords = 0;
    for (IFile logFile : files) {
        File indexFile = LogFileCacheHandler.getLogRecordIndexFileForLogFile(logFile);
        numOfRecords += LogFileCacheHandler.getNumberOfLogRecordIndexes(indexFile);
    }
    monitor.beginTask("Searching", numOfRecords);
    for (IFile logFile : files) {
        if (monitor.isCanceled()) {
            break;
        }
        if (LogFileCacheHandler.hasLogFileChanged(logFile) && !LogFileCacheHandler.processLogFile(logFile, new NullProgressMonitor(), true)) {
            continue;
        }
        File indexFile = LogFileCacheHandler.getLogRecordIndexFileForLogFile(logFile);
        try {
            LogRecordIndex[] indexes = LogFileCacheHandler.readLogRecordIndexFile(indexFile, 0, LogFileCacheHandler.getNumberOfLogRecordIndexes(indexFile));
            SequentialLogFileReader reader = new SequentialLogFileReader(logFile.getLocationURI(), indexes);
            monitor.subTask("Filtering");
            filterRecords(monitor, logFile, reader);
            monitor.done();
        } catch (ParseException e) {
            ErrorReporter.logExceptionStackTrace(e);
            TitanLogExceptionHandler.handleException(new TechnicalException(logFile.getName() + ": Could not parse the log file. Reason: " + e.getMessage()));
        } catch (IOException e) {
            ErrorReporter.logExceptionStackTrace(e);
            TitanLogExceptionHandler.handleException(new TechnicalException(logFile.getName() + ": Error while searching. Reason: " + e.getMessage()));
        }
    }
    monitor.done();
    return new Status(IStatus.OK, Constants.PLUGIN_ID, IStatus.OK, "Search done.", null);
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) SequentialLogFileReader(org.eclipse.titan.log.viewer.readers.SequentialLogFileReader) LogRecordIndex(org.eclipse.titan.log.viewer.models.LogRecordIndex) ParseException(java.text.ParseException) IOException(java.io.IOException) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 LogRecordIndex (org.eclipse.titan.log.viewer.models.LogRecordIndex)1 SequentialLogFileReader (org.eclipse.titan.log.viewer.readers.SequentialLogFileReader)1