Search in sources :

Example 1 with StreamListAnalysis

use of org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis in project tracecompass by tracecompass.

the class StreamListAnalysisTest method executeAnalysisTest.

/**
 * Method that execute the analysis and verify the results.
 *
 * @throws TmfAnalysisException
 *             Thrown when an analysis error occurs during the setup or
 *             execution. Fails the test.
 * @throws TmfTraceException
 *             Thrown when the trace cannot be initialized. Fails the test.
 */
@Test
public void executeAnalysisTest() throws TmfAnalysisException, TmfTraceException {
    PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP;
    assumeTrue(trace.exists());
    String path = trace.getPath().toString();
    PcapTrace pcapTrace = new PcapTrace();
    StreamListAnalysis analysis = new StreamListAnalysis();
    pcapTrace.initTrace(null, path, null);
    analysis.setId(StreamListAnalysis.ID);
    analysis.setTrace(pcapTrace);
    analysis.schedule();
    analysis.waitForCompletion();
    // Verify that builders are not empty.
    TmfPacketStreamBuilder builder = analysis.getBuilder(TmfPcapProtocol.ETHERNET_II);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(1, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.IPV4);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(3, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.TCP);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(2, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.UDP);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(1, builder.getNbStreams());
    analysis.dispose();
    pcapTrace.dispose();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) TmfPacketStreamBuilder(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) PcapTestTrace(org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace) Test(org.junit.Test)

Example 2 with StreamListAnalysis

use of org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis in project tracecompass by tracecompass.

the class StreamListAnalysisTest method canExecuteTest.

/**
 * Method that tests canExecute().
 *
 * @throws TmfTraceException
 *             Thrown when the trace cannot be initialized. Fails the test.
 */
@Test
public void canExecuteTest() throws TmfTraceException {
    PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP;
    assumeTrue(trace.exists());
    String path = trace.getPath().toString();
    PcapTrace pcapTrace = new PcapTrace();
    StreamListAnalysis analysis = new StreamListAnalysis();
    analysis.setId(StreamListAnalysis.ID);
    pcapTrace.initTrace(null, path, null);
    assertTrue(analysis.canExecute(pcapTrace));
    analysis.dispose();
    pcapTrace.dispose();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) PcapTestTrace(org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace) Test(org.junit.Test)

Example 3 with StreamListAnalysis

use of org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis in project tracecompass by tracecompass.

the class StreamListAnalysisTest method constructorTest.

/**
 * Method that tests the constructor.
 */
@Test
public void constructorTest() {
    StreamListAnalysis analysis = new StreamListAnalysis();
    analysis.setId(StreamListAnalysis.ID);
    for (TmfPcapProtocol protocol : TmfPcapProtocol.values()) {
        if (protocol.supportsStream()) {
            assertNotNull(analysis.getBuilder(protocol));
        }
    }
    assertFalse(analysis.isFinished());
    analysis.dispose();
}
Also used : TmfPcapProtocol(org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) Test(org.junit.Test)

Example 4 with StreamListAnalysis

use of org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis in project tracecompass by tracecompass.

the class StreamListView method updateUI.

private void updateUI() {
    final Display display = Display.getDefault();
    if (display == null || display.isDisposed()) {
        return;
    }
    display.asyncExec(() -> {
        if (display.isDisposed()) {
            return;
        }
        ITmfTrace trace = fCurrentTrace;
        if (trace == null) {
            return;
        }
        StreamListAnalysis analysis = TmfTraceUtils.getAnalysisModuleOfClass(trace, StreamListAnalysis.class, StreamListAnalysis.ID);
        if (analysis == null) {
            return;
        }
        Map<TmfPcapProtocol, Table> tables = fTableMap;
        if (tables == null) {
            return;
        }
        for (Entry<TmfPcapProtocol, Table> protocolEntry : tables.entrySet()) {
            TmfPcapProtocol protocol = protocolEntry.getKey();
            TmfPacketStreamBuilder builder = analysis.getBuilder(protocol);
            Table table = protocolEntry.getValue();
            if (builder != null && !(table.isDisposed())) {
                for (TmfPacketStream stream : builder.getStreams()) {
                    TableItem item;
                    if (stream.getID() < table.getItemCount()) {
                        item = table.getItem(stream.getID());
                    } else {
                        item = new TableItem(table, SWT.NONE);
                    }
                    item.setText(0, String.valueOf(stream.getID()));
                    item.setText(1, stream.getFirstEndpoint().toString());
                    item.setText(2, stream.getSecondEndpoint().toString());
                    item.setText(3, String.valueOf(stream.getNbPackets()));
                    item.setText(4, String.valueOf(stream.getNbBytes()));
                    item.setText(5, String.valueOf(stream.getNbPacketsAtoB()));
                    item.setText(6, String.valueOf(stream.getNbBytesAtoB()));
                    item.setText(7, String.valueOf(stream.getNbPacketsBtoA()));
                    item.setText(8, String.valueOf(stream.getNbBytesBtoA()));
                    item.setText(9, stream.getStartTime().toString());
                    item.setText(10, stream.getStopTime().toString());
                    // $NON-NLS-1$
                    item.setText(11, String.format("%.3f", stream.getDuration()));
                    // $NON-NLS-1$
                    item.setText(12, String.format("%.3f", stream.getBPSAtoB()));
                    // $NON-NLS-1$
                    item.setText(13, String.format("%.3f", stream.getBPSBtoA()));
                    item.setData(KEY_STREAM, stream);
                }
            }
        }
    });
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Table(org.eclipse.swt.widgets.Table) TmfPcapProtocol(org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol) TmfPacketStreamBuilder(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder) TmfPacketStream(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStream) TableItem(org.eclipse.swt.widgets.TableItem) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) Display(org.eclipse.swt.widgets.Display)

Example 5 with StreamListAnalysis

use of org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis in project tracecompass by tracecompass.

the class StreamListView method queryAnalysis.

private void queryAnalysis() {
    Thread thread = new Thread(() -> {
        ITmfTrace trace = fCurrentTrace;
        if (trace == null) {
            return;
        }
        StreamListAnalysis analysis = TmfTraceUtils.getAnalysisModuleOfClass(trace, StreamListAnalysis.class, StreamListAnalysis.ID);
        if (analysis == null) {
            return;
        }
        while (!analysis.isFinished() && !fStopThread) {
            updateUI();
            try {
                Thread.sleep(WAIT_TIME);
            } catch (InterruptedException e) {
                String message = e.getMessage();
                if (message == null) {
                    message = EMPTY_STRING;
                }
                Activator.logError(message, e);
                return;
            }
        }
        // Update UI one more time (daft punk)
        if (!fStopThread) {
            updateUI();
        }
    });
    fStopThread = false;
    thread.start();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis)

Aggregations

StreamListAnalysis (org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis)5 Test (org.junit.Test)3 TmfPacketStreamBuilder (org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder)2 TmfPcapProtocol (org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol)2 PcapTrace (org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace)2 PcapTestTrace (org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 Display (org.eclipse.swt.widgets.Display)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TmfPacketStream (org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStream)1