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();
}
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();
}
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();
}
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);
}
}
}
});
}
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();
}
Aggregations