Search in sources :

Example 1 with LogRecord

use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.

the class MSCModel method extractNodes.

/**
 * Extracts the nodes from the provided event object.
 *
 * @param ievent the event to extract the data from.
 * @param occurrence the number at which time this event happened in its order.
 *
 * @return the resulting list of nodes.
 */
private MSCNode[] extractNodes(final IEventObject ievent, final int occurrence) {
    if (!(ievent instanceof EventObject)) {
        return new MSCNode[] {};
    }
    EventObject event = (EventObject) ievent;
    String ref = event.getReference();
    String target = event.getTarget();
    String name = event.getName();
    String time = event.getTime();
    String type = event.getEventType();
    String sourcePort = event.getPort();
    String targetPort = event.getTargetPort();
    switch(event.getType()) {
        // TC start
        case TC_START:
            return testCaseStart(name, time, this.frame.lifeLinesCount(), occurrence);
        // TC end
        case TC_END:
            return testCaseEnd(name, time, this.frame.lifeLinesCount(), occurrence);
        // Creation of System Component
        case SYSTEM_CREATE:
            ref = Constants.SUT_REFERENCE;
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Creation of Host Controller (HC)
        case HC_CREATE:
            ref = Constants.HC_REFERENCE;
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Creation of Main Test Component (MTC)
        case MTC_CREATE:
            {
                ref = Constants.MTC_REFERENCE;
                Lifeline lifeLine = this.lifelines.get(ref);
                return createComponent(ref, time, lifeLine, occurrence);
            }
        // Creation of Parallel Test Component (PTC)
        case PTC_CREATE:
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Termination of System Component
        case SYSTEM_TERMINATE:
            ref = Constants.SUT_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Host Controller (HC)
        case HC_TERMINATE:
            ref = Constants.HC_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Main Test Component (MTC)
        case MTC_TERMINATE:
            ref = Constants.MTC_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Parallel Test Component (PTC)
        case PTC_TERMINATE:
            return terminateComponent(ref, time, occurrence);
        // Messages
        case SEND:
            return addSignal(new SendSignal(), ref, target, name, time, occurrence);
        case RECEIVE:
            return addSignal(new ReceiveSignal(), ref, target, name, time, occurrence);
        // Enqueued messages
        case ENQUEUED:
            return addEnqueued(ref, target, name, time, occurrence);
        // Silent events
        case SILENT_EVENT:
            LogRecord logrecord = null;
            try {
                logrecord = ValueReader.getInstance().readLogRecordFromLogFile(this.logFilePath, event);
            } catch (final IOException valueException) {
                return addSilentEvent(ref, "", type, time, occurrence);
            } catch (final ParseException e) {
                return addSilentEvent(ref, "", type, time, occurrence);
            }
            String messageText = getMessageTextFromRecord(logrecord);
            return addSilentEvent(ref, messageText, type, time, occurrence);
        // Functions
        case FUNCTION:
            return addFunctionNode(new Function(), ref, target, name, time, occurrence);
        // Function done
        case PTC_DONE:
            return addFunctionNode(new FunctionDone(), ref, target, name, time, occurrence);
        // Setverdict
        case SETVERDICT:
        case SETVERDICT_INCONC:
        case SETVERDICT_NONE:
        case SETVERDICT_PASS:
            return addSetVerdict(ref, name, time, occurrence);
        // Port mappings
        case MAPPING_PORT:
            return addPortEventNode(new PortMapping(sourcePort, targetPort), ref, target, time, occurrence);
        // Port unmappings
        case UNMAPPING_PORT:
            return addPortEventNode(new PortUnmapping(sourcePort, targetPort), ref, target, time, occurrence);
        // Port connections
        case CONNECTING_PORT:
            return addPortEventNode(new PortConnection(sourcePort, targetPort), ref, target, time, occurrence);
        // Port disconnections
        case DISCONNECTING_PORT:
            return addPortEventNode(new PortDisconnection(sourcePort, targetPort), ref, target, time, occurrence);
        default:
            return new MSCNode[] {};
    }
}
Also used : Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline) MSCNode(org.eclipse.titan.log.viewer.views.msc.ui.core.MSCNode) PortUnmapping(org.eclipse.titan.log.viewer.views.msc.ui.core.PortUnmapping) SendSignal(org.eclipse.titan.log.viewer.views.msc.ui.core.SendSignal) IOException(java.io.IOException) ReceiveSignal(org.eclipse.titan.log.viewer.views.msc.ui.core.ReceiveSignal) PortConnection(org.eclipse.titan.log.viewer.views.msc.ui.core.PortConnection) Function(org.eclipse.titan.log.viewer.views.msc.ui.core.Function) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) FunctionDone(org.eclipse.titan.log.viewer.views.msc.ui.core.FunctionDone) ParseException(java.text.ParseException) PortMapping(org.eclipse.titan.log.viewer.views.msc.ui.core.PortMapping) PortDisconnection(org.eclipse.titan.log.viewer.views.msc.ui.core.PortDisconnection)

Example 2 with LogRecord

use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.

the class OpenValueViewAction method run.

