Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2012-07-19 21:47:04 +0000
committerPatrick Tasse2012-07-19 22:27:39 +0000
commit602b68885e3c3baf244187fbae7908053a267cc8 (patch)
treec9579e50650ecce7090157f4dbc3c0d694171a28
parent2e7e8fbdd69f6060a793885aab56f6f418d3017d (diff)
downloadorg.eclipse.linuxtools-602b68885e3c3baf244187fbae7908053a267cc8.tar.gz
org.eclipse.linuxtools-602b68885e3c3baf244187fbae7908053a267cc8.tar.xz
org.eclipse.linuxtools-602b68885e3c3baf244187fbae7908053a267cc8.zip
Fix for bug 385432: Missed events in coalesced requests.
In addition to commit 04e0f4e84ffe07a23975f3d6e06849681f3afedf Change-Id: If53b5b322ef819d25f3fcf2ed7a3d542db124794 Reviewed-on: https://git.eclipse.org/r/6869 Reviewed-by: Francois Chouinard <fchouinard@gmail.com> IP-Clean: Francois Chouinard <fchouinard@gmail.com> Tested-by: Francois Chouinard <fchouinard@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java26
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java7
3 files changed, 34 insertions, 27 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
index acc606e49b..cc706fa265 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
@@ -429,7 +429,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "A-Test-10K";
- private static final int NB_EVENTS = 10000;
+ private static final int NB_EVENTS = 5000;
private static final int BLOCK_SIZE = 100;
// Initialize the test trace
@@ -476,6 +476,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
public void trigger(final TmfTestTriggerSignal signal) {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
+ final long REQUEST_OFFSET = 1000;
requestedEvents1 = new Vector<TmfEvent>();
request1 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
@@ -493,7 +494,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
};
requestedEvents2 = new Vector<TmfEvent>();
- request2 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
+ request2 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex + REQUEST_OFFSET, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData(TmfEvent event) {
super.handleData(event);
@@ -504,7 +505,7 @@ public class TmfCoalescedEventRequestTest extends TestCase {
};
requestedEvents3 = new Vector<TmfEvent>();
- request3 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
+ request3 = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData(TmfEvent event) {
super.handleData(event);
@@ -533,24 +534,24 @@ public class TmfCoalescedEventRequestTest extends TestCase {
request3.waitForCompletion();
try {
- assertEquals("Request1: nbEvents", NB_EVENTS - startIndex, requestedEvents1.size());
+ assertEquals("Request1: nbEvents", NB_EVENTS, requestedEvents1.size());
assertTrue ("Request1: isCompleted", request1.isCompleted());
assertFalse ("Request1: isCancelled", request1.isCancelled());
- assertEquals("Request2: nbEvents", NB_EVENTS - startIndex, requestedEvents2.size());
+ assertEquals("Request2: nbEvents", NB_EVENTS, requestedEvents2.size());
assertTrue ("Request2: isCompleted", request2.isCompleted());
assertFalse ("Request2: isCancelled", request2.isCancelled());
- assertEquals("Request3: nbEvents", NB_EVENTS - startIndex, requestedEvents3.size());
+ assertEquals("Request3: nbEvents", NB_EVENTS, requestedEvents3.size());
assertTrue ("Request3: isCompleted", request3.isCompleted());
assertFalse ("Request3: isCancelled", request3.isCancelled());
// Ensure that we have distinct events.
// Don't go overboard: we are not validating the stub!
- for (int i = 0; i < NB_EVENTS - startIndex; i++) {
- assertEquals("Distinct events", i + 1 + startIndex, requestedEvents1.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1 + startIndex, requestedEvents2.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i + 1 + startIndex, requestedEvents3.get(i).getTimestamp().getValue());
+ for (int i = 0; i < NB_EVENTS; i++) {
+ assertEquals("Distinct events", i + 1 + request1.getIndex(), requestedEvents1.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + request2.getIndex(), requestedEvents2.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + request3.getIndex(), requestedEvents3.get(i).getTimestamp().getValue());
}
}
finally {
@@ -592,9 +593,12 @@ public class TmfCoalescedEventRequestTest extends TestCase {
// Ensure that we have distinct events.
// Don't go overboard: we are not validating the stub!
+ for (int i = 0; i < BLOCK_SIZE; i++) {
+ assertEquals("Distinct events", i + 1 + request1.getIndex(), requestedEvents1.get(i).getTimestamp().getValue());
+ }
for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i+1, requestedEvents2.get(i).getTimestamp().getValue());
- assertEquals("Distinct events", i+1, requestedEvents3.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + request2.getIndex(), requestedEvents2.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1 + request3.getIndex(), requestedEvents3.get(i).getTimestamp().getValue());
}
TmfSignalManager.deregister(this);
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java
index 3ef4a37924..364ab3b728 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java
@@ -212,25 +212,25 @@ public class TmfCoalescedDataRequest<T extends ITmfEvent> extends TmfDataRequest
// ------------------------------------------------------------------------
@Override
- public void handleData(T data) {
- super.handleData(data);
- // Don't call sub-requests handleData() unless this is a
- // TmfCoalescedDataRequest; extended classes should call
- // the sub-requests handleData().
- if (getClass() == TmfCoalescedDataRequest.class) {
- long index = getIndex() + getNbRead();
- for (ITmfDataRequest<T> request : fRequests) {
- if (!request.isCompleted()) {
+ public void handleData(T data) {
+ super.handleData(data);
+ // Don't call sub-requests handleData() unless this is a
+ // TmfCoalescedDataRequest; extended classes should call
+ // the sub-requests handleData().
+ if (getClass() == TmfCoalescedDataRequest.class) {
+ long index = getIndex() + getNbRead() - 1;
+ for (ITmfDataRequest<T> request : fRequests) {
+ if (!request.isCompleted()) {
if (request.getDataType().isInstance(data)) {
long start = request.getIndex();
- long end = start + request.getNbRequested() - 1;
+ long end = start + request.getNbRequested();
if (index >= start && index < end) {
request.handleData(data);
}
}
- }
- }
- }
+ }
+ }
+ }
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java
index a315559670..9097649911 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java
@@ -209,13 +209,16 @@ public class TmfCoalescedEventRequest<T extends ITmfEvent> extends TmfCoalescedD
@Override
public void handleData(T data) {
super.handleData(data);
+ long index = getIndex() + getNbRead() - 1;
for (ITmfDataRequest<T> request : fRequests) {
if (data == null) {
request.handleData(null);
} else {
+ long start = request.getIndex();
+ long end = start + request.getNbRequested();
if (request instanceof TmfEventRequest<?>) {
TmfEventRequest<T> req = (TmfEventRequest<T>) request;
- if (!req.isCompleted() && (getIndex() + getNbRead() > request.getIndex())) {
+ if (!req.isCompleted() && index >= start && index < end) {
ITmfTimestamp ts = data.getTimestamp();
if (req.getRange().contains(ts)) {
if (req.getDataType().isInstance(data)) {
@@ -226,7 +229,7 @@ public class TmfCoalescedEventRequest<T extends ITmfEvent> extends TmfCoalescedD
}
else {
TmfDataRequest<T> req = (TmfDataRequest<T>) request;
- if (!req.isCompleted()) {
+ if (!req.isCompleted() && index >= start && index < end) {
if (req.getDataType().isInstance(data)) {
req.handleData(data);
}

Back to the top