@Override
public void run() {
    if (selectedLine == null || this.mscView == null || selectedLine < 2 || selectedLine >= this.mscView.getModel().getNumberOfEvents() + 2) {
        return;
    }
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage == null) {
        return;
    }
    LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
    IProject project = getProjectByName(logFileMetaData);
    IFile logFile = getLogFileFromProject(logFileMetaData, project);
    if (!logFile.exists()) {
        IViewReference[] viewReferences = activePage.getViewReferences();
        ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewAction.1")));
        return;
    }
    if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
        LogFileCacheHandler.handleLogFileChange(logFile);
        return;
    }
    DetailsView detailsview = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
    if (detailsview == null && !forceEditorOpening) {
        return;
    }
    if (forceEditorOpening) {
        try {
            detailsview = (DetailsView) activePage.showView(Constants.DETAILS_VIEW_ID);
        } catch (PartInitException e) {
            ErrorReporter.logExceptionStackTrace(e);
            // $NON-NLS-1$
            TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.4") + e.getMessage()));
            return;
        }
    }
    // pass log file meta data
    detailsview.setLogFileMetaData(this.mscView.getLogFileMetaData());
    ExecutionModel model = this.mscView.getModel();
    IEventObject ieventObject = model.getEvent(selectedLine - 2);
    if (!(ieventObject instanceof EventObject)) {
        return;
    }
    EventObject eventObject = (EventObject) ieventObject;
    String testCase = model.getTestCase().getTestCaseName();
    if ((testCase == null) || eventObject.getRecordNumber() == 0) {
        return;
    }
    // get value
    LogRecord logrecord;
    try {
        logrecord = ValueReader.getInstance().readLogRecordFromLogFileCached(this.mscView.getLogFileMetaData().getFilePath(), eventObject);
    } catch (Exception e) {
        ErrorReporter.logExceptionStackTrace(e);
        // $NON-NLS-1$
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.3")));
        return;
    }
    String message = logrecord.getMessage();
    DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
    detailsview.setData(detailData, false);
}
Also used : IFile(org.eclipse.core.resources.IFile) DetailsView(org.eclipse.titan.log.viewer.views.DetailsView) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IProject(org.eclipse.core.resources.IProject) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) IEventObject(org.eclipse.titan.log.viewer.views.msc.model.IEventObject) PartInitException(org.eclipse.ui.PartInitException) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) IEventObject(org.eclipse.titan.log.viewer.views.msc.model.IEventObject) ExecutionModel(org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) UserException(org.eclipse.titan.log.viewer.exceptions.UserException) PartInitException(org.eclipse.ui.PartInitException) DetailData(org.eclipse.titan.log.viewer.views.details.DetailData)

Example 3 with LogRecord

use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.

the class FilteredLogReader method runFilter.

public void runFilter(final FilterPattern filterPattern, final IProgressMonitor monitor) throws ParseException, IOException {
    monitor.beginTask("Filtering", logReader.size());
    if (filterPattern == null || filterPattern.equals(this.filterPattern) || logReader.size() == 0) {
        monitor.done();
        return;
    }
    List<Integer> tmpFilteredRecords = new ArrayList<Integer>();
    for (int i = 0; i < logReader.size(); ++i) {
        if (monitor.isCanceled()) {
            monitor.done();
            return;
        }
        LogRecord aRecord;
        try {
            aRecord = logReader.getRecord(i);
        } catch (ParseException e) {
            ErrorReporter.logExceptionStackTrace(e);
            // $NON-NLS-1$
            ParseException throwable = new ParseException("Could not parse the " + i + "th record ", 0);
            throwable.initCause(e);
            monitor.done();
            throw throwable;
        }
        if (filterPattern.match(aRecord)) {
            tmpFilteredRecords.add(i);
        }
        monitor.worked(1);
    }
    filtered = true;
    filteredRecords = tmpFilteredRecords;
    this.filterPattern = filterPattern;
    monitor.done();
}
Also used : LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException)

Example 4 with LogRecord

use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.

the class SequentialLogFileReader method getNext.

/**
 * Returns the next log record or null if the reader is at the end of the file.
 * @return The parsed log record
 * @throws ParseException
 * @throws IOException
 */
public LogRecord getNext() throws ParseException, IOException {
    if (!hasNext()) {
        return null;
    }
    currentRecord++;
    LogRecord result = recordParser.parse(readRecord());
    result.setRecordOffset(logRecordIndexes[currentRecord].getFileOffset());
    result.setRecordLength(logRecordIndexes[currentRecord].getRecordLength());
    result.setRecordNumber(logRecordIndexes[currentRecord].getRecordNumber());
    return result;
}
Also used : LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord)

Example 5 with LogRecord

use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.

the class ValueReader method getValue.

private String getValue(final URI logFilePath, final long offset, final int length) throws IOException, ParseException {
    RandomAccessFile random = null;
    String message = null;
    try {
        random = new RandomAccessFile(new File(logFilePath), MSCConstants.READ_ONLY);
        random.seek(offset);
        byte[] buffer = new byte[length];
        random.read(buffer, 0, length);
        RecordParser recordParser = new RecordParser();
        LogRecord logRecord = recordParser.parse(buffer);
        message = logRecord.getMessage();
    } finally {
        IOUtils.closeQuietly(random);
    }
    return message;
}
Also used : RandomAccessFile(java.io.RandomAccessFile) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) RecordParser(org.eclipse.titan.log.viewer.parsers.RecordParser) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Aggregations

LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)21 ParseException (java.text.ParseException)9 EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)9 IFile (org.eclipse.core.resources.IFile)6 TableItem (org.eclipse.swt.widgets.TableItem)5 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)4 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)4 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 File (java.io.File)3 IWorkspace (org.eclipse.core.resources.IWorkspace)3 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 RecordParser (org.eclipse.titan.log.viewer.parsers.RecordParser)3 ExecutionModel (org.eclipse.titan.log.viewer.views.msc.model.ExecutionModel)3 RandomAccessFile (java.io.RandomAccessFile)2 ArrayList (java.util.ArrayList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2